Archived

This topic is now archived and is closed to further replies.

im new so help

errror

Recommended Posts

I cant find the problem with this code. #include int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow) { char className [] = ""; WinClassMaker winClass (WinProcedure, className, hInst); winClass.Register (); WinMaker maker (className, hInst); Window win = maker.Create (""); win.Display (cmdShow); // Message loop MSG msg; int status; while ((status = ::GetMessage (& msg, 0, 0, 0)) != 0) { if (status == -1) return -1; ::DispatchMessage (& msg); } return msg.wParam; } class WinClassMaker { public: WinClassMaker (WNDPROC WinProcedure, char const * className, HINSTANCE hInst); void Register () { if (::RegisterClassEx (&_class) == 0) throw "RegisterClass failed"; } private: WNDCLASSEX _class; }; WinClassMaker::WinClassMaker (WNDPROC WinProcedure, char const * className, HINSTANCE hInst) { _class.lpfnWndProc = WinProcedure;// window procedure: mandatory _class.hInstance = hInst; // owner of the class: mandatory _class.lpszClassName = className; // mandatory _class.cbSize = sizeof (WNDCLASSEX); _class.hCursor = ::LoadCursor (0, IDC_ARROW); _class.hbrBackground = reinterpret_cast (COLOR_WINDOW + 1); _class.style = 0; _class.cbClsExtra = 0; _class.cbWndExtra = 0; _class.hIcon = 0; _class.hIconSm = 0; _class.lpszMenuName = 0; } class WinMaker { public: WinMaker (char const * className, HINSTANCE hInst); HWND Create (char const * title); private: HINSTANCE _hInst; // program instance char const *_className; // name of Window class DWORD _style; // window style DWORD _exStyle; // window extended style int _x; // horizontal position of window int _y; // vertical position of window int _width; // window width int _height; // window height HWND _hWndParent; // handle to parent or owner window HMENU _hMenu; // handle to menu, or child-window id void * _data; // pointer to window-creation data }; WinMaker::WinMaker (char const * className, HINSTANCE hInst) : _style (WS_OVERLAPPEDWINDOW), _exStyle (0), _className (className), _x (CW_USEDEFAULT), // horizontal position of window _y (0), // vertical position of window _width (CW_USEDEFAULT), // window width _height (0), // window height _hWndParent (0), // handle to parent or owner window _hMenu (0), // handle to menu, or child-window identifier _data (0), // pointer to window-creation data _hInst (hInst) {} HWND WinMaker::Create (char const * title) { HWND hwnd = ::CreateWindowEx ( _exStyle, _className, title, _style, _x, _y, _width, _height, _hWndParent, _hMenu, _hInst, _data); if (hwnd == 0) throw "Window Creation Failed"; return hwnd; } class Window { public: Window (HWND h = 0) : _h (h) {} void Display (int cmdShow) { assert (_h != 0); ::ShowWindow (_h, cmdShow); ::UpdateWindow (_h); } private: HWND _h; }; LRESULT CALLBACK WinProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage (0); return 0; } return ::DefWindowProc (hwnd, message, wParam, lParam ); } Edited by - im new so help on November 18, 2001 10:38:34 AM

Share this post


Link to post
Share on other sites
What does it do?

You know when posting code you should put it inbetween [ s o u r c e] and [ / s o u r c e ] (without the spaces), or the < symbols are cosidered as HTML tags and the code gets corrupted.

Share this post


Link to post
Share on other sites