Trying to load a .rc Dialog

Started by
2 comments, last by Endurion 15 years, 5 months ago
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
Advertisement
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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

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).

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement