This is a bit weird and I don't know why it happens but if you have a dialog with an application defined class you cannot load it from a DLL directly. This is the only way I have gotten it to work

invoke FindResource,, IDD_MAIN, RT_DIALOG
mov , eax
invoke LoadResource, ,
mov ,eax
invoke LockResource,
mov ,eax

invoke CreateDialogIndirectParam, , , NULL, NULL, NULL

test eax,eax
jnz >
// If we were unable to create the dialog shut down
invoke FreeResource,
invoke ExitProcess, -1
:
mov ,eax
invoke FreeResource,


Seems to work perfectly this way, both in 98SE and XP. However if I use...

invoke CreateDialogParam, ,IDD_MAIN, NULL, NULL, NULL


The dialog gives me the "Class not found" error. Regular dialogs and all other resources work fine though, it is only those with applicaion defined classes that fail. The class is defined in the main application as follows..

// Define our main window class and register it
mov D, SIZEOF WNDCLASSEX
mov D, NULL ; CS_HREDRAW + CS_VREDRAW
mov D, OFFSET MainDlgProc
mov D, NULL
mov D, DLGWINDOWEXTRA
mov eax,
mov D, eax
mov D, COLOR_BTNFACE + 1
mov D, NULL
mov D, OFFSET ClassName
invoke LoadIcon, NULL, IDI_APPLICATION
mov D, eax
mov D, eax
invoke LoadCursor,NULL,IDC_ARROW
mov D, eax

invoke RegisterClassEx, addr wc


Anyone know why this is the case ?
Posted on 2005-08-09 23:55:21 by donkey