]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/private.h
added eraseBg argument to RefreshRect() too
[wxWidgets.git] / include / wx / msw / private.h
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: private.h
a23fd0e1 3// Purpose: Private declarations: as this header is only included by
77ffb593 4// wxWidgets itself, it may contain identifiers which don't start
a23fd0e1 5// with "wx".
2bda0e17
KB
6// Author: Julian Smart
7// Modified by:
8// Created: 01/02/97
9// RCS-ID: $Id$
bbcdf8bc 10// Copyright: (c) Julian Smart
65571936 11// Licence: wxWindows licence
2bda0e17
KB
12/////////////////////////////////////////////////////////////////////////////
13
bbcdf8bc
JS
14#ifndef _WX_PRIVATE_H_
15#define _WX_PRIVATE_H_
2bda0e17 16
9ed0d735 17#include "wx/msw/wrapwin.h"
2bda0e17 18
04ef50df 19#ifdef __WXMICROWIN__
b225f659
VZ
20 // Extra prototypes and symbols not defined by MicroWindows
21 #include "wx/msw/microwin.h"
04ef50df
JS
22#endif
23
3d5231db
VS
24// Include fixes for MSLU:
25#include "wx/msw/mslu.h"
26
3a922bb4
RL
27#include "wx/log.h"
28
a23fd0e1 29class WXDLLEXPORT wxFont;
d427503c 30class WXDLLEXPORT wxWindow;
2bda0e17 31
42e69d6b
VZ
32// ---------------------------------------------------------------------------
33// private constants
34// ---------------------------------------------------------------------------
35
77d8d6cd
VZ
36// 260 was taken from windef.h
37#ifndef MAX_PATH
38 #define MAX_PATH 260
39#endif
40
a23fd0e1
VZ
41// ---------------------------------------------------------------------------
42// standard icons from the resources
43// ---------------------------------------------------------------------------
2bda0e17 44
b568d04f
VZ
45#if wxUSE_GUI
46
ef359b43
WS
47extern WXDLLEXPORT_DATA(HICON) wxSTD_FRAME_ICON;
48extern WXDLLEXPORT_DATA(HICON) wxSTD_MDIPARENTFRAME_ICON;
49extern WXDLLEXPORT_DATA(HICON) wxSTD_MDICHILDFRAME_ICON;
50extern WXDLLEXPORT_DATA(HICON) wxDEFAULT_FRAME_ICON;
51extern WXDLLEXPORT_DATA(HICON) wxDEFAULT_MDIPARENTFRAME_ICON;
52extern WXDLLEXPORT_DATA(HICON) wxDEFAULT_MDICHILDFRAME_ICON;
53extern WXDLLEXPORT_DATA(HFONT) wxSTATUS_LINE_FONT;
2bda0e17 54
b568d04f
VZ
55#endif // wxUSE_GUI
56
a23fd0e1 57// ---------------------------------------------------------------------------
11c7d5b6 58// define things missing from some compilers' headers
a23fd0e1 59// ---------------------------------------------------------------------------
c455ab93 60
7f0586ef 61#if defined(__WXWINCE__) || (defined(__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS)
01dba85a 62#ifndef ZeroMemory
11c7d5b6 63 inline void ZeroMemory(void *buf, size_t len) { memset(buf, 0, len); }
01dba85a 64#endif
11c7d5b6
VZ
65#endif // old mingw32
66
67// this defines a CASTWNDPROC macro which casts a pointer to the type of a
68// window proc
7f0586ef 69#if defined(STRICT) || defined(__GNUC__)
ebb0781f 70 typedef WNDPROC WndProcCast;
c3b177ae 71#else
ebb0781f
VZ
72 typedef FARPROC WndProcCast;
73#endif
74
552a0ebd 75
ebb0781f 76#define CASTWNDPROC (WndProcCast)
2bda0e17 77
dd54f5d3 78
50165591 79
a23fd0e1
VZ
80// ---------------------------------------------------------------------------
81// some stuff for old Windows versions (FIXME: what does it do here??)
82// ---------------------------------------------------------------------------
83
c085e333 84#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
a23fd0e1 85 #define APIENTRY FAR PASCAL
2bda0e17 86#endif
c085e333 87
2bda0e17 88#ifdef __WIN32__
a23fd0e1 89 #define _EXPORT
2bda0e17 90#else
a23fd0e1
VZ
91 #define _EXPORT _export
92#endif
93
94#ifndef __WIN32__
95 typedef signed short int SHORT;
2bda0e17 96#endif
c085e333
VZ
97
98#if !defined(__WIN32__) // 3.x uses FARPROC for dialogs
27a9bd48 99#ifndef STRICT
a23fd0e1 100 #define DLGPROC FARPROC
2bda0e17 101#endif
27a9bd48 102#endif
2bda0e17 103
47d67540 104#if wxUSE_PENWIN
cc2b7472
VZ
105 WXDLLEXPORT void wxRegisterPenWin();
106 WXDLLEXPORT void wxCleanUpPenWin();
107 WXDLLEXPORT void wxEnablePenAppHooks (bool hook);
108#endif // wxUSE_PENWIN
2bda0e17 109
47d67540 110#if wxUSE_ITSY_BITSY
a23fd0e1
VZ
111 #define IBS_HORZCAPTION 0x4000L
112 #define IBS_VERTCAPTION 0x8000L
2bda0e17 113
a23fd0e1
VZ
114 UINT WINAPI ibGetCaptionSize( HWND hWnd ) ;
115 UINT WINAPI ibSetCaptionSize( HWND hWnd, UINT nSize ) ;
116 LRESULT WINAPI ibDefWindowProc( HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam ) ;
117 VOID WINAPI ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ;
118#endif // wxUSE_ITSY_BITSY
2bda0e17 119
2bda0e17
KB
120/*
121 * Decide what window classes we're going to use
122 * for this combination of CTl3D/FAFA settings
123 */
c085e333 124
223d09f6 125#define STATIC_CLASS wxT("STATIC")
2bda0e17 126#define STATIC_FLAGS (SS_LEFT|WS_CHILD|WS_VISIBLE)
223d09f6 127#define CHECK_CLASS wxT("BUTTON")
2bda0e17 128#define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP|WS_CHILD)
078cf5cb 129#define CHECK_IS_FAFA FALSE
223d09f6 130#define RADIO_CLASS wxT("BUTTON")
2bda0e17
KB
131#define RADIO_FLAGS (BS_AUTORADIOBUTTON|WS_CHILD|WS_VISIBLE)
132#define RADIO_SIZE 20
078cf5cb 133#define RADIO_IS_FAFA FALSE
2bda0e17 134#define PURE_WINDOWS
223d09f6 135#define GROUP_CLASS wxT("BUTTON")
2bda0e17
KB
136#define GROUP_FLAGS (BS_GROUPBOX|WS_CHILD|WS_VISIBLE)
137
138/*
139#define BITCHECK_FLAGS (FB_BITMAP|FC_BUTTONDRAW|FC_DEFAULT|WS_VISIBLE)
140#define BITRADIO_FLAGS (FC_BUTTONDRAW|FB_BITMAP|FC_RADIO|WS_CHILD|WS_VISIBLE)
141*/
142
a23fd0e1
VZ
143// ---------------------------------------------------------------------------
144// misc macros
145// ---------------------------------------------------------------------------
146
2bda0e17 147#define MEANING_CHARACTER '0'
5d368213 148#define DEFAULT_ITEM_WIDTH 100
2bda0e17 149#define DEFAULT_ITEM_HEIGHT 80
1c4a764c
VZ
150
151// Scale font to get edit control height
f6bcfd97
BP
152//#define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (3*(cy)/2)
153#define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (cy+8)
2bda0e17
KB
154
155// Generic subclass proc, for panel item moving/sizing and intercept
156// EDIT control VK_RETURN messages
157extern LONG APIENTRY _EXPORT
158 wxSubclassedGenericControlProc(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
159
11c7d5b6
VZ
160// ---------------------------------------------------------------------------
161// useful macros and functions
162// ---------------------------------------------------------------------------
163
164// a wrapper macro for ZeroMemory()
04ef50df 165#if defined(__WIN32__) && !defined(__WXMICROWIN__)
11c7d5b6 166#define wxZeroMemory(obj) ::ZeroMemory(&obj, sizeof(obj))
0e528b99
JS
167#else
168#define wxZeroMemory(obj) memset((void*) & obj, 0, sizeof(obj))
169#endif
11c7d5b6 170
f6bcfd97
BP
171#if wxUSE_GUI
172
01dba85a 173#include <wx/gdicmn.h>
ed39ff57 174#include <wx/colour.h>
01dba85a 175
11c7d5b6
VZ
176// make conversion from wxColour and COLORREF a bit less painful
177inline COLORREF wxColourToRGB(const wxColour& c)
4ab861e5
VZ
178{
179 return RGB(c.Red(), c.Green(), c.Blue());
180}
181
182inline COLORREF wxColourToPalRGB(const wxColour& c)
11c7d5b6 183{
19193a2c 184 return PALETTERGB(c.Red(), c.Green(), c.Blue());
11c7d5b6
VZ
185}
186
d23c8ba2
VZ
187inline wxColour wxRGBToColour(COLORREF rgb)
188{
189 return wxColour(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
190}
191
11c7d5b6
VZ
192inline void wxRGBToColour(wxColour& c, COLORREF rgb)
193{
194 c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
195}
196
90c1530a
VZ
197// get the standard colour map for some standard colours - see comment in this
198// function to understand why is it needed and when should it be used
199//
200// it returns a wxCOLORMAP (can't use COLORMAP itself here as comctl32.dll
201// might be not included/available) array of size wxSTD_COLOUR_MAX
202//
203// NB: if you change these colours, update wxBITMAP_STD_COLOURS in the
204// resources as well: it must have the same number of pixels!
205enum wxSTD_COLOUR
206{
207 wxSTD_COL_BTNTEXT,
208 wxSTD_COL_BTNSHADOW,
209 wxSTD_COL_BTNFACE,
210 wxSTD_COL_BTNHIGHLIGHT,
57e075e9 211 wxSTD_COL_MAX
90c1530a
VZ
212};
213
214struct WXDLLEXPORT wxCOLORMAP
215{
216 COLORREF from, to;
217};
218
219// this function is implemented in src/msw/window.cpp
220extern wxCOLORMAP *wxGetStdColourMap();
221
9688700c
VZ
222// create a wxRect from Windows RECT
223inline wxRect wxRectFromRECT(const RECT& r)
224{
225 return wxRect(r.left, r.top, r.right - r.left, r.bottom - r.top);
226}
227
ed791986
VZ
228// copy Windows RECT to our wxRect
229inline void wxCopyRECTToRect(const RECT& r, wxRect& rect)
230{
9688700c 231 rect = wxRectFromRECT(r);
ed791986
VZ
232}
233
d9317fd4
VZ
234// translations between HIMETRIC units (which OLE likes) and pixels (which are
235// liked by all the others) - implemented in msw/utilsexc.cpp
236extern void HIMETRICToPixel(LONG *x, LONG *y);
237extern void PixelToHIMETRIC(LONG *x, LONG *y);
238
77ffb593 239// Windows convention of the mask is opposed to the wxWidgets one, so we need
4b7f2165
VZ
240// to invert the mask each time we pass one/get one to/from Windows
241extern HBITMAP wxInvertMask(HBITMAP hbmpMask, int w = 0, int h = 0);
242
211b54b1
VZ
243// Creates an icon or cursor depending from a bitmap
244//
245// The bitmap must be valid and it should have a mask. If it doesn't, a default
246// mask is created using light grey as the transparent colour.
247extern HICON wxBitmapToHICON(const wxBitmap& bmp);
248
249// Same requirments as above apply and the bitmap must also have the correct
250// size.
251extern
252HCURSOR wxBitmapToHCURSOR(const wxBitmap& bmp, int hotSpotX, int hotSpotY);
253
8614c467
VZ
254// get (x, y) from DWORD - notice that HI/LOWORD can *not* be used because they
255// will fail on system with multiple monitors where the coords may be negative
256//
257// these macros are standard now (Win98) but some older headers don't have them
258#ifndef GET_X_LPARAM
259 #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
260 #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
261#endif // GET_X_LPARAM
262
a95e38c0 263// get the current state of SHIFT/CTRL keys
1f80a703 264inline bool wxIsShiftDown()
a95e38c0 265{
1fdf858b
JS
266// return (::GetKeyState(VK_SHIFT) & 0x100) != 0;
267 // Returns different negative values on WinME and WinNT,
268 // so simply test for negative value.
269 return ::GetKeyState(VK_SHIFT) < 0;
a95e38c0
VZ
270}
271
1f80a703 272inline bool wxIsCtrlDown()
a95e38c0 273{
1fdf858b
JS
274// return (::GetKeyState(VK_CONTROL) & 0x100) != 0;
275 // Returns different negative values on WinME and WinNT,
276 // so simply test for negative value.
277 return ::GetKeyState(VK_CONTROL) < 0;
a95e38c0
VZ
278}
279
82c9f85c
VZ
280// wrapper around GetWindowRect() and GetClientRect() APIs doing error checking
281// for Win32
282inline RECT wxGetWindowRect(HWND hwnd)
283{
284 RECT rect;
3a5bcc4d 285
82c9f85c
VZ
286 if ( !::GetWindowRect(hwnd, &rect) )
287 {
288 wxLogLastError(_T("GetWindowRect"));
289 }
82c9f85c
VZ
290
291 return rect;
292}
293
294inline RECT wxGetClientRect(HWND hwnd)
295{
296 RECT rect;
3a5bcc4d 297
82c9f85c
VZ
298 if ( !::GetClientRect(hwnd, &rect) )
299 {
300 wxLogLastError(_T("GetClientRect"));
301 }
82c9f85c
VZ
302
303 return rect;
304}
305
6d167489
VZ
306// ---------------------------------------------------------------------------
307// small helper classes
308// ---------------------------------------------------------------------------
309
bffa02ff
VZ
310// a template to make initializing Windows styructs less painful: it zeroes all
311// the struct fields and also sets cbSize member to the correct value (and so
312// can be only used with structures which have this member...)
313template <class T>
314struct WinStruct : public T
315{
316 WinStruct()
317 {
5eae641d 318 ::ZeroMemory(this, sizeof(T));
329ac7da
VZ
319
320 // explicit qualification is required here for this to be valid C++
a7d174bf 321 this->cbSize = sizeof(T);
bffa02ff
VZ
322 }
323};
324
325
6d167489
VZ
326// create an instance of this class and use it as the HDC for screen, will
327// automatically release the DC going out of scope
328class ScreenHDC
329{
330public:
091225b4
VZ
331 ScreenHDC() { m_hdc = ::GetDC(NULL); }
332 ~ScreenHDC() { ::ReleaseDC(NULL, m_hdc); }
333
334 operator HDC() const { return m_hdc; }
335
336private:
337 HDC m_hdc;
22f3361e
VZ
338
339 DECLARE_NO_COPY_CLASS(ScreenHDC)
091225b4
VZ
340};
341
2ff56383
VZ
342// the same as ScreenHDC but for window DCs
343class WindowHDC
344{
345public:
346 WindowHDC(HWND hwnd) { m_hdc = ::GetDC(m_hwnd = hwnd); }
347 ~WindowHDC() { ::ReleaseDC(m_hwnd, m_hdc); }
348
349 operator HDC() const { return m_hdc; }
350
351private:
352 HWND m_hwnd;
353 HDC m_hdc;
354
355 DECLARE_NO_COPY_CLASS(WindowHDC)
356};
357
697b08a8
VZ
358// the same as ScreenHDC but for memory DCs: creates the HDC compatible with
359// the given one (screen by default) in ctor and destroys it in dtor
091225b4
VZ
360class MemoryHDC
361{
362public:
9cf743aa 363 MemoryHDC(HDC hdc = 0) { m_hdc = ::CreateCompatibleDC(hdc); }
697b08a8 364 ~MemoryHDC() { ::DeleteDC(m_hdc); }
091225b4
VZ
365
366 operator HDC() const { return m_hdc; }
6d167489
VZ
367
368private:
369 HDC m_hdc;
22f3361e
VZ
370
371 DECLARE_NO_COPY_CLASS(MemoryHDC)
6d167489
VZ
372};
373
091225b4
VZ
374// a class which selects a GDI object into a DC in its ctor and deselects in
375// dtor
376class SelectInHDC
377{
378public:
379 SelectInHDC(HDC hdc, HGDIOBJ hgdiobj) : m_hdc(hdc)
380 { m_hgdiobj = ::SelectObject(hdc, hgdiobj); }
381
382 ~SelectInHDC() { ::SelectObject(m_hdc, m_hgdiobj); }
383
384 // return true if the object was successfully selected
385 operator bool() const { return m_hgdiobj != 0; }
386
387private:
388 HDC m_hdc;
389 HGDIOBJ m_hgdiobj;
22f3361e 390
51a2a728
VZ
391 DECLARE_NO_COPY_CLASS(SelectInHDC)
392};
393
978bb48f
VZ
394// a class for temporary bitmaps
395class CompatibleBitmap
396{
397public:
398 CompatibleBitmap(HDC hdc, int w, int h)
399 {
400 m_hbmp = ::CreateCompatibleBitmap(hdc, w, h);
401 }
402
403 ~CompatibleBitmap()
404 {
405 if ( m_hbmp )
406 ::DeleteObject(m_hbmp);
407 }
408
409 operator HBITMAP() const { return m_hbmp; }
410
411private:
412 HBITMAP m_hbmp;
413};
414
51a2a728
VZ
415// when working with global pointers (which is unfortunately still necessary
416// sometimes, e.g. for clipboard) it is important to unlock them exactly as
417// many times as we lock them which just asks for using a "smart lock" class
06d09389 418class GlobalPtr
51a2a728
VZ
419{
420public:
06d09389 421 GlobalPtr(HGLOBAL hGlobal) : m_hGlobal(hGlobal)
51a2a728 422 {
2aaf17c2 423 m_ptr = GlobalLock(hGlobal);
51a2a728
VZ
424 if ( !m_ptr )
425 {
426 wxLogLastError(_T("GlobalLock"));
427 }
428 }
429
06d09389 430 ~GlobalPtr()
51a2a728 431 {
2aaf17c2 432 if ( !GlobalUnlock(m_hGlobal) )
51a2a728
VZ
433 {
434#ifdef __WXDEBUG__
435 // this might happen simply because the block became unlocked
436 DWORD dwLastError = ::GetLastError();
437 if ( dwLastError != NO_ERROR )
438 {
439 wxLogApiError(_T("GlobalUnlock"), dwLastError);
440 }
441#endif // __WXDEBUG__
442 }
443 }
444
445 operator void *() const { return m_ptr; }
446
447private:
448 HGLOBAL m_hGlobal;
449 void *m_ptr;
450
06d09389 451 DECLARE_NO_COPY_CLASS(GlobalPtr)
091225b4
VZ
452};
453
a23fd0e1 454// ---------------------------------------------------------------------------
42e69d6b 455// macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
c50f1fb9
VZ
456// returns Foo cast to the Windows type for oruselves, while GetFooOf() takes
457// an argument which should be a pointer or reference to the object of the
458// corresponding class (this depends on the macro)
a23fd0e1
VZ
459// ---------------------------------------------------------------------------
460
461#define GetHwnd() ((HWND)GetHWND())
c50f1fb9
VZ
462#define GetHwndOf(win) ((HWND)((win)->GetHWND()))
463// old name
464#define GetWinHwnd GetHwndOf
a23fd0e1
VZ
465
466#define GetHdc() ((HDC)GetHDC())
c50f1fb9 467#define GetHdcOf(dc) ((HDC)(dc).GetHDC())
a23fd0e1 468
11c7d5b6
VZ
469#define GetHbitmap() ((HBITMAP)GetHBITMAP())
470#define GetHbitmapOf(bmp) ((HBITMAP)(bmp).GetHBITMAP())
471
42e69d6b 472#define GetHicon() ((HICON)GetHICON())
c50f1fb9 473#define GetHiconOf(icon) ((HICON)(icon).GetHICON())
42e69d6b 474
a23fd0e1 475#define GetHaccel() ((HACCEL)GetHACCEL())
c50f1fb9
VZ
476#define GetHaccelOf(table) ((HACCEL)((table).GetHACCEL()))
477
ee50eab8
VZ
478#define GetHbrush() ((HPEN)GetResourceHandle())
479#define GetHbrushOf(brush) ((HPEN)(brush).GetResourceHandle())
480
c50f1fb9
VZ
481#define GetHmenu() ((HMENU)GetHMenu())
482#define GetHmenuOf(menu) ((HMENU)menu->GetHMenu())
a23fd0e1 483
bfbd6dc1
VZ
484#define GetHcursor() ((HCURSOR)GetHCURSOR())
485#define GetHcursorOf(cursor) ((HCURSOR)(cursor).GetHCURSOR())
486
f6bcfd97
BP
487#define GetHfont() ((HFONT)GetHFONT())
488#define GetHfontOf(font) ((HFONT)(font).GetHFONT())
489
1816a070 490#define GetHpalette() ((HPALETTE)GetHPALETTE())
b95edd47 491#define GetHpaletteOf(pal) ((HPALETTE)(pal).GetHPALETTE())
1816a070 492
75776373
VZ
493#define GetHpen() ((HPEN)GetResourceHandle())
494#define GetHpenOf(pen) ((HPEN)(pen).GetResourceHandle())
495
1e6feb95
VZ
496#define GetHrgn() ((HRGN)GetHRGN())
497#define GetHrgnOf(rgn) ((HRGN)(rgn).GetHRGN())
498
f6bcfd97
BP
499#endif // wxUSE_GUI
500
a23fd0e1
VZ
501// ---------------------------------------------------------------------------
502// global data
503// ---------------------------------------------------------------------------
2bda0e17 504
ef359b43 505extern WXDLLIMPEXP_DATA_BASE(HINSTANCE) wxhInstance;
2bda0e17 506
a23fd0e1
VZ
507// ---------------------------------------------------------------------------
508// global functions
509// ---------------------------------------------------------------------------
510
18600546
GRG
511extern "C"
512{
bb24c68f 513 WXDLLIMPEXP_BASE HINSTANCE wxGetInstance();
18600546
GRG
514}
515
bb24c68f 516WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
a23fd0e1 517
25b0e7c8
VZ
518// return the full path of the given module
519inline wxString wxGetFullModuleName(HMODULE hmod)
77d8d6cd
VZ
520{
521 wxString fullname;
522 if ( !::GetModuleFileName
523 (
25b0e7c8 524 hmod,
77d8d6cd
VZ
525 wxStringBuffer(fullname, MAX_PATH),
526 MAX_PATH
527 ) )
528 {
529 wxLogLastError(_T("GetModuleFileName"));
530 }
531
532 return fullname;
533}
534
25b0e7c8
VZ
535// return the full path of the program file
536inline wxString wxGetFullModuleName()
537{
538 return wxGetFullModuleName((HMODULE)wxGetInstance());
539}
540
b568d04f
VZ
541#if wxUSE_GUI
542
bfbd6dc1
VZ
543// cursor stuff
544extern HCURSOR wxGetCurrentBusyCursor(); // from msw/utils.cpp
545extern const wxCursor *wxGetGlobalCursor(); // from msw/cursor.cpp
546
7a5e53ab 547WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y, const wxFont& the_font);
11c7d5b6
VZ
548WXDLLEXPORT void wxFillLogFont(LOGFONT *logFont, const wxFont *font);
549WXDLLEXPORT wxFont wxCreateFontFromLogFont(const LOGFONT *logFont);
f6bcfd97 550WXDLLEXPORT wxFontEncoding wxGetFontEncFromCharSet(int charset);
a23fd0e1
VZ
551
552WXDLLEXPORT void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos);
553WXDLLEXPORT void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos);
554
555// Find maximum size of window/rectangle
ef359b43 556extern WXDLLEXPORT void wxFindMaxSize(WXHWND hwnd, RECT *rect);
a23fd0e1 557
1c4a764c 558// Safely get the window text (i.e. without using fixed size buffer)
ef359b43 559extern WXDLLEXPORT wxString wxGetWindowText(WXHWND hWnd);
1c4a764c 560
cc2b7472 561// get the window class name
ef359b43 562extern WXDLLEXPORT wxString wxGetWindowClass(WXHWND hWnd);
cc2b7472 563
42e69d6b
VZ
564// get the window id (should be unsigned, hence this is not wxWindowID which
565// is, for mainly historical reasons, signed)
ef359b43 566extern WXDLLEXPORT WXWORD wxGetWindowId(WXHWND hWnd);
cc2b7472 567
ae304744
VZ
568// check if hWnd's WNDPROC is wndProc. Return true if yes, false if they are
569// different
ef359b43 570extern WXDLLEXPORT bool wxCheckWindowWndProc(WXHWND hWnd, WXFARPROC wndProc);
eb5e4d9a 571
c085e333 572// Does this window style specify any border?
184b5d99 573inline bool wxStyleHasBorder(long style)
c085e333 574{
82c9f85c
VZ
575 return (style & (wxSIMPLE_BORDER | wxRAISED_BORDER |
576 wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0;
c085e333
VZ
577}
578
ae304744
VZ
579// ----------------------------------------------------------------------------
580// functions mapping HWND to wxWindow
581// ----------------------------------------------------------------------------
582
583// this function simply checks whether the given hWnd corresponds to a wxWindow
584// and returns either that window if it does or NULL otherwise
ef359b43 585extern WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd);
ae304744
VZ
586
587// find the window for HWND which is part of some wxWindow, i.e. unlike
588// wxFindWinFromHandle() above it will also work for "sub controls" of a
589// wxWindow.
8614c467 590//
ae304744 591// returns the wxWindow corresponding to the given HWND or NULL.
ef359b43 592extern WXDLLEXPORT wxWindow *wxGetWindowFromHWND(WXHWND hwnd);
8614c467 593
6bad4c32 594// Get the size of an icon
ef359b43 595extern WXDLLEXPORT wxSize wxGetHiconSize(HICON hicon);
6bad4c32 596
086b3a5b
JS
597// Lines are drawn differently for WinCE and regular WIN32
598WXDLLEXPORT void wxDrawLine(HDC hdc, int x1, int y1, int x2, int y2);
599
5171ea0e
VZ
600// ----------------------------------------------------------------------------
601// 32/64 bit helpers
602// ----------------------------------------------------------------------------
603
604#ifdef __WIN64__
605
606inline void *wxGetWindowProc(HWND hwnd)
607{
608 return (void *)::GetWindowLongPtr(hwnd, GWLP_WNDPROC);
609}
610
611inline void *wxGetWindowUserData(HWND hwnd)
612{
613 return (void *)::GetWindowLongPtr(hwnd, GWLP_USERDATA);
614}
615
616inline WNDPROC wxSetWindowProc(HWND hwnd, WNDPROC func)
617{
618 return (WNDPROC)::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)func);
619}
620
621inline void *wxSetWindowUserData(HWND hwnd, void *data)
622{
623 return (void *)::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data);
624}
625
626#else // __WIN32__
627
b41f29c3
VZ
628#ifdef __VISUALC__
629 // strangely enough, VC++ 7.1 gives warnings about 32 -> 64 bit conversions
630 // in the functions below, even in spite of the explicit casts
631 #pragma warning(disable:4311)
632 #pragma warning(disable:4312)
633#endif
634
5171ea0e
VZ
635inline void *wxGetWindowProc(HWND hwnd)
636{
637 return (void *)::GetWindowLong(hwnd, GWL_WNDPROC);
638}
639
640inline void *wxGetWindowUserData(HWND hwnd)
641{
642 return (void *)::GetWindowLong(hwnd, GWL_USERDATA);
643}
644
645inline WNDPROC wxSetWindowProc(HWND hwnd, WNDPROC func)
646{
647 return (WNDPROC)::SetWindowLong(hwnd, GWL_WNDPROC, (LONG)func);
648}
649
650inline void *wxSetWindowUserData(HWND hwnd, void *data)
651{
652 return (void *)::SetWindowLong(hwnd, GWL_USERDATA, (LONG)data);
653}
654
b41f29c3
VZ
655#ifdef __VISUALC__
656 #pragma warning(default:4311)
657 #pragma warning(default:4312)
658#endif
659
5171ea0e
VZ
660#endif // __WIN64__/__WIN32__
661
b568d04f
VZ
662#endif // wxUSE_GUI
663
2bda0e17 664#endif
bbcdf8bc 665 // _WX_PRIVATE_H_