Trying to load a .rc Dialog
Hi everyone,
i am trying to load a Dialog from a .rc file i created and its just not loading:-(
i created the dialog in Visual Studio 2008 and its Called dlgChangeDialog and has the same ID
now i try to call the DialogBox function like this:
nResult = DialogBox(m_hDLL, LPCWSTR("dlgChangeDevice"), hWnd, DlgProcWrap);
but nResult is always -1
can anyone tell me what i might be doing wrong?
Thx a lot in advance for any hints you guys might have
Are you using Unicode?
Anyhow, you should NEVER cast a string like that. If there is a warning it's there for a reason.
If you're using Unicode change the line to:
DialogBox( m_hDLL, L"dlgChangeDevice", hWnd, DlgProcWrap );
else to:
DialogBox( m_hDLL, "dlgChangeDevice", hWnd, DlgProcWrap );
If neither works try the MAKEINTRESOURCE makro:
DialogBox( m_hDLL, MAKEINTRESOURCE( dlgChangeDevice ), hWnd, DlgProcWrap );
dlgChangeDevice should be defined in resource.h, don't forget to include it.
Anyhow, you should NEVER cast a string like that. If there is a warning it's there for a reason.
If you're using Unicode change the line to:
DialogBox( m_hDLL, L"dlgChangeDevice", hWnd, DlgProcWrap );
else to:
DialogBox( m_hDLL, "dlgChangeDevice", hWnd, DlgProcWrap );
If neither works try the MAKEINTRESOURCE makro:
DialogBox( m_hDLL, MAKEINTRESOURCE( dlgChangeDevice ), hWnd, DlgProcWrap );
dlgChangeDevice should be defined in resource.h, don't forget to include it.
I had same kind of a problem just yesterday. After trying nearly everything I found out that dialogs created with DialogBox() don't support all window controls. In my case the conflicting control was a status bar. After I removed it the dialog loaded fine.
Good catch, latelate.
For some more complex controls you need to either call InitCommonControls(Ex) or load a library (RichEdit).
For some more complex controls you need to either call InitCommonControls(Ex) or load a library (RichEdit).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement