CreateDialog() fails (Win32 dialog creation function)
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2007-06-22
08:16 AM
- last edited on
2023-08-07
10:34 AM
by
Doreena Deng
2007-06-22
08:16 AM
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
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
Labels:
- Labels:
-
Add-On (C++)
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2007-06-22 09:58 AM
2007-06-22
09:58 AM
csh wrote: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.
//
// 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
HTH,
Akos
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2007-07-07 03:57 PM
2007-07-07
03:57 PM
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
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2007-08-18 02:32 PM
2007-08-18
02:32 PM
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):
best regards
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