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