wxMessageBox off the main thread lost result code.
[wxWidgets.git] / include / wx / msw / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/window.h
3 // Purpose: wxWindowMSW class
4 // Author: Julian Smart
5 // Modified by: Vadim Zeitlin on 13.05.99: complete refont of message handling,
6 // elimination of Default(), ...
7 // Created: 01/02/97
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_
13 #define _WX_WINDOW_H_
14
15 #include "wx/settings.h" // solely for wxSystemColour
16
17 // if this is set to 1, we use deferred window sizing to reduce flicker when
18 // resizing complicated window hierarchies, but this can in theory result in
19 // different behaviour than the old code so we keep the possibility to use it
20 // by setting this to 0 (in the future this should be removed completely)
21 #ifdef __WXWINCE__
22 #define wxUSE_DEFERRED_SIZING 0
23 #else
24 #define wxUSE_DEFERRED_SIZING 1
25 #endif
26
27 // ---------------------------------------------------------------------------
28 // wxWindow declaration for MSW
29 // ---------------------------------------------------------------------------
30
31 class WXDLLIMPEXP_CORE wxWindowMSW : public wxWindowBase
32 {
33 friend class wxSpinCtrl;
34 friend class wxSlider;
35 friend class wxRadioBox;
36 #if defined __VISUALC__ && __VISUALC__ <= 1200
37 friend class wxWindowMSW;
38 #endif
39 public:
40 wxWindowMSW() { Init(); }
41
42 wxWindowMSW(wxWindow *parent,
43 wxWindowID id,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize,
46 long style = 0,
47 const wxString& name = wxPanelNameStr)
48 {
49 Init();
50 Create(parent, id, pos, size, style, name);
51 }
52
53 virtual ~wxWindowMSW();
54
55 bool Create(wxWindow *parent,
56 wxWindowID id,
57 const wxPoint& pos = wxDefaultPosition,
58 const wxSize& size = wxDefaultSize,
59 long style = 0,
60 const wxString& name = wxPanelNameStr);
61
62 // implement base class pure virtuals
63 virtual void SetLabel(const wxString& label);
64 virtual wxString GetLabel() const;
65
66 virtual void Raise();
67 virtual void Lower();
68
69 virtual bool BeginRepositioningChildren();
70 virtual void EndRepositioningChildren();
71
72 virtual bool Show(bool show = true);
73 virtual bool ShowWithEffect(wxShowEffect effect,
74 unsigned timeout = 0)
75 {
76 return MSWShowWithEffect(true, effect, timeout);
77 }
78 virtual bool HideWithEffect(wxShowEffect effect,
79 unsigned timeout = 0)
80 {
81 return MSWShowWithEffect(false, effect, timeout);
82 }
83
84 virtual void SetFocus();
85 virtual void SetFocusFromKbd();
86
87 virtual bool Reparent(wxWindowBase *newParent);
88
89 virtual void WarpPointer(int x, int y);
90
91 virtual void Refresh( bool eraseBackground = true,
92 const wxRect *rect = (const wxRect *) NULL );
93 virtual void Update();
94
95 virtual void SetWindowStyleFlag(long style);
96 virtual void SetExtraStyle(long exStyle);
97 virtual bool SetCursor( const wxCursor &cursor );
98 virtual bool SetFont( const wxFont &font );
99
100 virtual int GetCharHeight() const;
101 virtual int GetCharWidth() const;
102
103 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
104 int range, bool refresh = true );
105 virtual void SetScrollPos( int orient, int pos, bool refresh = true );
106 virtual int GetScrollPos( int orient ) const;
107 virtual int GetScrollThumb( int orient ) const;
108 virtual int GetScrollRange( int orient ) const;
109 virtual void ScrollWindow( int dx, int dy,
110 const wxRect* rect = NULL );
111
112 virtual bool ScrollLines(int lines);
113 virtual bool ScrollPages(int pages);
114
115 virtual void SetLayoutDirection(wxLayoutDirection dir);
116 virtual wxLayoutDirection GetLayoutDirection() const;
117 virtual wxCoord AdjustForLayoutDirection(wxCoord x,
118 wxCoord width,
119 wxCoord widthTotal) const;
120
121 #if wxUSE_DRAG_AND_DROP
122 virtual void SetDropTarget( wxDropTarget *dropTarget );
123 #endif // wxUSE_DRAG_AND_DROP
124
125 // Accept files for dragging
126 virtual void DragAcceptFiles(bool accept);
127
128 #ifndef __WXUNIVERSAL__
129 // Native resource loading (implemented in src/msw/nativdlg.cpp)
130 // FIXME: should they really be all virtual?
131 virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id);
132 virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
133 wxWindow* GetWindowChild1(wxWindowID id);
134 wxWindow* GetWindowChild(wxWindowID id);
135 #endif // __WXUNIVERSAL__
136
137 #if wxUSE_HOTKEY
138 // install and deinstall a system wide hotkey
139 virtual bool RegisterHotKey(int hotkeyId, int modifiers, int keycode);
140 virtual bool UnregisterHotKey(int hotkeyId);
141 #endif // wxUSE_HOTKEY
142
143 #ifdef __POCKETPC__
144 bool IsContextMenuEnabled() const { return m_contextMenuEnabled; }
145 void EnableContextMenu(bool enable = true) { m_contextMenuEnabled = enable; }
146 #endif
147
148 // window handle stuff
149 // -------------------
150
151 WXHWND GetHWND() const { return m_hWnd; }
152 void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
153 virtual WXWidget GetHandle() const { return GetHWND(); }
154
155 void AssociateHandle(WXWidget handle);
156 void DissociateHandle();
157
158 // does this window have deferred position and/or size?
159 bool IsSizeDeferred() const;
160
161 // these functions allow to register a global handler for the given Windows
162 // message: it will be called from MSWWindowProc() of any window which gets
163 // this event if it's not processed before (i.e. unlike a hook procedure it
164 // does not override the normal processing)
165 //
166 // notice that if you want to process a message for a given window only you
167 // should override its MSWWindowProc() instead
168
169 // type of the handler: it is called with the message parameters (except
170 // that the window object is passed instead of window handle) and should
171 // return true if it handled the message or false if it should be passed to
172 // DefWindowProc()
173 typedef bool (*MSWMessageHandler)(wxWindowMSW *win,
174 WXUINT nMsg,
175 WXWPARAM wParam,
176 WXLPARAM lParam);
177
178 // install a handler, shouldn't be called more than one for the same message
179 static bool MSWRegisterMessageHandler(int msg, MSWMessageHandler handler);
180
181 // unregister a previously registered handler
182 static void MSWUnregisterMessageHandler(int msg, MSWMessageHandler handler);
183
184
185 // implementation from now on
186 // ==========================
187
188 // event handlers
189 // --------------
190
191 void OnPaint(wxPaintEvent& event);
192 #ifdef __WXWINCE__
193 void OnInitDialog(wxInitDialogEvent& event);
194 #endif
195
196 public:
197 // Windows subclassing
198 void SubclassWin(WXHWND hWnd);
199 void UnsubclassWin();
200
201 WXFARPROC MSWGetOldWndProc() const { return m_oldWndProc; }
202 void MSWSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; }
203
204 // return true if the window is of a standard (i.e. not wxWidgets') class
205 //
206 // to understand why does it work, look at SubclassWin() code and comments
207 bool IsOfStandardClass() const { return m_oldWndProc != NULL; }
208
209 wxWindow *FindItem(long id) const;
210 wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = false) const;
211
212 // MSW only: true if this control is part of the main control
213 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return false; }
214
215 #if wxUSE_TOOLTIPS
216 // MSW only: true if this window or any of its children have a tooltip
217 virtual bool HasToolTips() const { return GetToolTip() != NULL; }
218 #endif // wxUSE_TOOLTIPS
219
220 // translate wxWidgets style flags for this control into the Windows style
221 // and optional extended style for the corresponding native control
222 //
223 // this is the function that should be overridden in the derived classes,
224 // but you will mostly use MSWGetCreateWindowFlags() below
225 virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const ;
226
227 // get the MSW window flags corresponding to wxWidgets ones
228 //
229 // the functions returns the flags (WS_XXX) directly and puts the ext
230 // (WS_EX_XXX) flags into the provided pointer if not NULL
231 WXDWORD MSWGetCreateWindowFlags(WXDWORD *exflags = NULL) const
232 { return MSWGetStyle(GetWindowStyle(), exflags); }
233
234 // update the real underlying window style flags to correspond to the
235 // current wxWindow object style (safe to call even if window isn't fully
236 // created yet)
237 void MSWUpdateStyle(long flagsOld, long exflagsOld);
238
239 // get the HWND to be used as parent of this window with CreateWindow()
240 virtual WXHWND MSWGetParent() const;
241
242 // get the Win32 window class name used by all wxWindow objects by default
243 static const wxChar *MSWGetRegisteredClassName();
244
245 // creates the window of specified Windows class with given style, extended
246 // style, title and geometry (default values
247 //
248 // returns true if the window has been created, false if creation failed
249 bool MSWCreate(const wxChar *wclass,
250 const wxChar *title = NULL,
251 const wxPoint& pos = wxDefaultPosition,
252 const wxSize& size = wxDefaultSize,
253 WXDWORD style = 0,
254 WXDWORD exendedStyle = 0);
255
256 virtual bool MSWCommand(WXUINT param, WXWORD id);
257
258 #ifndef __WXUNIVERSAL__
259 // Create an appropriate wxWindow from a HWND
260 virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd);
261
262 // Make sure the window style reflects the HWND style (roughly)
263 virtual void AdoptAttributesFromHWND();
264 #endif // __WXUNIVERSAL__
265
266 // Setup background and foreground colours correctly
267 virtual void SetupColours();
268
269 // ------------------------------------------------------------------------
270 // helpers for message handlers: these perform the same function as the
271 // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
272 // the correct parameters
273 // ------------------------------------------------------------------------
274
275 void UnpackCommand(WXWPARAM wParam, WXLPARAM lParam,
276 WXWORD *id, WXHWND *hwnd, WXWORD *cmd);
277 void UnpackActivate(WXWPARAM wParam, WXLPARAM lParam,
278 WXWORD *state, WXWORD *minimized, WXHWND *hwnd);
279 void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
280 WXWORD *code, WXWORD *pos, WXHWND *hwnd);
281 void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
282 WXHDC *hdc, WXHWND *hwnd);
283 void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
284 WXWORD *item, WXWORD *flags, WXHMENU *hmenu);
285
286 // ------------------------------------------------------------------------
287 // internal handlers for MSW messages: all handlers return a boolean value:
288 // true means that the handler processed the event and false that it didn't
289 // ------------------------------------------------------------------------
290
291 // there are several cases where we have virtual functions for Windows
292 // message processing: this is because these messages often require to be
293 // processed in a different manner in the derived classes. For all other
294 // messages, however, we do *not* have corresponding MSWOnXXX() function
295 // and if the derived class wants to process them, it should override
296 // MSWWindowProc() directly.
297
298 // scroll event (both horizontal and vertical)
299 virtual bool MSWOnScroll(int orientation, WXWORD nSBCode,
300 WXWORD pos, WXHWND control);
301
302 // child control notifications
303 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
304
305 // owner-drawn controls need to process these messages
306 virtual bool MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *item);
307 virtual bool MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item);
308
309 // the rest are not virtual
310 bool HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate);
311 bool HandleInitDialog(WXHWND hWndFocus);
312 bool HandleDestroy();
313
314 bool HandlePaint();
315 bool HandlePrintClient(WXHDC hDC);
316 bool HandleEraseBkgnd(WXHDC hDC);
317
318 bool HandleMinimize();
319 bool HandleMaximize();
320 bool HandleSize(int x, int y, WXUINT flag);
321 bool HandleSizing(wxRect& rect);
322 bool HandleGetMinMaxInfo(void *mmInfo);
323 bool HandleEnterSizeMove();
324 bool HandleExitSizeMove();
325
326 bool HandleShow(bool show, int status);
327 bool HandleActivate(int flag, bool minimized, WXHWND activate);
328
329 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
330
331 bool HandleCtlColor(WXHBRUSH *hBrush, WXHDC hdc, WXHWND hWnd);
332
333 bool HandlePaletteChanged(WXHWND hWndPalChange);
334 bool HandleQueryNewPalette();
335 bool HandleSysColorChange();
336 bool HandleDisplayChange();
337 bool HandleCaptureChanged(WXHWND gainedCapture);
338 virtual bool HandleSettingChange(WXWPARAM wParam, WXLPARAM lParam);
339
340 bool HandleQueryEndSession(long logOff, bool *mayEnd);
341 bool HandleEndSession(bool endSession, long logOff);
342
343 bool HandleSetFocus(WXHWND wnd);
344 bool HandleKillFocus(WXHWND wnd);
345
346 bool HandleDropFiles(WXWPARAM wParam);
347
348 bool HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags);
349 bool HandleMouseMove(int x, int y, WXUINT flags);
350 bool HandleMouseWheel(wxMouseWheelAxis axis,
351 WXWPARAM wParam, WXLPARAM lParam);
352
353 bool HandleChar(WXWPARAM wParam, WXLPARAM lParam);
354 bool HandleKeyDown(WXWPARAM wParam, WXLPARAM lParam);
355 bool HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam);
356 #if wxUSE_HOTKEY
357 bool HandleHotKey(WXWPARAM wParam, WXLPARAM lParam);
358 #endif
359 #ifdef __WIN32__
360 int HandleMenuChar(int chAccel, WXLPARAM lParam);
361 #endif
362 // Create and process a clipboard event specified by type.
363 bool HandleClipboardEvent( WXUINT nMsg );
364
365 bool HandleQueryDragIcon(WXHICON *hIcon);
366
367 bool HandleSetCursor(WXHWND hWnd, short nHitTest, int mouseMsg);
368
369 bool HandlePower(WXWPARAM wParam, WXLPARAM lParam, bool *vetoed);
370
371
372 // The main body of common window proc for all wxWindow objects. It tries
373 // to handle the given message and returns true if it was handled (the
374 // appropriate return value is then put in result, which must be non-NULL)
375 // or false if it wasn't.
376 //
377 // This function should be overridden in any new code instead of
378 // MSWWindowProc() even if currently most of the code overrides
379 // MSWWindowProc() as it had been written before this function was added.
380 virtual bool MSWHandleMessage(WXLRESULT *result,
381 WXUINT message,
382 WXWPARAM wParam,
383 WXLPARAM lParam);
384
385 // Common Window procedure for all wxWindow objects: forwards to
386 // MSWHandleMessage() and MSWDefWindowProc() if the message wasn't handled.
387 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
388
389 // Calls an appropriate default window procedure
390 virtual WXLRESULT MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
391
392 // message processing helpers
393
394 // return false if the message shouldn't be translated/preprocessed but
395 // dispatched normally
396 virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg);
397
398 // return true if the message was preprocessed and shouldn't be dispatched
399 virtual bool MSWProcessMessage(WXMSG* pMsg);
400
401 // return true if the message was translated and shouldn't be dispatched
402 virtual bool MSWTranslateMessage(WXMSG* pMsg);
403
404 // called when the window is about to be destroyed
405 virtual void MSWDestroyWindow();
406
407
408 // Functions dealing with painting the window background. The derived
409 // classes should normally only need to reimplement MSWGetBgBrush() if they
410 // need to use a non-solid brush for erasing their background. This
411 // function is called by MSWGetBgBrushForChild() which only exists for the
412 // weird wxToolBar case and MSWGetBgBrushForChild() itself is used by
413 // MSWGetBgBrush() to actually find the right brush to use.
414
415 // Adjust the origin for the brush returned by MSWGetBgBrushForChild().
416 //
417 // This needs to be overridden for scrolled windows to ensure that the
418 // scrolling of their associated DC is taken into account.
419 //
420 // Both parameters must be non-NULL.
421 virtual void MSWAdjustBrushOrg(int* WXUNUSED(xOrg),
422 int* WXUNUSED(yOrg)) const
423 {
424 }
425
426 // The brush returned from here must remain valid at least until the next
427 // event loop iteration. Returning 0, as is done by default, indicates
428 // there is no custom background brush.
429 virtual WXHBRUSH MSWGetCustomBgBrush() { return 0; }
430
431 // this function should return the brush to paint the children controls
432 // background or 0 if this window doesn't impose any particular background
433 // on its children
434 //
435 // the hDC parameter is the DC background will be drawn on, it can be used
436 // to call SetBrushOrgEx() on it if the returned brush is a bitmap one
437 //
438 // child parameter is never NULL, it can be this window itself or one of
439 // its (grand)children
440 //
441 // the base class version returns a solid brush if we have a non default
442 // background colour or 0 otherwise
443 virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child);
444
445 // return the background brush to use for painting the given window by
446 // querying the parent windows via MSWGetBgBrushForChild() recursively
447 WXHBRUSH MSWGetBgBrush(WXHDC hDC);
448
449 enum MSWThemeColour
450 {
451 ThemeColourText = 0,
452 ThemeColourBackground,
453 ThemeColourBorder
454 };
455
456 // returns a specific theme colour, or if that is not possible then
457 // wxSystemSettings::GetColour(fallback)
458 wxColour MSWGetThemeColour(const wchar_t *themeName,
459 int themePart,
460 int themeState,
461 MSWThemeColour themeColour,
462 wxSystemColour fallback) const;
463
464 // gives the parent the possibility to draw its children background, e.g.
465 // this is used by wxNotebook to do it using DrawThemeBackground()
466 //
467 // return true if background was drawn, false otherwise
468 virtual bool MSWPrintChild(WXHDC WXUNUSED(hDC), wxWindow * WXUNUSED(child))
469 {
470 return false;
471 }
472
473 // some controls (e.g. wxListBox) need to set the return value themselves
474 //
475 // return true to let parent handle it if we don't, false otherwise
476 virtual bool MSWShouldPropagatePrintChild()
477 {
478 return true;
479 }
480
481 // This should be overridden to return true for the controls which have
482 // themed background that should through their children. Currently only
483 // wxNotebook uses this.
484 //
485 // The base class version already returns true if we have a solid
486 // background colour that should be propagated to our children.
487 virtual bool MSWHasInheritableBackground() const
488 {
489 return InheritsBackgroundColour();
490 }
491
492 #if !defined(__WXWINCE__) && !defined(__WXUNIVERSAL__)
493 #define wxHAS_MSW_BACKGROUND_ERASE_HOOK
494 #endif
495
496 #ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK
497 // allows the child to hook into its parent WM_ERASEBKGND processing: call
498 // MSWSetEraseBgHook() with a non-NULL window to make parent call
499 // MSWEraseBgHook() on this window (don't forget to reset it to NULL
500 // afterwards)
501 //
502 // this hack is used by wxToolBar, see comments there
503 void MSWSetEraseBgHook(wxWindow *child);
504
505 // return true if WM_ERASEBKGND is currently hooked
506 bool MSWHasEraseBgHook() const;
507
508 // called when the window on which MSWSetEraseBgHook() had been called
509 // receives WM_ERASEBKGND
510 virtual bool MSWEraseBgHook(WXHDC WXUNUSED(hDC)) { return false; }
511 #endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK
512
513 // common part of Show/HideWithEffect()
514 bool MSWShowWithEffect(bool show,
515 wxShowEffect effect,
516 unsigned timeout);
517
518 // Responds to colour changes: passes event on to children.
519 void OnSysColourChanged(wxSysColourChangedEvent& event);
520
521 // initialize various fields of wxMouseEvent (common part of MSWOnMouseXXX)
522 void InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags);
523
524 // check if mouse is in the window
525 bool IsMouseInWindow() const;
526
527 // check if a native double-buffering applies for this window
528 virtual bool IsDoubleBuffered() const;
529
530 void SetDoubleBuffered(bool on);
531
532 // synthesize a wxEVT_LEAVE_WINDOW event and set m_mouseInWindow to false
533 void GenerateMouseLeave();
534
535 // virtual function for implementing internal idle
536 // behaviour
537 virtual void OnInternalIdle();
538
539 protected:
540 // this allows you to implement standard control borders without
541 // repeating the code in different classes that are not derived from
542 // wxControl
543 virtual wxBorder GetDefaultBorderForControl() const;
544
545 // choose the default border for this window
546 virtual wxBorder GetDefaultBorder() const;
547
548 // Translate wxBORDER_THEME (and other border styles if necessary to the value
549 // that makes most sense for this Windows environment
550 virtual wxBorder TranslateBorder(wxBorder border) const;
551
552 #if wxUSE_MENUS_NATIVE
553 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
554 #endif // wxUSE_MENUS_NATIVE
555
556 // the window handle
557 WXHWND m_hWnd;
558
559 // the old window proc (we subclass all windows)
560 WXFARPROC m_oldWndProc;
561
562 // additional (MSW specific) flags
563 bool m_mouseInWindow:1;
564 bool m_lastKeydownProcessed:1;
565
566 // the size of one page for scrolling
567 int m_xThumbSize;
568 int m_yThumbSize;
569
570 // implement the base class pure virtuals
571 virtual void DoGetTextExtent(const wxString& string,
572 int *x, int *y,
573 int *descent = NULL,
574 int *externalLeading = NULL,
575 const wxFont *font = NULL) const;
576 virtual void DoClientToScreen( int *x, int *y ) const;
577 virtual void DoScreenToClient( int *x, int *y ) const;
578 virtual void DoGetPosition( int *x, int *y ) const;
579 virtual void DoGetSize( int *width, int *height ) const;
580 virtual void DoGetClientSize( int *width, int *height ) const;
581 virtual void DoSetSize(int x, int y,
582 int width, int height,
583 int sizeFlags = wxSIZE_AUTO);
584 virtual void DoSetClientSize(int width, int height);
585
586 virtual wxSize DoGetBorderSize() const;
587
588 virtual void DoCaptureMouse();
589 virtual void DoReleaseMouse();
590
591 virtual void DoEnable(bool enable);
592
593 virtual void DoFreeze();
594 virtual void DoThaw();
595
596 // this simply moves/resizes the given HWND which is supposed to be our
597 // sibling (this is useful for controls which are composite at MSW level
598 // and for which DoMoveWindow() is not enough)
599 //
600 // returns true if the window move was deferred, false if it was moved
601 // immediately (no error return)
602 bool DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height);
603
604 // move the window to the specified location and resize it: this is called
605 // from both DoSetSize() and DoSetClientSize() and would usually just call
606 // ::MoveWindow() except for composite controls which will want to arrange
607 // themselves inside the given rectangle
608 virtual void DoMoveWindow(int x, int y, int width, int height);
609
610 #if wxUSE_TOOLTIPS
611 virtual void DoSetToolTip( wxToolTip *tip );
612
613 // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in
614 // comctl32.dll in our code -- see the function body for more info)
615 bool HandleTooltipNotify(WXUINT code,
616 WXLPARAM lParam,
617 const wxString& ttip);
618 #endif // wxUSE_TOOLTIPS
619
620 // This is used by CreateKeyEvent() and also for wxEVT_CHAR[_HOOK] event
621 // creation. Notice that this method doesn't initialize wxKeyEvent
622 // m_keyCode and m_uniChar fields.
623 void InitAnyKeyEvent(wxKeyEvent& event,
624 WXWPARAM wParam,
625 WXLPARAM lParam) const;
626
627 // Helper functions used by HandleKeyXXX() methods and some derived
628 // classes, wParam and lParam have the same meaning as in WM_KEY{DOWN,UP}.
629 //
630 // NB: evType here must be wxEVT_KEY_{DOWN,UP} as wParam here contains the
631 // virtual key code, not character!
632 wxKeyEvent CreateKeyEvent(wxEventType evType,
633 WXWPARAM wParam,
634 WXLPARAM lParam = 0) const;
635
636 // Another helper for creating wxKeyEvent for wxEVT_CHAR and related types.
637 //
638 // The wParam and lParam here must come from WM_CHAR event parameters, i.e.
639 // wParam must be a character and not a virtual code.
640 wxKeyEvent CreateCharEvent(wxEventType evType,
641 WXWPARAM wParam,
642 WXLPARAM lParam) const;
643
644
645 // default OnEraseBackground() implementation, return true if we did erase
646 // the background, false otherwise (i.e. the system should erase it)
647 bool DoEraseBackground(WXHDC hDC);
648
649 // generate WM_CHANGEUISTATE if it's needed for the OS we're running under
650 //
651 // action should be one of the UIS_XXX constants
652 // state should be one or more of the UISF_XXX constants
653 // if action == UIS_INITIALIZE then it doesn't seem to matter what we use
654 // for state as the system will decide for us what needs to be set
655 void MSWUpdateUIState(int action, int state = 0);
656
657 // translate wxWidgets coords into Windows ones suitable to be passed to
658 // ::CreateWindow(), called from MSWCreate()
659 virtual void MSWGetCreateWindowCoords(const wxPoint& pos,
660 const wxSize& size,
661 int& x, int& y,
662 int& w, int& h) const;
663
664 bool MSWEnableHWND(WXHWND hWnd, bool enable);
665
666 private:
667 // common part of all ctors
668 void Init();
669
670 // the (non-virtual) handlers for the events
671 bool HandleMove(int x, int y);
672 bool HandleMoving(wxRect& rect);
673 bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
674 bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
675
676 #if wxUSE_DEFERRED_SIZING
677 protected:
678 // this function is called after the window was resized to its new size
679 virtual void MSWEndDeferWindowPos()
680 {
681 m_pendingPosition = wxDefaultPosition;
682 m_pendingSize = wxDefaultSize;
683 }
684
685 // current defer window position operation handle (may be NULL)
686 WXHANDLE m_hDWP;
687
688 // When deferred positioning is done these hold the pending changes, and
689 // are used for the default values if another size/pos changes is done on
690 // this window before the group of deferred changes is completed.
691 wxPoint m_pendingPosition;
692 wxSize m_pendingSize;
693 #endif // wxUSE_DEFERRED_SIZING
694
695 private:
696 #ifdef __POCKETPC__
697 bool m_contextMenuEnabled;
698 #endif
699
700 DECLARE_DYNAMIC_CLASS(wxWindowMSW)
701 wxDECLARE_NO_COPY_CLASS(wxWindowMSW);
702 DECLARE_EVENT_TABLE()
703 };
704
705 // window creation helper class: before creating a new HWND, instantiate an
706 // object of this class on stack - this allows to process the messages sent to
707 // the window even before CreateWindow() returns
708 class wxWindowCreationHook
709 {
710 public:
711 wxWindowCreationHook(wxWindowMSW *winBeingCreated);
712 ~wxWindowCreationHook();
713 };
714
715 #endif // _WX_WINDOW_H_