Ok I quit programming for one month and now i started again so here i wrote my empty window program:
Can you please get the error in there because when i run the program, it give me the messagebox saying "Error Creating Hwnd".Code:#include <windows.h> LRESULT CALLBACK WndProc(HWND hwnd, UINT imsg, WPARAM wparam, LPARAM lparam) { switch(imsg) { case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, imsg, wparam, lparam); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { WNDCLASSEX wc; MSG msg; HWND winhwnd; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; 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)GetStockObject(LTGRAY_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = "mycalss"; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Error in Class Registeration", "Error", MB_OK); return 0; } winhwnd = CreateWindow("myclass", "the title", WS_OVERLAPPEDWINDOW, 0,0,34,34,NULL,NULL,hInstance,NULL); if(winhwnd == NULL) { MessageBox(NULL, "Error Creating Hwnd", "Error", MB_OK); return 0; } ShowWindow(winhwnd, nShowCmd); while(GetMessage(&msg, NULL, 0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
Thanks!




Reply With Quote