Windows class not created error?
-
Hi, I am experiencing some real trouble with a simple windows program that I am trying to create. After running the CreateDialog() function, windows returns the error "Windows class not created". I am having trouble determing what this message is really telling me. The result of this error message is that after processing the WM_SETFONT message inside the DlgProc for the Dialog Box that it creates, Windows always processes the WM_DESTROY instead of the WM_INITDIALOG which is the next message that my other working windows programs processes which creates and displays the dialog box. I have posted my WinAPI function below:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int nCmdShow) { MSG msg; HWND mainWnd; hInst = hInstance; // Make instance available globally InitCommonControls(); // Create a dummy window so the dialog box can have a parent window, then // create the dialog box itself. mainWnd = CreateWindow("", "", 0, 0, 0, 0, 0, NULL,(HMENU)-1, hInstance, 0); MainDlgBox = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_AURACONNECT), mainWnd, (DLGPROC)DlgProc); DWORD Err = GetLastError(); SetClassLong(mainWnd,GCL_HICON,IDI_EXE); // Standard Windows message loop while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
Thank you for anyone who can offer any help. Joe -
Hi, I am experiencing some real trouble with a simple windows program that I am trying to create. After running the CreateDialog() function, windows returns the error "Windows class not created". I am having trouble determing what this message is really telling me. The result of this error message is that after processing the WM_SETFONT message inside the DlgProc for the Dialog Box that it creates, Windows always processes the WM_DESTROY instead of the WM_INITDIALOG which is the next message that my other working windows programs processes which creates and displays the dialog box. I have posted my WinAPI function below:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int nCmdShow) { MSG msg; HWND mainWnd; hInst = hInstance; // Make instance available globally InitCommonControls(); // Create a dummy window so the dialog box can have a parent window, then // create the dialog box itself. mainWnd = CreateWindow("", "", 0, 0, 0, 0, 0, NULL,(HMENU)-1, hInstance, 0); MainDlgBox = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_AURACONNECT), mainWnd, (DLGPROC)DlgProc); DWORD Err = GetLastError(); SetClassLong(mainWnd,GCL_HICON,IDI_EXE); // Standard Windows message loop while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
Thank you for anyone who can offer any help. JoeCan you post your DlgProc code? Also, if the dialog is the main window of the app, does it need the dummy parent window? Mark
-
Can you post your DlgProc code? Also, if the dialog is the main window of the app, does it need the dummy parent window? Mark
My DlgProc is rather lengthy, so I don't think I can post it, but is that what is most likely causing error? I don't know if it needs a dummy window, I'll try it without it.
-
My DlgProc is rather lengthy, so I don't think I can post it, but is that what is most likely causing error? I don't know if it needs a dummy window, I'll try it without it.
TheDelChop wrote:
but is that what is most likely causing error?
Actually I thought that might be the case, since you stated you had other similar working apps. Looking at your code again this morning, though, I would try changng this line: SetClassLong(mainWnd,GCL_HICON,IDI_EXE); to SetClassLong(mainWnd,GCL_HICON,LoadIcon(hInstance, MAKEINTRESOURCE(IDI_EXE));