1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/private.h
3 // Purpose: Private declarations: as this header is only included by
4 // wxWidgets itself, it may contain identifiers which don't start
6 // Author: Julian Smart
10 // Copyright: (c) Julian Smart
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_PRIVATE_H_
15 #define _WX_PRIVATE_H_
17 #include "wx/msw/wrapwin.h"
20 // Extra prototypes and symbols not defined by MicroWindows
21 #include "wx/msw/microwin.h"
27 #include "wx/window.h"
30 class WXDLLIMPEXP_FWD_CORE wxFont
;
31 class WXDLLIMPEXP_FWD_CORE wxWindow
;
32 class WXDLLIMPEXP_FWD_CORE wxWindowBase
;
34 // ---------------------------------------------------------------------------
36 // ---------------------------------------------------------------------------
38 // 260 was taken from windef.h
43 // ---------------------------------------------------------------------------
44 // standard icons from the resources
45 // ---------------------------------------------------------------------------
49 extern WXDLLIMPEXP_DATA_CORE(HICON
) wxSTD_FRAME_ICON
;
50 extern WXDLLIMPEXP_DATA_CORE(HICON
) wxSTD_MDIPARENTFRAME_ICON
;
51 extern WXDLLIMPEXP_DATA_CORE(HICON
) wxSTD_MDICHILDFRAME_ICON
;
52 extern WXDLLIMPEXP_DATA_CORE(HICON
) wxDEFAULT_FRAME_ICON
;
53 extern WXDLLIMPEXP_DATA_CORE(HICON
) wxDEFAULT_MDIPARENTFRAME_ICON
;
54 extern WXDLLIMPEXP_DATA_CORE(HICON
) wxDEFAULT_MDICHILDFRAME_ICON
;
55 extern WXDLLIMPEXP_DATA_CORE(HFONT
) wxSTATUS_LINE_FONT
;
59 // ---------------------------------------------------------------------------
61 // ---------------------------------------------------------------------------
63 extern WXDLLIMPEXP_DATA_BASE(HINSTANCE
) wxhInstance
;
65 // ---------------------------------------------------------------------------
66 // define things missing from some compilers' headers
67 // ---------------------------------------------------------------------------
69 #if defined(__WXWINCE__) || (defined(__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS)
71 inline void ZeroMemory(void *buf
, size_t len
) { memset(buf
, 0, len
); }
75 // this defines a CASTWNDPROC macro which casts a pointer to the type of a
77 #if defined(STRICT) || defined(__GNUC__)
78 typedef WNDPROC WndProcCast
;
80 typedef FARPROC WndProcCast
;
84 #define CASTWNDPROC (WndProcCast)
88 // ---------------------------------------------------------------------------
89 // some stuff for old Windows versions (FIXME: what does it do here??)
90 // ---------------------------------------------------------------------------
92 #if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
93 #define APIENTRY FAR PASCAL
99 #define _EXPORT _export
103 typedef signed short int SHORT
;
106 #if !defined(__WIN32__) // 3.x uses FARPROC for dialogs
108 #define DLGPROC FARPROC
113 * Decide what window classes we're going to use
114 * for this combination of CTl3D/FAFA settings
117 #define STATIC_CLASS wxT("STATIC")
118 #define STATIC_FLAGS (SS_LEFT|WS_CHILD|WS_VISIBLE)
119 #define CHECK_CLASS wxT("BUTTON")
120 #define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP|WS_CHILD)
121 #define CHECK_IS_FAFA FALSE
122 #define RADIO_CLASS wxT("BUTTON")
123 #define RADIO_FLAGS (BS_AUTORADIOBUTTON|WS_CHILD|WS_VISIBLE)
124 #define RADIO_SIZE 20
125 #define RADIO_IS_FAFA FALSE
127 #define GROUP_CLASS wxT("BUTTON")
128 #define GROUP_FLAGS (BS_GROUPBOX|WS_CHILD|WS_VISIBLE)
131 #define BITCHECK_FLAGS (FB_BITMAP|FC_BUTTONDRAW|FC_DEFAULT|WS_VISIBLE)
132 #define BITRADIO_FLAGS (FC_BUTTONDRAW|FB_BITMAP|FC_RADIO|WS_CHILD|WS_VISIBLE)
135 // ---------------------------------------------------------------------------
137 // ---------------------------------------------------------------------------
139 #define MEANING_CHARACTER '0'
140 #define DEFAULT_ITEM_WIDTH 100
141 #define DEFAULT_ITEM_HEIGHT 80
143 // Scale font to get edit control height
144 //#define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (3*(cy)/2)
145 #define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (cy+8)
147 // Generic subclass proc, for panel item moving/sizing and intercept
148 // EDIT control VK_RETURN messages
149 extern LONG APIENTRY _EXPORT
150 wxSubclassedGenericControlProc(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
152 // ---------------------------------------------------------------------------
153 // useful macros and functions
154 // ---------------------------------------------------------------------------
156 // a wrapper macro for ZeroMemory()
157 #if defined(__WIN32__) && !defined(__WXMICROWIN__)
158 #define wxZeroMemory(obj) ::ZeroMemory(&obj, sizeof(obj))
160 #define wxZeroMemory(obj) memset((void*) & obj, 0, sizeof(obj))
163 // This one is a macro so that it can be tested with #ifdef, it will be
164 // undefined if it cannot be implemented for a given compiler.
165 // Vc++, bcc, dmc, ow, mingw, codewarrior (and rsxnt) have _get_osfhandle.
166 // Cygwin has get_osfhandle. Others are currently unknown, e.g. Salford,
167 // Intel, Visual Age.
168 #if defined(__WXWINCE__)
169 #define wxGetOSFHandle(fd) ((HANDLE)fd)
170 #define wxOpenOSFHandle(h, flags) ((int)wxPtrToUInt(h))
171 #elif defined(__CYGWIN__)
172 #define wxGetOSFHandle(fd) ((HANDLE)get_osfhandle(fd))
173 #elif defined(__VISUALC__) \
174 || defined(__BORLANDC__) \
175 || defined(__DMC__) \
176 || defined(__WATCOMC__) \
177 || defined(__MINGW32__) \
178 || (defined(__MWERKS__) && defined(__MSL__))
179 #define wxGetOSFHandle(fd) ((HANDLE)_get_osfhandle(fd))
180 #define wxOpenOSFHandle(h, flags) (_open_osfhandle(wxPtrToUInt(h), flags))
181 #define wx_fdopen _fdopen
184 // close the handle in the class dtor
188 wxEXPLICIT
AutoHANDLE(HANDLE handle
) : m_handle(handle
) { }
190 bool IsOk() const { return m_handle
!= INVALID_HANDLE_VALUE
; }
191 operator HANDLE() const { return m_handle
; }
193 ~AutoHANDLE() { if ( IsOk() ) ::CloseHandle(m_handle
); }
199 // a template to make initializing Windows styructs less painful: it zeroes all
200 // the struct fields and also sets cbSize member to the correct value (and so
201 // can be only used with structures which have this member...)
203 struct WinStruct
: public T
207 ::ZeroMemory(this, sizeof(T
));
209 // explicit qualification is required here for this to be valid C++
210 this->cbSize
= sizeof(T
);
217 #include "wx/gdicmn.h"
218 #include "wx/colour.h"
220 // make conversion from wxColour and COLORREF a bit less painful
221 inline COLORREF
wxColourToRGB(const wxColour
& c
)
223 return RGB(c
.Red(), c
.Green(), c
.Blue());
226 inline COLORREF
wxColourToPalRGB(const wxColour
& c
)
228 return PALETTERGB(c
.Red(), c
.Green(), c
.Blue());
231 inline wxColour
wxRGBToColour(COLORREF rgb
)
233 return wxColour(GetRValue(rgb
), GetGValue(rgb
), GetBValue(rgb
));
236 inline void wxRGBToColour(wxColour
& c
, COLORREF rgb
)
238 c
.Set(GetRValue(rgb
), GetGValue(rgb
), GetBValue(rgb
));
241 // get the standard colour map for some standard colours - see comment in this
242 // function to understand why is it needed and when should it be used
244 // it returns a wxCOLORMAP (can't use COLORMAP itself here as comctl32.dll
245 // might be not included/available) array of size wxSTD_COLOUR_MAX
247 // NB: if you change these colours, update wxBITMAP_STD_COLOURS in the
248 // resources as well: it must have the same number of pixels!
254 wxSTD_COL_BTNHIGHLIGHT
,
258 struct WXDLLIMPEXP_CORE wxCOLORMAP
263 // this function is implemented in src/msw/window.cpp
264 extern wxCOLORMAP
*wxGetStdColourMap();
266 // create a wxRect from Windows RECT
267 inline wxRect
wxRectFromRECT(const RECT
& rc
)
269 return wxRect(rc
.left
, rc
.top
, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
272 // copy Windows RECT to our wxRect
273 inline void wxCopyRECTToRect(const RECT
& rc
, wxRect
& rect
)
275 rect
= wxRectFromRECT(rc
);
279 inline void wxCopyRectToRECT(const wxRect
& rect
, RECT
& rc
)
281 // note that we don't use wxRect::GetRight() as it is one of compared to
282 // wxRectFromRECT() above
285 rc
.right
= rect
.x
+ rect
.width
;
286 rc
.bottom
= rect
.y
+ rect
.height
;
289 // translations between HIMETRIC units (which OLE likes) and pixels (which are
290 // liked by all the others) - implemented in msw/utilsexc.cpp
291 extern void HIMETRICToPixel(LONG
*x
, LONG
*y
);
292 extern void PixelToHIMETRIC(LONG
*x
, LONG
*y
);
294 // Windows convention of the mask is opposed to the wxWidgets one, so we need
295 // to invert the mask each time we pass one/get one to/from Windows
296 extern HBITMAP
wxInvertMask(HBITMAP hbmpMask
, int w
= 0, int h
= 0);
298 // Creates an icon or cursor depending from a bitmap
300 // The bitmap must be valid and it should have a mask. If it doesn't, a default
301 // mask is created using light grey as the transparent colour.
302 extern HICON
wxBitmapToHICON(const wxBitmap
& bmp
);
304 // Same requirments as above apply and the bitmap must also have the correct
307 HCURSOR
wxBitmapToHCURSOR(const wxBitmap
& bmp
, int hotSpotX
, int hotSpotY
);
309 // get (x, y) from DWORD - notice that HI/LOWORD can *not* be used because they
310 // will fail on system with multiple monitors where the coords may be negative
312 // these macros are standard now (Win98) but some older headers don't have them
314 #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
315 #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
316 #endif // GET_X_LPARAM
318 // get the current state of SHIFT/CTRL/ALT keys
319 inline bool wxIsModifierDown(int vk
)
321 // GetKeyState() returns different negative values on WinME and WinNT,
322 // so simply test for negative value.
323 return ::GetKeyState(vk
) < 0;
326 inline bool wxIsShiftDown()
328 return wxIsModifierDown(VK_SHIFT
);
331 inline bool wxIsCtrlDown()
333 return wxIsModifierDown(VK_CONTROL
);
336 inline bool wxIsAltDown()
338 return wxIsModifierDown(VK_MENU
);
341 inline bool wxIsAnyModifierDown()
343 return wxIsShiftDown() || wxIsCtrlDown() || wxIsAltDown();
346 // wrapper around GetWindowRect() and GetClientRect() APIs doing error checking
348 inline RECT
wxGetWindowRect(HWND hwnd
)
352 if ( !::GetWindowRect(hwnd
, &rect
) )
353 wxLogLastError(_T("GetWindowRect"));
358 inline RECT
wxGetClientRect(HWND hwnd
)
362 if ( !::GetClientRect(hwnd
, &rect
) )
363 wxLogLastError(_T("GetClientRect"));
368 // ---------------------------------------------------------------------------
369 // small helper classes
370 // ---------------------------------------------------------------------------
372 // create an instance of this class and use it as the HDC for screen, will
373 // automatically release the DC going out of scope
377 ScreenHDC() { m_hdc
= ::GetDC(NULL
); }
378 ~ScreenHDC() { ::ReleaseDC(NULL
, m_hdc
); }
380 operator HDC() const { return m_hdc
; }
385 DECLARE_NO_COPY_CLASS(ScreenHDC
)
388 // the same as ScreenHDC but for window DCs
392 WindowHDC(HWND hwnd
) { m_hdc
= ::GetDC(m_hwnd
= hwnd
); }
393 ~WindowHDC() { ::ReleaseDC(m_hwnd
, m_hdc
); }
395 operator HDC() const { return m_hdc
; }
401 DECLARE_NO_COPY_CLASS(WindowHDC
)
404 // the same as ScreenHDC but for memory DCs: creates the HDC compatible with
405 // the given one (screen by default) in ctor and destroys it in dtor
409 MemoryHDC(HDC hdc
= 0) { m_hdc
= ::CreateCompatibleDC(hdc
); }
410 ~MemoryHDC() { ::DeleteDC(m_hdc
); }
412 operator HDC() const { return m_hdc
; }
417 DECLARE_NO_COPY_CLASS(MemoryHDC
)
420 // a class which selects a GDI object into a DC in its ctor and deselects in
425 void DoInit(HGDIOBJ hgdiobj
) { m_hgdiobj
= ::SelectObject(m_hdc
, hgdiobj
); }
428 SelectInHDC() : m_hdc(NULL
) { }
429 SelectInHDC(HDC hdc
, HGDIOBJ hgdiobj
) : m_hdc(hdc
) { DoInit(hgdiobj
); }
431 void Init(HDC hdc
, HGDIOBJ hgdiobj
)
433 wxASSERT_MSG( !m_hdc
, _T("initializing twice?") );
440 ~SelectInHDC() { if ( m_hdc
) ::SelectObject(m_hdc
, m_hgdiobj
); }
442 // return true if the object was successfully selected
443 operator bool() const { return m_hgdiobj
!= 0; }
449 DECLARE_NO_COPY_CLASS(SelectInHDC
)
452 // a class which cleans up any GDI object
456 AutoGDIObject() { m_gdiobj
= NULL
; }
457 AutoGDIObject(HGDIOBJ gdiobj
) : m_gdiobj(gdiobj
) { }
458 ~AutoGDIObject() { if ( m_gdiobj
) ::DeleteObject(m_gdiobj
); }
460 void InitGdiobj(HGDIOBJ gdiobj
)
462 wxASSERT_MSG( !m_gdiobj
, _T("initializing twice?") );
467 HGDIOBJ
GetObject() const { return m_gdiobj
; }
473 // TODO: all this asks for using a AutoHandler<T, CreateFunc> template...
475 // a class for temporary brushes
476 class AutoHBRUSH
: private AutoGDIObject
479 AutoHBRUSH(COLORREF col
)
480 : AutoGDIObject(::CreateSolidBrush(col
)) { }
482 operator HBRUSH() const { return (HBRUSH
)GetObject(); }
485 // a class for temporary fonts
486 class AutoHFONT
: private AutoGDIObject
491 : AutoGDIObject() { }
493 AutoHFONT(const LOGFONT
& lf
)
494 : AutoGDIObject(::CreateFontIndirect(&lf
)) { }
496 void Init(const LOGFONT
& lf
) { InitGdiobj(::CreateFontIndirect(&lf
)); }
498 operator HFONT() const { return (HFONT
)GetObject(); }
501 // a class for temporary pens
502 class AutoHPEN
: private AutoGDIObject
505 AutoHPEN(COLORREF col
)
506 : AutoGDIObject(::CreatePen(PS_SOLID
, 0, col
)) { }
508 operator HPEN() const { return (HPEN
)GetObject(); }
511 // classes for temporary bitmaps
512 class AutoHBITMAP
: private AutoGDIObject
515 AutoHBITMAP(HBITMAP hbmp
) : AutoGDIObject(hbmp
) { }
517 operator HBITMAP() const { return (HBITMAP
)GetObject(); }
520 class CompatibleBitmap
: public AutoHBITMAP
523 CompatibleBitmap(HDC hdc
, int w
, int h
)
524 : AutoHBITMAP(::CreateCompatibleBitmap(hdc
, w
, h
))
529 class MonoBitmap
: public AutoHBITMAP
532 MonoBitmap(int w
, int h
)
533 : AutoHBITMAP(::CreateBitmap(w
, h
, 1, 1, 0))
538 // class automatically destroys the region object
539 class AutoHRGN
: private AutoGDIObject
542 AutoHRGN(HRGN hrgn
) : AutoGDIObject(hrgn
) { }
544 operator HRGN() const { return (HRGN
)GetObject(); }
547 // class sets the specified clipping region during its life time
551 HDCClipper(HDC hdc
, HRGN hrgn
)
554 if ( !::SelectClipRgn(hdc
, hrgn
) )
555 wxLogLastError(_T("SelectClipRgn"));
560 ::SelectClipRgn(m_hdc
, NULL
);
566 DECLARE_NO_COPY_CLASS(HDCClipper
)
569 // set the given map mode for the life time of this object
571 // NB: SetMapMode() is not supported by CE so we also define a helper macro
572 // to avoid using it there
574 #define wxCHANGE_HDC_MAP_MODE(hdc, mm)
575 #else // !__WXWINCE__
576 class HDCMapModeChanger
579 HDCMapModeChanger(HDC hdc
, int mm
)
582 m_modeOld
= ::SetMapMode(hdc
, mm
);
584 wxLogLastError(_T("SelectClipRgn"));
590 ::SetMapMode(m_hdc
, m_modeOld
);
597 DECLARE_NO_COPY_CLASS(HDCMapModeChanger
)
600 #define wxCHANGE_HDC_MAP_MODE(hdc, mm) \
601 HDCMapModeChanger wxMAKE_UNIQUE_NAME(wxHDCMapModeChanger)(hdc, mm)
602 #endif // __WXWINCE__/!__WXWINCE__
604 // smart pointer using GlobalAlloc/GlobalFree()
608 // allocates a block of given size
609 GlobalPtr(size_t size
, unsigned flags
= GMEM_MOVEABLE
)
611 m_hGlobal
= ::GlobalAlloc(flags
, size
);
613 wxLogLastError(_T("GlobalAlloc"));
618 if ( m_hGlobal
&& ::GlobalFree(m_hGlobal
) )
619 wxLogLastError(_T("GlobalFree"));
622 // implicit conversion
623 operator HGLOBAL() const { return m_hGlobal
; }
628 DECLARE_NO_COPY_CLASS(GlobalPtr
)
631 // when working with global pointers (which is unfortunately still necessary
632 // sometimes, e.g. for clipboard) it is important to unlock them exactly as
633 // many times as we lock them which just asks for using a "smart lock" class
637 // default ctor, use Init() later -- should only be used if the HGLOBAL can
638 // be NULL (in which case Init() shouldn't be called)
645 // initialize the object, may be only called if we were created using the
646 // default ctor; HGLOBAL must not be NULL
647 void Init(HGLOBAL hGlobal
)
651 // NB: GlobalLock() is a macro, not a function, hence don't use the
652 // global scope operator with it (and neither with GlobalUnlock())
653 m_ptr
= GlobalLock(hGlobal
);
655 wxLogLastError(_T("GlobalLock"));
658 // initialize the object, HGLOBAL must not be NULL
659 GlobalPtrLock(HGLOBAL hGlobal
)
666 if ( m_hGlobal
&& !GlobalUnlock(m_hGlobal
) )
669 // this might happen simply because the block became unlocked
670 DWORD dwLastError
= ::GetLastError();
671 if ( dwLastError
!= NO_ERROR
)
673 wxLogApiError(_T("GlobalUnlock"), dwLastError
);
675 #endif // __WXDEBUG__
679 void *Get() const { return m_ptr
; }
680 operator void *() const { return m_ptr
; }
686 DECLARE_NO_COPY_CLASS(GlobalPtrLock
)
689 // register the class when it is first needed and unregister it in dtor
693 // ctor doesn't register the class, call Initialize() for this
694 ClassRegistrar() { m_registered
= -1; }
696 // return true if the class is already registered
697 bool IsInitialized() const { return m_registered
!= -1; }
699 // return true if the class had been already registered
700 bool IsRegistered() const { return m_registered
== 1; }
702 // try to register the class if not done yet, return true on success
703 bool Register(const WNDCLASS
& wc
)
705 // we should only be called if we hadn't been initialized yet
706 wxASSERT_MSG( m_registered
== -1,
707 _T("calling ClassRegistrar::Register() twice?") );
709 m_registered
= ::RegisterClass(&wc
) ? 1 : 0;
710 if ( !IsRegistered() )
712 wxLogLastError(_T("RegisterClassEx()"));
716 m_clsname
= wc
.lpszClassName
;
719 return m_registered
== 1;
722 // get the name of the registered class (returns empty string if not
724 const wxString
& GetName() const { return m_clsname
; }
726 // unregister the class if it had been registered
729 if ( IsRegistered() )
731 if ( !::UnregisterClass(m_clsname
.wx_str(), wxhInstance
) )
733 wxLogLastError(_T("UnregisterClass"));
739 // initial value is -1 which means that we hadn't tried registering the
740 // class yet, it becomes true or false (1 or 0) when Initialize() is called
743 // the name of the class, only non empty if it had been registered
747 // ---------------------------------------------------------------------------
748 // macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
749 // returns Foo cast to the Windows type for oruselves, while GetFooOf() takes
750 // an argument which should be a pointer or reference to the object of the
751 // corresponding class (this depends on the macro)
752 // ---------------------------------------------------------------------------
754 #define GetHwnd() ((HWND)GetHWND())
755 #define GetHwndOf(win) ((HWND)((win)->GetHWND()))
757 #define GetWinHwnd GetHwndOf
759 #define GetHdc() ((HDC)GetHDC())
760 #define GetHdcOf(dc) ((HDC)(dc).GetHDC())
762 #define GetHbitmap() ((HBITMAP)GetHBITMAP())
763 #define GetHbitmapOf(bmp) ((HBITMAP)(bmp).GetHBITMAP())
765 #define GetHicon() ((HICON)GetHICON())
766 #define GetHiconOf(icon) ((HICON)(icon).GetHICON())
768 #define GetHaccel() ((HACCEL)GetHACCEL())
769 #define GetHaccelOf(table) ((HACCEL)((table).GetHACCEL()))
771 #define GetHbrush() ((HBRUSH)GetResourceHandle())
772 #define GetHbrushOf(brush) ((HBRUSH)(brush).GetResourceHandle())
774 #define GetHmenu() ((HMENU)GetHMenu())
775 #define GetHmenuOf(menu) ((HMENU)menu->GetHMenu())
777 #define GetHcursor() ((HCURSOR)GetHCURSOR())
778 #define GetHcursorOf(cursor) ((HCURSOR)(cursor).GetHCURSOR())
780 #define GetHfont() ((HFONT)GetHFONT())
781 #define GetHfontOf(font) ((HFONT)(font).GetHFONT())
783 #define GetHimagelist() ((HIMAGELIST)GetHIMAGELIST())
784 #define GetHimagelistOf(imgl) ((HIMAGELIST)imgl->GetHIMAGELIST())
786 #define GetHpalette() ((HPALETTE)GetHPALETTE())
787 #define GetHpaletteOf(pal) ((HPALETTE)(pal).GetHPALETTE())
789 #define GetHpen() ((HPEN)GetResourceHandle())
790 #define GetHpenOf(pen) ((HPEN)(pen).GetResourceHandle())
792 #define GetHrgn() ((HRGN)GetHRGN())
793 #define GetHrgnOf(rgn) ((HRGN)(rgn).GetHRGN())
797 // ---------------------------------------------------------------------------
799 // ---------------------------------------------------------------------------
803 WXDLLIMPEXP_BASE HINSTANCE
wxGetInstance();
806 WXDLLIMPEXP_BASE
void wxSetInstance(HINSTANCE hInst
);
808 // return the full path of the given module
809 inline wxString
wxGetFullModuleName(HMODULE hmod
)
812 if ( !::GetModuleFileName
815 wxStringBuffer(fullname
, MAX_PATH
),
819 wxLogLastError(_T("GetModuleFileName"));
825 // return the full path of the program file
826 inline wxString
wxGetFullModuleName()
828 return wxGetFullModuleName((HMODULE
)wxGetInstance());
831 // return the run-time version of the OS in a format similar to
832 // WINVER/_WIN32_WINNT compile-time macros:
834 // 0x0300 Windows NT 3.51
835 // 0x0400 Windows 95, NT4
837 // 0x0500 Windows ME, 2000
839 // 0x0502 Windows 2003
842 // for the other Windows versions 0 is currently returned
845 wxWinVersion_Unknown
= 0,
847 wxWinVersion_3
= 0x0300,
848 wxWinVersion_NT3
= wxWinVersion_3
,
850 wxWinVersion_4
= 0x0400,
851 wxWinVersion_95
= wxWinVersion_4
,
852 wxWinVersion_NT4
= wxWinVersion_4
,
853 wxWinVersion_98
= 0x0410,
855 wxWinVersion_5
= 0x0500,
856 wxWinVersion_ME
= wxWinVersion_5
,
857 wxWinVersion_NT5
= wxWinVersion_5
,
858 wxWinVersion_2000
= wxWinVersion_5
,
859 wxWinVersion_XP
= 0x0501,
860 wxWinVersion_2003
= 0x0502,
862 wxWinVersion_6
= 0x0600,
863 wxWinVersion_Vista
= wxWinVersion_6
,
864 wxWinVersion_NT6
= wxWinVersion_6
867 WXDLLIMPEXP_BASE wxWinVersion
wxGetWinVersion();
872 extern HCURSOR
wxGetCurrentBusyCursor(); // from msw/utils.cpp
873 extern const wxCursor
*wxGetGlobalCursor(); // from msw/cursor.cpp
875 WXDLLIMPEXP_CORE
void wxGetCharSize(WXHWND wnd
, int *x
, int *y
, const wxFont
& the_font
);
876 WXDLLIMPEXP_CORE
void wxFillLogFont(LOGFONT
*logFont
, const wxFont
*font
);
877 WXDLLIMPEXP_CORE wxFont
wxCreateFontFromLogFont(const LOGFONT
*logFont
);
878 WXDLLIMPEXP_CORE wxFontEncoding
wxGetFontEncFromCharSet(int charset
);
880 WXDLLIMPEXP_CORE
void wxSliderEvent(WXHWND control
, WXWORD wParam
, WXWORD pos
);
881 WXDLLIMPEXP_CORE
void wxScrollBarEvent(WXHWND hbar
, WXWORD wParam
, WXWORD pos
);
883 // Find maximum size of window/rectangle
884 extern WXDLLIMPEXP_CORE
void wxFindMaxSize(WXHWND hwnd
, RECT
*rect
);
886 // Safely get the window text (i.e. without using fixed size buffer)
887 extern WXDLLIMPEXP_CORE wxString
wxGetWindowText(WXHWND hWnd
);
889 // get the window class name
890 extern WXDLLIMPEXP_CORE wxString
wxGetWindowClass(WXHWND hWnd
);
892 // get the window id (should be unsigned, hence this is not wxWindowID which
893 // is, for mainly historical reasons, signed)
894 extern WXDLLIMPEXP_CORE
int wxGetWindowId(WXHWND hWnd
);
896 // check if hWnd's WNDPROC is wndProc. Return true if yes, false if they are
898 extern WXDLLIMPEXP_CORE
bool wxCheckWindowWndProc(WXHWND hWnd
, WXFARPROC wndProc
);
900 // Does this window style specify any border?
901 inline bool wxStyleHasBorder(long style
)
903 return (style
& (wxSIMPLE_BORDER
| wxRAISED_BORDER
|
904 wxSUNKEN_BORDER
| wxDOUBLE_BORDER
)) != 0;
907 inline long wxGetWindowExStyle(const wxWindowMSW
*win
)
909 return ::GetWindowLong(GetHwndOf(win
), GWL_EXSTYLE
);
912 inline bool wxHasWindowExStyle(const wxWindowMSW
*win
, long style
)
914 return (wxGetWindowExStyle(win
) & style
) != 0;
917 inline long wxSetWindowExStyle(const wxWindowMSW
*win
, long style
)
919 return ::SetWindowLong(GetHwndOf(win
), GWL_EXSTYLE
, style
);
922 // ----------------------------------------------------------------------------
923 // functions mapping HWND to wxWindow
924 // ----------------------------------------------------------------------------
926 // this function simply checks whether the given hwnd corresponds to a wxWindow
927 // and returns either that window if it does or NULL otherwise
928 extern WXDLLIMPEXP_CORE wxWindow
* wxFindWinFromHandle(HWND hwnd
);
930 // without STRICT WXHWND is the same as HWND anyhow
931 inline wxWindow
* wxFindWinFromHandle(WXHWND hWnd
)
933 return wxFindWinFromHandle(static_cast<HWND
>(hWnd
));
936 // find the window for HWND which is part of some wxWindow, i.e. unlike
937 // wxFindWinFromHandle() above it will also work for "sub controls" of a
940 // returns the wxWindow corresponding to the given HWND or NULL.
941 extern WXDLLIMPEXP_CORE wxWindow
*wxGetWindowFromHWND(WXHWND hwnd
);
943 // Get the size of an icon
944 extern WXDLLIMPEXP_CORE wxSize
wxGetHiconSize(HICON hicon
);
946 // Lines are drawn differently for WinCE and regular WIN32
947 WXDLLIMPEXP_CORE
void wxDrawLine(HDC hdc
, int x1
, int y1
, int x2
, int y2
);
949 // fill the client rect of the given window on the provided dc using this brush
950 inline void wxFillRect(HWND hwnd
, HDC hdc
, HBRUSH hbr
)
953 ::GetClientRect(hwnd
, &rc
);
954 ::FillRect(hdc
, &rc
, hbr
);
957 // ----------------------------------------------------------------------------
959 // ----------------------------------------------------------------------------
963 inline void *wxGetWindowProc(HWND hwnd
)
965 return (void *)::GetWindowLongPtr(hwnd
, GWLP_WNDPROC
);
968 inline void *wxGetWindowUserData(HWND hwnd
)
970 return (void *)::GetWindowLongPtr(hwnd
, GWLP_USERDATA
);
973 inline WNDPROC
wxSetWindowProc(HWND hwnd
, WNDPROC func
)
975 return (WNDPROC
)::SetWindowLongPtr(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)func
);
978 inline void *wxSetWindowUserData(HWND hwnd
, void *data
)
980 return (void *)::SetWindowLongPtr(hwnd
, GWLP_USERDATA
, (LONG_PTR
)data
);
985 // note that the casts to LONG_PTR here are required even on 32-bit machines
986 // for the 64-bit warning mode of later versions of MSVC (C4311/4312)
987 inline WNDPROC
wxGetWindowProc(HWND hwnd
)
989 return (WNDPROC
)(LONG_PTR
)::GetWindowLong(hwnd
, GWL_WNDPROC
);
992 inline void *wxGetWindowUserData(HWND hwnd
)
994 return (void *)(LONG_PTR
)::GetWindowLong(hwnd
, GWL_USERDATA
);
997 inline WNDPROC
wxSetWindowProc(HWND hwnd
, WNDPROC func
)
999 return (WNDPROC
)(LONG_PTR
)::SetWindowLong(hwnd
, GWL_WNDPROC
, (LONG_PTR
)func
);
1002 inline void *wxSetWindowUserData(HWND hwnd
, void *data
)
1004 return (void *)(LONG_PTR
)::SetWindowLong(hwnd
, GWL_USERDATA
, (LONG_PTR
)data
);
1007 #endif // __WIN64__/__WIN32__
1011 #endif // _WX_PRIVATE_H_