Advertisement

Window won´t show itself

Started by July 22, 2002 05:01 AM
2 comments, last by shakazed 22 years, 3 months ago
I´ve amde a class so that I can simplify the windows creation process for later projects. The problem is that it won´t show itself. Build and compile shows no errors. Here´s the code. ////////////////////////////////////////////////////////////////////////////////////// //cWindows header ///////////////////////////////////////////////////////////////////////////////////// #include //Necessary windows funcs. and macros. class Win; //////////////////////////////////////////////////////////////////////////////////////////////// //Windows initialization ////////////////////////////////////////////////////////////////////////////////////////////////// class Win { public: void WinInit(HINSTANCE hInstance); bool CreateWin(char *WinName, HINSTANCE hInstance); static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); private: WNDCLASSEX m_wClass; HWND hWnd; }; //End of definition void Win::WinInit(HINSTANCE hInstance) { m_wClass.cbSize = sizeof(WNDCLASSEX); m_wClass.cbClsExtra = 0; m_wClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); m_wClass.cbWndExtra = 0; m_wClass.hCursor = LoadCursor(NULL, IDC_ARROW); m_wClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); m_wClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); m_wClass.lpfnWndProc = WndProc; m_wClass.lpszClassName = "Window Class"; m_wClass.lpszMenuName = NULL; m_wClass.style = CS_HREDRAW|CS_VREDRAW; m_wClass.hInstance = hInstance; } bool Win::CreateWin(char *WinName, HINSTANCE hInstance) { hWnd = CreateWindowEx(NULL, "Window Class", WinName, WS_OVERLAPPEDWINDOW|WS_VISIBLE,100,100, 640,480,NULL, NULL,hInstance, NULL); if(hWnd==NULL) return false; return true; } LRESULT CALLBACK Win::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_DESTROY: { PostQuitMessage(0); return 0; }break; } return DefWindowProc(hWnd, msg, wParam, lParam); } sHaKaZeD

http://www26.brinkster.com/shakazed/
are you calling showwindow at all?

---
Come to #directxdev IRC channel on AfterNET
Advertisement
You got ShowWindow(hWnd, SW_SHOW) anywhere?
what about a RegisterClassEx call? meh all i can see missing...
eh?
He shouldnt need to call ShowWindow because he has specified the WS_VISIBLE style in the windows creation. It might be the RegisterClassEx() call (or lack thereof) but i thought an assert would be fired if CreateWindow was called with an unregistered class.

Another thing i dont understand is, I didnt think you could use static vars/functions in non-static functions (m_wClass.lpfnWndProc = WndProc where WndProc is static). I mostly point that out because ive recently tried to do the exact same thing for a dialog box and had to make all its functions and variables static to accommodate the static WndProc which is to say the least annoying- having a whole class with nothing but static members and functions, it kind of destroys the idea of having a class at all lol.

Anyway id have to go with forgotton_associator and assume its the lack of a RegisterClass call.

Edit: doh, forget all what I said about the static func, its the other way round: you cant reference non-static members from static funcs .

[edited by - Zeke on July 23, 2002 12:25:32 PM]
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face

This topic is closed to new replies.

Advertisement