BIM Coordinator Program (INT) April 22, 2024
Find the next step in your career as a Graphisoft Certified BIM Coordinator!
Archicad C++ API
About Archicad add-on development using the C++ API.

'DGModelessInit' : cannot convert parameter 2 in x64 window

Anonymous
Not applicable
I finished compiling and testing a project in 32bit Archicad but when I am compiling the same project with X64 option. I ran into trouble with the dialogue handler.

For eg,
in the example project "DG_Test" supplied with the APIDevKit .

the line:
isOK = (DGModalDialog (Fill_GDLGID, Fill_Handler, (DGUserData) &prefsData) == DG_OK);

where :

fill_Handler is a call back function :
static short DGCALLBACK Fill_Handler (short message, short dialogID, short item, DGUserData userData, DGMessageData msgData){...}

This will compile and run normally in archicad 32 bit however if I changed active solution platform in visual studio 2005 to "X64" , I will get this error on compilation:

: error C2664: 'DGModelessInit' : cannot convert parameter 2 from 'short (__cdecl *)(short,short,short,long,long)' to 'const DGDialCallBack'



How can I get around this? is DGModeless or DGModal supported in x64 development? I am really stuck on this part. Would appreciate any advice. Thanks

Alfred
3 REPLIES 3
Ralph Wessel
Mentor
ALFREDMAN wrote:
How can I get around this? is DGModeless or DGModal supported in x64 development? I am really stuck on this part. Would appreciate any advice.
Yes, these calls are supported and work fine in my experience. I can't tell why this isn't working from the information you provided. Could you post some code snippets at the declaration of the callback and the point leading up to and including the call to DGModeless?
Ralph Wessel BArch
Anonymous
Not applicable
This is a very simple code snip that shows how it fails to work in my case:

In this example, i am just trying to call the progress bar up :

#include ".\commonprogressdg.h"

CProgressDG::~CProgressDG(void)
{
delete[] m_title;
}
CProgressDG::CProgressDG(short progBarRes, char* title,long minVal, long maxVal)
{
m_progBarRes=progBarRes;
m_title = new char[256];
CHCopyC(title,m_title);
m_minVal=minVal;
m_maxVal=maxVal;
m_curVal=m_minVal;
GSResModule filNum;
short dialID;
filNum = ACAPI_UseOwnResModule (); // Set own resource file the active one
dialID = DGModelessInit (m_progBarRes, CProgressDG::progressBarCallBack,(DGUserData) this,1);
ACAPI_ResetResModule (filNum);
}

static short DGCALLBACK CProgressDG::progressBarCallBack ( short message,
short dialId,
short item,
DGUserData userData,
DGMessageData msgData)
{
msgData=0;
item=0;
// long val=0;
CProgressDG* pThisData=(CProgressDG*) userData;

short result=0;
switch (message) {
case DG_MSG_INIT:
DGSetDialogTitle (dialId,pThisData->m_title);
DGSetItemMinLong (dialId, 1, pThisData->m_minVal);
DGSetItemMaxLong (dialId, 1, pThisData->m_maxVal);
DGSetItemValLong (dialId, 1, 0);// m_maxProgress);
break;
}
return (result);
} // Browser_CB

void CProgressDG::setValue(long val)
{
DGSetItemValLong (m_progBarRes, 1, val);
}
void CProgressDG::closeDG()
{
DGModelessClose (m_progBarRes);
}







************************************************************
This same piece of code will compile and runs if I dont choose the active platform to be x64. But once x64 is used, the error goes here:

dialID = DGModelessInit (m_progBarRes, CProgressDG::progressBarCallBack,(DGUserData) this,1);


1>..\..\..\..\..\..\_Common\OnumaCommon\CommonProgressDG.cpp(18) : error C2664: 'DGModelessInit' : cannot convert parameter 2 from 'short (__cdecl *)(short,short,short,long,long)' to 'const DGDialCallBack'



Please help.
Ralph Wessel
Mentor
ALFREDMAN wrote:
This is a very simple code snip that shows how it fails to work in my case:
I don't know why this is failing to compile in this case. Perhaps there is a problem in the project configuration? I suggest looking at the example project Navigator_test - it includes a call to DGModelessInit and compiles for a x64 target without problems.

BTW - I notice you are still using the long data type in your code. As part of the migration to 64-bit, I would be more explicit about the required integer width (Int32, Int64, etc).
Ralph Wessel BArch
Learn and get certified!