// WindowMaker.cpp // // 'Maker' is synonomous with 'Creator'; therefore, this class // handles window creation. // // Revision Log // // Date Who SAR Notes // ========== === ======= ===================================== // (c) Reliable Software, 1997, 98 // Bartosz Milewski, www.relisoft.com // 2001-06-04 mph add namespace rfc (Reliable Foundation Class) // 2001-10-22 mph Add functionality // #include #include "WindowMaker.h" #include "WinException.h" #include "ResString.h" // The maker of a window of a given class namespace rfc { WindowMaker::WindowMaker(const char* className, HINSTANCE hInst) : _hwnd(0), _exStyle(0), // extended window style _className(className), // class name for the window _style(0), // window style _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 _Instance(hInst) // application instance //_data(0) // pointer to window-creation data { } WindowMaker::WindowMaker(UINT classStringtableId, HINSTANCE hInst) : _hwnd(0), _exStyle(0), // extended window style _style(0), // window style _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 _Instance(hInst) // application instance //_data(0) // pointer to window-creation data { rfc::ResString className(_Instance, classStringtableId); _className = className; } HWND WindowMaker::Create(int captionId, void* controller) { ResString caption(_Instance, captionId); return Create(caption, controller); } HWND WindowMaker::Create(const char* caption, void* controller) { _hwnd = ::CreateWindowEx( _exStyle, _className.c_str(), caption, _style, _x, _y, _width, _height, _hWndParent, _hMenu, _Instance, controller); if (_hwnd == 0) throw WinException("Internal error: Window Creation Failed.", __FILE__, __LINE__); return _hwnd; } void WindowMaker::Show(int nCmdShow) { ::ShowWindow(_hwnd, nCmdShow); ::UpdateWindow(_hwnd); } /* TopWindowMaker::TopWindowMaker (char const * caption, int idClassName, HINSTANCE hInst, const char* caption) : WindowMaker (idClassName, hInst) { _style = WS_OVERLAPPEDWINDOW | WS_VISIBLE; _windowTitle = caption; AddCaption(caption); } ChildWindowMaker::ChildWindowMaker (int idClassName, HWnd hwndParent, int childId) : WindowMaker (idClassName, hwndParent.GetInstance ()) { _style = WS_CHILD; _hWndParent = hwndParent; _hMenu = (HMENU) childId; } ChildWindowMaker::ChildWindowMaker (char const * className, HWnd hwndParent, int childId) : WindowMaker (className, hwndParent.GetInstance ()) { _style = WS_CHILD; _hWndParent = hwndParent; _hMenu = (HMENU) childId; } PopupWindowMaker::PopupWindowMaker (int idClassName, HINSTANCE hInst) : WindowMaker (idClassName, hInst) { _style = WS_POPUP | WS_VISIBLE; } */ } // end namespace