OSDN Git Service

control.hpp: message_callback_base に WM_CLOSE, WM_MOVE 追加
authorMyun2 <myun2@nwhite.info>
Sun, 31 Oct 2010 14:24:41 +0000 (23:24 +0900)
committerMyun2 <myun2@nwhite.info>
Sun, 31 Oct 2010 14:24:41 +0000 (23:24 +0900)
roast_ex/include/roast/windows/control.hpp

index 4e8422c..842e1d2 100644 (file)
@@ -177,7 +177,7 @@ namespace roast
                        bool hide_window(){ return show_window(false); }
                        bool set_text(lpctstr_t text){ return ( ::SetWindowText(m_hWnd, text) == TRUE ); }
                };
-               
+
                //
                const char* control::standard_class::button = "BUTTON";
                const char* control::standard_class::edit_box = "EDIT";
@@ -193,9 +193,10 @@ namespace roast
                class message_callback_base
                {
                protected:
-                       //      If returns false, the window is destroyed and the control::start() returns false.
-                       virtual bool OnCreate(::LPCREATESTRUCT lpCreateStruct){ return true; }
+                       virtual bool OnClose(){ return true; }
+                       virtual bool OnCreate(::LPCREATESTRUCT lpCreateStruct){ return true; } // If returns false, the window is destroyed and the control::start() returns false.
                        virtual void OnDestroy(){ ::PostQuitMessage( 0 ); }
+                       virtual void OnMove(unsigned short x, unsigned short y){}
 
                private:
                        HWND m_hWnd;
@@ -206,12 +207,21 @@ namespace roast
 
                                switch( msg )
                                {
+                               case WM_CLOSE:  
+                                       if ( OnClose() )
+                                               ::DestroyWindow(m_hWnd);
+                                       return 0;
+
                                case WM_CREATE: 
                                        return ( OnCreate((::LPCREATESTRUCT)lParam) ? 0 : -1 );
 
                                case WM_DESTROY:
                                        OnDestroy();
                                        return 0;
+
+                               case WM_MOVE:
+                                       OnMove(LOWORD(lParam), HIWORD(lParam));
+                                       return 0;
                                }
 
                                return ::DefWindowProc( hWnd, msg, wParam, lParam );