#pragma once #include #include "WCString.h" // Returns number of elements #define dim(x) (sizeof(x) / sizeof(x[0])) namespace SRFramework { class SRWnd { public: SRWnd(); virtual ~SRWnd(void); BOOL IshWnd(HWND hWnd) { return hWnd == m_hWnd; } virtual WCString GetWindowTitle() { return ""; }; //! The actual call back function for this window. /*! This only acts as a mediator between the callback function we really want and the call back the Win API is expecting. @param hwnd Handle to the window. @param message Specifies the message. @param wParam Specifies additional message information. The contents of this parameter depend on the value of the message parameter. @param lParam Specifies additional message information. The contents of this parameter depend on the value of the message parameter. */ static LRESULT CALLBACK MessageRoute(HWND hwnd, UINT wMsg, WPARAM wParam, LPARAM lParam); //! The expected WinProc callback function. /*! Handles any messages sent to this window. @param hwnd Handle to the window. @param message Specifies the message. @param wParam Specifies additional message information. The contents of this parameter depend on the value of the message parameter. @param lParam Specifies additional message information. The contents of this parameter depend on the value of the message parameter. */ virtual LRESULT CALLBACK WndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam); virtual void Show(); virtual void Hide(); virtual BOOL IsVisible(); virtual void RefreshWindow(); virtual void MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE); virtual void MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE); virtual void SetFocus(); virtual LRESULT OnMove(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnMove(LOWORD(lParam), HIWORD(lParam)); } virtual BOOL OnMove(int x, int y) { return FALSE; } virtual LRESULT OnSize(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnSize(wParam, LOWORD(lParam), HIWORD(lParam)); } virtual BOOL OnSize(UINT nType, int cx, int cy) { return FALSE; } virtual LRESULT OnActivate(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnActivate(LOWORD(wParam), (HWND) lParam, (BOOL)HIWORD(wParam)); } virtual BOOL OnActivate(UINT nState, HWND hWndOther, BOOL bMinimized) { return FALSE; } virtual LRESULT OnSetFocus(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnSetFocus((HWND)wParam); } virtual BOOL OnSetFocus(HWND hOldWnd) { return FALSE; } virtual LRESULT OnKillFocus(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnKillFocus((HWND)wParam); } virtual BOOL OnKillFocus(HWND hNewWnd) { return FALSE; } virtual LRESULT OnPaint(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnPaint(); } virtual BOOL OnPaint() { return FALSE; } virtual LRESULT OnEraseBackground(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnEraseBackground((HDC) wParam); } virtual BOOL OnEraseBackground(HDC hdc) { return FALSE; } virtual LRESULT OnSetCursor(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnSetCursor((HWND) wParam, LOWORD(lParam), HIWORD(lParam)); } virtual BOOL OnSetCursor(HWND hWnd, UINT nHitTest, UINT message) { return FALSE; } virtual LRESULT OnNotify(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnNotify((int) wParam, (LPNMHDR) lParam); } virtual BOOL OnNotify(int idCtrl, LPNMHDR pnmh) {return FALSE; } virtual LRESULT OnHelp(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnHelp(); } virtual BOOL OnHelp() { return FALSE; } virtual LRESULT OnKeyDown(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnKeyDown((UINT)wParam, LOWORD(lParam), HIWORD(lParam)); } virtual BOOL OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { return FALSE; } virtual LRESULT OnKeyUp(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnKeyUp((UINT)wParam, LOWORD(lParam), HIWORD(lParam)); } virtual BOOL OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { return FALSE; } virtual LRESULT OnChar(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnChar((UINT)wParam, LOWORD(lParam), HIWORD(lParam)); } virtual BOOL OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { return FALSE; } virtual LRESULT OnDeadChar(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnDeadChar((UINT)wParam, LOWORD(lParam), HIWORD(lParam)); } virtual BOOL OnDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags) { return FALSE; } virtual LRESULT OnSysKeyDown(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnSysKeyDown((UINT)wParam, LOWORD(lParam), HIWORD(lParam)); } virtual BOOL OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { return FALSE; } virtual LRESULT OnSysKeyUp(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnKeyUp((UINT)wParam, LOWORD(lParam), HIWORD(lParam)); } virtual BOOL OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { return FALSE; } virtual LRESULT OnSysChar(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnSysChar((UINT)wParam, LOWORD(lParam), HIWORD(lParam)); } virtual BOOL OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags) { return FALSE; } virtual LRESULT OnSysDeadChar(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnSysDeadChar((UINT)wParam, LOWORD(lParam), HIWORD(lParam)); } virtual BOOL OnSysDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags) { return FALSE; } virtual LRESULT OnInitDialog(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnInitDialog((HWND)wParam, lParam); } virtual BOOL OnInitDialog(HWND wParam, LPARAM lParam) { return FALSE; } virtual LRESULT OnCommand(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnCommand(HIWORD(wParam) , LOWORD(wParam), (HWND) lParam); } virtual BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl) { return FALSE; } virtual LRESULT OnSysCommand(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnSysCommand((UINT)wParam, (INT) LOWORD(lParam), (INT) HIWORD(lParam)); } virtual BOOL OnSysCommand(UINT uCmdType, INT xPos, INT yPos) { return FALSE; } virtual LRESULT OnTimer(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnTimer((WORD)wParam, (TIMERPROC *)lParam); } virtual BOOL OnTimer(WORD wTimerID, TIMERPROC * lParam) { return FALSE; } virtual LRESULT OnHScroll(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnHScroll((INT) LOWORD(wParam), (INT) HIWORD(wParam), (HWND) lParam); } virtual BOOL OnHScroll(INT nScrollCode, INT nPos, HWND hwndScrollBar) { return FALSE; } virtual LRESULT OnVScroll(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnVScroll((INT) LOWORD(wParam), (INT) HIWORD(wParam), (HWND) lParam); } virtual BOOL OnVScroll(INT nScrollCode, INT nPos, HWND hwndScrollBar) { return FALSE; } virtual LRESULT OnInitMenuPopup(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnInitMenuPopup((HMENU) wParam, (UINT) LOWORD(lParam), (BOOL) HIWORD(lParam)); } virtual BOOL OnInitMenuPopup(HMENU hmenuPopup, UINT uPos, BOOL fSystemMenu) { return FALSE; } virtual LRESULT OnMenuChar(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnMenuChar((CHAR)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); } virtual BOOL OnMenuChar(CHAR chUser, UINT fuFlag, HMENU hmenu) { return FALSE; } virtual LRESULT OnMouseMove(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnMouseMove(wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); } virtual BOOL OnMouseMove(WORD fwKeys, INT xPos, INT yPos) { return FALSE; } virtual LRESULT OnLButtonDown(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnLButtonDown(wParam, (SHORT) LOWORD(lParam), (SHORT)HIWORD(lParam)); } virtual BOOL OnLButtonDown(WORD fwKeys, INT xPos, INT yPos) { return FALSE; } virtual LRESULT OnLButtonUp(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnLButtonUp(wParam, (SHORT) LOWORD(lParam), (SHORT)HIWORD(lParam)); } virtual BOOL OnLButtonUp(WORD fwKeys, INT xPos, INT yPos) { return FALSE; } virtual LRESULT OnLButtonDblClk(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnLButtonDblClk(wParam, (SHORT) LOWORD(lParam), (SHORT)HIWORD(lParam)); } virtual BOOL OnLButtonDblClk(WORD fwKeys, INT xPos, INT yPos) { return FALSE; } virtual LRESULT OnRButtonDown(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnRButtonDown(wParam, (SHORT) LOWORD(lParam), (SHORT)HIWORD(lParam)); } virtual BOOL OnRButtonDown(WORD fwKeys, INT xPos, INT yPos) { return FALSE; } virtual LRESULT OnRButtonUp(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnRButtonUp(wParam, (SHORT) LOWORD(lParam), (SHORT)HIWORD(lParam)); } virtual BOOL OnRButtonUp(WORD fwKeys, INT xPos, INT yPos) { return FALSE; } virtual LRESULT OnRButtonDblClk(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnRButtonDblClk(wParam, (SHORT) LOWORD(lParam), (SHORT)HIWORD(lParam)); } virtual BOOL OnRButtonDblClk(WORD fwKeys, INT xPos, INT yPos) { return FALSE; } virtual LRESULT OnMButtonDown(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnMButtonDown(wParam, (SHORT) LOWORD(lParam), (SHORT)HIWORD(lParam)); } virtual BOOL OnMButtonDown(WORD fwKeys, INT xPos, INT yPos) { return FALSE; } virtual LRESULT OnMButtonUp(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnMButtonUp(wParam, (SHORT) LOWORD(lParam), (SHORT)HIWORD(lParam)); } virtual BOOL OnMButtonUp(WORD fwKeys, INT xPos, INT yPos) { return FALSE; } virtual LRESULT OnMButtonDblClk(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnMButtonDblClk(wParam, (SHORT) LOWORD(lParam), (SHORT)HIWORD(lParam)); } virtual BOOL OnMButtonDblClk(WORD fwKeys, INT xPos, INT yPos) { return FALSE; } virtual LRESULT OnCut(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnCut(); } virtual BOOL OnCut() { return FALSE; } virtual LRESULT OnCopy(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnCopy(); } virtual BOOL OnCopy() { return FALSE; } virtual LRESULT OnPaste(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnPaste(); } virtual BOOL OnPaste() { return FALSE; } virtual LRESULT OnClear(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnClear(); } virtual BOOL OnClear() { return FALSE; } virtual LRESULT OnUndo(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnUndo(); } virtual BOOL OnUndo() { return FALSE; } virtual LRESULT OnHibernate(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnHibernate(); } virtual BOOL OnHibernate() { return FALSE; } virtual LRESULT OnCreate(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnCreate((LPCREATESTRUCT) lParam); } virtual BOOL OnCreate(LPCREATESTRUCT lpcs) { return FALSE; } virtual LRESULT OnDestroy(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnDestroy(); } virtual BOOL OnDestroy() { return FALSE; } virtual LRESULT OnClose(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnClose(); } virtual BOOL OnClose() { return FALSE; } virtual LRESULT OnQuit(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { return OnQuit((INT)wParam); } virtual BOOL OnQuit(INT nExitCode) { return FALSE; } virtual const SRWnd *GetParentWindow() const { return m_pParentWnd; } RECT GetBounds(); protected: virtual BOOL Register() = 0; HWND m_hWnd; // These typically are set by the subclass' constructor. WCString m_wcsClassName; WCString m_wcsWindowName; DWORD m_dwStyle; SRWnd* m_pParentWnd; HMENU m_hMenu; HINSTANCE m_hInstance; public: virtual BOOL Create(const WCString &wcsClassName, const WCString &wcsWindowName, DWORD dwStyle, RECT rect, SRWnd* pParentWnd, HMENU hMenu, HINSTANCE hInstance); virtual BOOL Create(SRWnd *pParentWnd, RECT rect) { return FALSE; }; HWND GetWindowHandle() const; }; // END OF SRWnd Class... }