Hello.
Sorry, I realize there are millions of threads about dialog boxes here, but I've searched through them loads and haven't yet found an answer to my problem. Like most noobs here, I'm using the tutorial at www.winprog.net. Anyways, heres my code:
Windows.cpp
Control1.rcCode:#include <windows.h> #define IDC_STATIC '-1' const char g_szClassName[] = "WindowClass"; HWND hWindowHandle; //////////////////////////////////////////////////////////////////////////////// ////////////////////////////// Control1 procedure ////////////////////////////// //////////////////////////////////////////////////////////////////////////////// BOOL CALLBACK Control1DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: EndDialog(hwnd, IDOK); break; case IDCANCEL: EndDialog(hwnd, IDCANCEL); break; } break; default: return FALSE; } return TRUE; } //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: int Control1_Result; Control1_Result = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(101), hwnd, Control1DlgProc); if(Control1_Result == -1) { MessageBox(hWindowHandle, "Dialog failed!", "Error", MB_OK | MB_ICONINFORMATION); } break; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; MSG MainMessage; //Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 11); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } // Step 2: Creating the Window hWindowHandle = CreateWindowEx( WS_EX_CLIENTEDGE | WS_EX_TOPMOST, g_szClassName, "Windows Application", WS_DLGFRAME, 120, 120, 240, 240, NULL, NULL, hInstance, NULL); if(hWindowHandle == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hWindowHandle, nCmdShow); UpdateWindow(hWindowHandle); // Step 3: The Message Loop while(GetMessage(&MainMessage, NULL, 0, 0) > 0) { TranslateMessage(&MainMessage); DispatchMessage(&MainMessage); } return MainMessage.wParam; }
Control1.hCode:#include <windows.h> #if !defined IDC_STATIC #define IDC_STATIC -1 #endif IDD_Control1 DIALOG DISCARDABLE 120, 120, 240, 65 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Windows Application" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "&Yes",IDYES,174,18,50,14 PUSHBUTTON "&No",IDNO,174,35,50,14 GROUPBOX "Login", IDC_STATIC,7,7,225,52 CTEXT "Do you wish to login to Windows Application?", IDC_STATIC,16,18,144,33 END
My problem is that the dialog simply dosen't show. Hence the title.Code:#define IDD_CONTROL1 101
Any suggestions?
Cheers!



LinkBack URL
About LinkBacks


