We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad C++ API
About Archicad add-on development using the C++ API.

CreateDialog() fails (Win32 dialog creation function)

Anonymous
Not applicable
Instead of creating a User Control, for various reasons, I want to launch a modeless dialog box using CreateDialog(). I've created a dialog (IDD_FORMVIEW) in the resource file (note that there is an *.rc2 file, but when you create a dialog, an *.rc file is created along with resource.h), added the resource.h file to my cpp file, and modified the entry point in my cpp file as follows:

static void Do_APIMyAddOn (void)
{
/*
// ArchiCAD API modeless dialog code starts here...
GSResModule actResModule = ACAPI_UseOwnResModule ();

myAddOnDialID = DGModelessInit (MYADDON_ID, APIMyAddOn_Handler, NULL, 1);
ACAPI_ResetResModule (actResModule);
// ArchiCAD API modeless dialog code ends here...
*/

//
// Win32 modeless dialog creation code starts here...
DWORD error;

if (hwnd == NULL) {
hwnd = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_FORMVIEW), NULL, (DLGPROC)DlgProc);
if (hwnd == NULL) {
error = GetLastError();
} else {
ShowWindow(hwnd, SW_SHOW);
}
}
// Win32 modeless dialog creation code ends here...
//
}

hwnd == NULL and error == 1814 ("The specified resource name cannot be found in the image file"). Any ideas on why I can't create the dialog via the resource mechanism?

thanks in advance, Chuck
3 REPLIES 3
Akos Somorjai
Graphisoft
Graphisoft
csh wrote:
//
// Win32 modeless dialog creation code starts here...
DWORD error;

if (hwnd == NULL) {
hwnd = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_FORMVIEW), NULL, (DLGPROC)DlgProc);
if (hwnd == NULL) {
error = GetLastError();
} else {
ShowWindow(hwnd, SW_SHOW);
}
}
// Win32 modeless dialog creation code ends here...
//
}

hwnd == NULL and error == 1814 ("The specified resource name cannot be found in the image file"). Any ideas on why I can't create the dialog via the resource mechanism?

thanks in advance, Chuck
I think even if you used the Windows native dialogs, you'd still have to set the resource module to the add-on using ACAPI_UseOwnResModule. But first check if the resource is really there by opening the compiled add-on in resource view.

HTH,

Akos
Anonymous
Not applicable
Here's are the parameters that make it work:

hwnd = CreateDialog(ACAPI_GetExtensionInstance (), MAKEINTRESOURCE(IDD_DIALOG1), ACAPI_GetMainWindow (), (DLGPROC)DlgProc);

(Substitute your own IDD and procedure for my IDD_DIALOG1 and DlgProc respectively).

thanks, Chuck
Anonymous
Not applicable
Hello,

I've took working example plugin from ArchiCAD SDK, and add code which should open dialog box (as shown below). But each time I use any of <windows.h> functions ArchiCAD crashes with out any understable and visible error for me. Bug reporting tool opens, and that's all of my dialog box. Application exits after it shows a border of my dialog box. Buttons inside dialog are invisible. What could be wrong? I use ArchiCAD 10 and sdk 10. Changed plugin name: Automate_Functions (added one position to menu):
HWND _win;  
  
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)  
{  
	return FALSE;  
}  
  
static void Do_Window()  
{  
	_win = CreateDialog(ACAPI_GetExtensionInstance (), MAKEINTRESOURCE(IDD_DIALOG1), ACAPI_GetMainWindow(), (DLGPROC)DialogProc);   
	//ACAPI_GetExtensionInstance();  
	//ACAPI_GetMainWindow();  
	if(_win != NULL)  
		ShowWindow(_win, SW_SHOW);  
}


best regards