// WindowMaker.h // // Create a Window // // // 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 // // // // Implementation Notes: // * object must exist for the life of the window it starts // because it contains the icon handles which must be // released when the windown no longer needs them. // //////////////////////////////////////////////////////////// #ifndef WINMAKER_H #define WINMAKER_H #include #include namespace rfc { class WindowMaker { public: WindowMaker(const char* className, HINSTANCE hInst); WindowMaker(UINT classStringtableId, HINSTANCE hInst); HINSTANCE GetInstance() { return _Instance; } operator HWND() { return _hwnd; } HWND GetHwnd() { return _hwnd; } //void AddCaption(char const * caption) { _windowTitle = caption; } void SetMenu(HMENU menu) { _hMenu = menu; } void AddSysMenu() { _style |= WS_SYSMENU; } void AddVScrollBar() { _style |= WS_VSCROLL; } void AddHScrollBar() { _style |= WS_HSCROLL; } void AddCaption() { _style |= WS_CAPTION; } void AddMaximizeBox() { _style |= WS_MAXIMIZEBOX; } void AddMinimizeBox() { _style |= WS_MINIMIZEBOX; } void AddThickFrame() { _style |= WS_THICKFRAME; } // typical window styles void SetStyleAsMDIFrame() { _style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; } void SetStyleAsTop() { _style = WS_OVERLAPPEDWINDOW; } void SetStyleAsChild(HWND parent, int childId) { _style = WS_CHILD; _hWndParent = parent; _hMenu = (HMENU) childId; } void SetStyleAsPopup() { _style = WS_POPUP | WS_VISIBLE; } void SetStyle(UINT s) { _style = s; } void SetExtendedStyle(UINT s) { _exStyle = s; } void SetXYWH(int x, int y, int w, int h) { _x = x; _y = y; _width = w; _height =h; } HWND Create(int captionId, void* controller=NULL); HWND Create(const char* caption, void* controller=NULL); void Display(int nCmdShow = SW_SHOWNORMAL) { Show(nCmdShow); } // use Show instead void Show(int nCmdShow = SW_SHOWNORMAL); protected: std::string _className; HWND _hwnd; HINSTANCE _Instance; DWORD _exStyle; // extended window style DWORD _style; // window 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 identifier // void* _data; // pointer to window-creation data }; /* class TopWindowMaker: public rfc::WindowMaker { public: TopWindowMaker(char const * caption, int idClassName, HINSTANCE hInst); }; class ChildWindowMaker: public rfc::WindowMaker { public: ChildWindowMaker(int idClassName, CWindowHandle hwndParent, int childId); ChildWindowMaker(char const * className, CWindowHandle hwndParent, int childId); }; class PopupWindowMaker: public rfc::WindowMaker { public: PopupWindowMaker(int idClassName, HINSTANCE hInst); }; */ } #endif