win.h

Go to the documentation of this file.
00001 
00007 /*
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Lesser General Public
00010     License as published by the Free Software Foundation; either
00011     version 2.1 of the License, or (at your option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public
00019     License along with this library; if not, write to the Free Software
00020     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00021 
00022     Copyright (C) 2005 Robin McNeill
00023 */
00024 
00025 #ifndef OMGUI_WIN32_WIN_H
00026 #define OMGUI_WIN32_WIN_H
00027 
00028 //#define DEBUG_DWP
00029 
00030 #include <omgui/win32/theme.h>
00031 #include <omgui/debug.h>
00032 
00033 namespace omgui {
00034     namespace win32 {
00035         
00036 class Widget;
00037 
00043 Widget *get_widget_from_hwnd(HWND h);
00044 template <typename T> T *get_widget_from_hwnd(HWND h)
00045 {
00046     return dynamic_cast<T*>(get_widget_from_hwnd(h));
00047 }
00048 
00054 void associate_hwnd(HWND h, Widget *wnd);
00055 
00059 void disassociate_hwnd(HWND h);
00060 
00067 bool has_widgets();
00068 
00073 LRESULT CALLBACK widget_wndproc(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param);
00074 
00078 void save_instance_handle(HINSTANCE handle);
00079 
00083 HINSTANCE get_instance_handle();
00084 
00092 class CreationHook
00093 {
00094 public:
00095 
00101     CreationHook(Widget *w);
00102 
00103     ~CreationHook();
00104 
00105     static LRESULT CALLBACK hook_proc(int code, WPARAM w_param, LPARAM l_param);
00106 };
00107 
00112 class ScopedDC
00113 {
00114 public:
00115     ScopedDC(HWND hwnd, HDC dc) : m_dc(dc), m_hwnd(hwnd) { }
00116 
00117     ~ScopedDC()
00118     {
00119         ::ReleaseDC(m_hwnd, m_dc);
00120     }
00121 
00122     operator HDC () const
00123     {
00124         return m_dc;
00125     }
00126 
00127 private:
00128     HDC m_dc;
00129     HWND m_hwnd;
00130 
00131     // Non copyable and non assignable
00132     ScopedDC &operator= (const ScopedDC &);
00133     ScopedDC(const ScopedDC &);
00134 };
00135 
00136     } // win32
00137 } // omgui
00138 
00139 #endif // OMGUI_WIN32_WIN_H

doxygen SourceForge.net Logo