]> git.saurik.com Git - wxWidgets.git/blame - src/msw/dialog.cpp
Include wx/slider.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / src / msw / dialog.cpp
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
b6c588e1 2// Name: src/msw/dialog.cpp
2bda0e17
KB
3// Purpose: wxDialog class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
6c9a19aa 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
b6c588e1
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
2bda0e17
KB
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
b6c588e1 24 #pragma hdrstop
2bda0e17
KB
25#endif
26
fdf565fe
WS
27#include "wx/dialog.h"
28
2bda0e17 29#ifndef WX_PRECOMP
b6c588e1
VZ
30 #include "wx/utils.h"
31 #include "wx/frame.h"
32 #include "wx/app.h"
95e92d90 33 #include "wx/button.h"
b6c588e1
VZ
34 #include "wx/settings.h"
35 #include "wx/intl.h"
36 #include "wx/log.h"
2bda0e17
KB
37#endif
38
39#include "wx/msw/private.h"
ac8d0c11 40#include "wx/evtloop.h"
8c7f5f03 41#include "wx/ptr_scpd.h"
2bda0e17 42
660296aa 43#include "wx/msw/wrapcdlg.h"
2bda0e17 44
3180bc0e 45#if defined(__SMARTPHONE__) && defined(__WXWINCE__)
ef6d716b 46 #include "wx/msw/wince/resources.h"
3180bc0e 47#endif // __SMARTPHONE__ && __WXWINCE__
ef6d716b 48
ec5f0c24
JS
49#if wxUSE_TOOLBAR && defined(__POCKETPC__)
50#include "wx/toolbar.h"
51#endif
52
b6c588e1
VZ
53// ----------------------------------------------------------------------------
54// wxWin macros
55// ----------------------------------------------------------------------------
56
ffca575c
SC
57#if wxUSE_EXTENDED_RTTI
58WX_DEFINE_FLAGS( wxDialogStyle )
59
3ff066a4 60wxBEGIN_FLAGS( wxDialogStyle )
ffca575c
SC
61 // new style border flags, we put them first to
62 // use them for streaming out
3ff066a4
SC
63 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
64 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
65 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
66 wxFLAGS_MEMBER(wxBORDER_RAISED)
67 wxFLAGS_MEMBER(wxBORDER_STATIC)
68 wxFLAGS_MEMBER(wxBORDER_NONE)
044fe836 69
ffca575c 70 // old style border flags
3ff066a4
SC
71 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
72 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
73 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
74 wxFLAGS_MEMBER(wxRAISED_BORDER)
75 wxFLAGS_MEMBER(wxSTATIC_BORDER)
76 wxFLAGS_MEMBER(wxNO_BORDER)
ffca575c
SC
77
78 // standard window styles
3ff066a4
SC
79 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
80 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
ffca575c
SC
81
82 // dialog styles
3ff066a4
SC
83 wxFLAGS_MEMBER(wxWS_EX_VALIDATE_RECURSIVELY)
84 wxFLAGS_MEMBER(wxSTAY_ON_TOP)
85 wxFLAGS_MEMBER(wxCAPTION)
1c067fe3 86#if WXWIN_COMPATIBILITY_2_6
3ff066a4 87 wxFLAGS_MEMBER(wxTHICK_FRAME)
1c067fe3 88#endif // WXWIN_COMPATIBILITY_2_6
3ff066a4
SC
89 wxFLAGS_MEMBER(wxSYSTEM_MENU)
90 wxFLAGS_MEMBER(wxRESIZE_BORDER)
1c067fe3 91#if WXWIN_COMPATIBILITY_2_6
3ff066a4 92 wxFLAGS_MEMBER(wxRESIZE_BOX)
1c067fe3 93#endif // WXWIN_COMPATIBILITY_2_6
3ff066a4
SC
94 wxFLAGS_MEMBER(wxCLOSE_BOX)
95 wxFLAGS_MEMBER(wxMAXIMIZE_BOX)
96 wxFLAGS_MEMBER(wxMINIMIZE_BOX)
97wxEND_FLAGS( wxDialogStyle )
ffca575c
SC
98
99IMPLEMENT_DYNAMIC_CLASS_XTI(wxDialog, wxTopLevelWindow,"wx/dialog.h")
100
3ff066a4 101wxBEGIN_PROPERTIES_TABLE(wxDialog)
af498247
VZ
102 wxPROPERTY( Title, wxString, SetTitle, GetTitle, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
103 wxPROPERTY_FLAGS( WindowStyle , wxDialogStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
3ff066a4 104wxEND_PROPERTIES_TABLE()
ffca575c 105
3ff066a4
SC
106wxBEGIN_HANDLERS_TABLE(wxDialog)
107wxEND_HANDLERS_TABLE()
ffca575c 108
044fe836 109wxCONSTRUCTOR_6( wxDialog , wxWindow* , Parent , wxWindowID , Id , wxString , Title , wxPoint , Position , wxSize , Size , long , WindowStyle)
ffca575c
SC
110
111#else
82c9f85c 112IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
ffca575c 113#endif
066f1b7a 114
138e1502 115BEGIN_EVENT_TABLE(wxDialog, wxDialogBase)
1b6452df
VZ
116 EVT_BUTTON(wxID_OK, wxDialog::OnOK)
117 EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
118 EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
b6c588e1 119
1b6452df 120 EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
b6c588e1 121
1b6452df
VZ
122 EVT_CLOSE(wxDialog::OnCloseWindow)
123END_EVENT_TABLE()
2bda0e17 124
6757b5e3
VZ
125// ----------------------------------------------------------------------------
126// wxDialogModalData
127// ----------------------------------------------------------------------------
128
8c7f5f03
VZ
129// this is simply a container for any data we need to implement modality which
130// allows us to avoid changing wxDialog each time the implementation changes
6757b5e3
VZ
131class wxDialogModalData
132{
133public:
8c7f5f03 134 wxDialogModalData(wxDialog *dialog) : m_evtLoop(dialog) { }
6757b5e3 135
8c7f5f03 136 void RunLoop()
6757b5e3 137 {
6757b5e3
VZ
138 m_evtLoop.Run();
139 }
140
141 void ExitLoop()
142 {
6757b5e3
VZ
143 m_evtLoop.Exit();
144 }
145
6757b5e3 146private:
8c7f5f03 147 wxModalEventLoop m_evtLoop;
6757b5e3
VZ
148};
149
259c43f6 150wxDEFINE_TIED_SCOPED_PTR_TYPE(wxDialogModalData)
8c7f5f03 151
b6c588e1
VZ
152// ============================================================================
153// implementation
154// ============================================================================
155
156// ----------------------------------------------------------------------------
157// wxDialog construction
158// ----------------------------------------------------------------------------
159
b0a6bb75 160void wxDialog::Init()
2bda0e17 161{
52a07708 162 m_oldFocus = (wxWindow *)NULL;
044fe836 163 m_isShown = false;
6757b5e3 164 m_modalData = NULL;
044fe836 165 m_endModalCalled = false;
ec5f0c24
JS
166#if wxUSE_TOOLBAR && defined(__POCKETPC__)
167 m_dialogToolBar = NULL;
168#endif
2bda0e17
KB
169}
170
b3daa5a3
VZ
171bool wxDialog::Create(wxWindow *parent,
172 wxWindowID id,
462e2437
VZ
173 const wxString& title,
174 const wxPoint& pos,
175 const wxSize& size,
176 long style,
177 const wxString& name)
2bda0e17 178{
82c9f85c 179 SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG);
bd9d76cb 180
b225f659 181 // save focus before doing anything which can potentially change it
82c9f85c 182 m_oldFocus = FindFocus();
462e2437 183
706bb5f9 184 // All dialogs should really have this style
b225f659 185 style |= wxTAB_TRAVERSAL;
2bda0e17 186
b225f659 187 if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
044fe836 188 return false;
00233716
VZ
189
190 if ( !m_hasFont )
6f951810 191 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
e1bdd507 192
3180bc0e 193#if defined(__SMARTPHONE__) && defined(__WXWINCE__)
ef6d716b
WS
194 SetLeftMenu(wxID_OK, _("OK"));
195#endif
ec5f0c24
JS
196#if wxUSE_TOOLBAR && defined(__POCKETPC__)
197 CreateToolBar();
198#endif
ef6d716b 199
044fe836 200 return true;
2bda0e17
KB
201}
202
40ff126a
WS
203#if WXWIN_COMPATIBILITY_2_6
204
f46f4c86
VZ
205// deprecated ctor
206wxDialog::wxDialog(wxWindow *parent,
207 const wxString& title,
208 bool WXUNUSED(modal),
209 int x,
210 int y,
211 int w,
212 int h,
213 long style,
214 const wxString& name)
2bda0e17 215{
f46f4c86
VZ
216 Init();
217
d71cc120 218 Create(parent, wxID_ANY, title, wxPoint(x, y), wxSize(w, h), style, name);
f46f4c86
VZ
219}
220
221void wxDialog::SetModal(bool WXUNUSED(flag))
222{
223 // nothing to do, obsolete method
2bda0e17
KB
224}
225
40ff126a
WS
226#endif // WXWIN_COMPATIBILITY_2_6
227
2bda0e17
KB
228wxDialog::~wxDialog()
229{
044fe836 230 m_isBeingDeleted = true;
2bda0e17 231
b0a6bb75 232 // this will also reenable all the other windows for a modal dialog
044fe836 233 Show(false);
2bda0e17
KB
234}
235
b6c588e1
VZ
236// ----------------------------------------------------------------------------
237// showing the dialogs
238// ----------------------------------------------------------------------------
22cf5fec 239
40ff126a
WS
240#if WXWIN_COMPATIBILITY_2_6
241
b6c588e1 242bool wxDialog::IsModalShowing() const
2bda0e17 243{
f46f4c86 244 return IsModal();
2bda0e17
KB
245}
246
40ff126a
WS
247#endif // WXWIN_COMPATIBILITY_2_6
248
a543e3ce
VZ
249wxWindow *wxDialog::FindSuitableParent() const
250{
251 // first try to use the currently active window
252 HWND hwndFg = ::GetForegroundWindow();
253 wxWindow *parent = hwndFg ? wxFindWinFromHandle((WXHWND)hwndFg)
254 : NULL;
255 if ( !parent )
256 {
257 // next try the main app window
258 parent = wxTheApp->GetTopWindow();
259 }
260
261 // finally, check if the parent we found is really suitable
262 if ( !parent || parent == (wxWindow *)this || !parent->IsShown() )
263 {
264 // don't use this one
265 parent = NULL;
266 }
267
268 return parent;
269}
270
b6c588e1 271bool wxDialog::Show(bool show)
2bda0e17 272{
044fe836
VZ
273 if ( show == IsShown() )
274 return false;
275
6757b5e3 276 if ( !show && m_modalData )
86ad564e 277 {
6757b5e3
VZ
278 // we need to do this before calling wxDialogBase version because if we
279 // had disabled other app windows, they must be reenabled right now as
b0a6bb75 280 // if they stay disabled Windows will activate another window (one
6757b5e3
VZ
281 // which is enabled, anyhow) when we're hidden in the base class Show()
282 // and we will lose activation
283 m_modalData->ExitLoop();
86ad564e
JS
284 }
285
044fe836 286 if ( show )
b6c588e1 287 {
044fe836
VZ
288 // this usually will result in TransferDataToWindow() being called
289 // which will change the controls values so do it before showing as
290 // otherwise we could have some flicker
291 InitDialog();
b6c588e1 292 }
2bda0e17 293
044fe836
VZ
294 wxDialogBase::Show(show);
295
b6c588e1
VZ
296 if ( show )
297 {
2b5f62a0
VZ
298 // dialogs don't get WM_SIZE message after creation unlike most (all?)
299 // other windows and so could start their life non laid out correctly
300 // if we didn't call Layout() from here
301 //
302 // NB: normally we should call it just the first time but doing it
303 // every time is simpler than keeping a flag
304 Layout();
b6c588e1 305 }
2bda0e17 306
044fe836 307 return true;
2bda0e17
KB
308}
309
313901f3
JS
310void wxDialog::Raise()
311{
312 ::SetForegroundWindow(GetHwnd());
313}
314
f46f4c86 315// show dialog modally
a23fd0e1 316int wxDialog::ShowModal()
2bda0e17 317{
f46f4c86
VZ
318 wxASSERT_MSG( !IsModal(), _T("wxDialog::ShowModal() reentered?") );
319
044fe836 320 m_endModalCalled = false;
f46f4c86
VZ
321
322 Show();
323
324 // EndModal may have been called from InitDialog handler (called from
325 // inside Show()), which would cause an infinite loop if we didn't take it
326 // into account
327 if ( !m_endModalCalled )
5e1febfa 328 {
f46f4c86
VZ
329 // modal dialog needs a parent window, so try to find one
330 wxWindow *parent = GetParent();
331 if ( !parent )
332 {
333 parent = FindSuitableParent();
334 }
5e1febfa 335
f46f4c86
VZ
336 // remember where the focus was
337 wxWindow *oldFocus = m_oldFocus;
338 if ( !oldFocus )
339 {
340 // VZ: do we really want to do this?
341 oldFocus = parent;
342 }
343
344 // We have to remember the HWND because we need to check
345 // the HWND still exists (oldFocus can be garbage when the dialog
346 // exits, if it has been destroyed)
347 HWND hwndOldFocus = oldFocus ? GetHwndOf(oldFocus) : NULL;
348
349
350 // enter and run the modal loop
351 {
352 wxDialogModalDataTiedPtr modalData(&m_modalData,
353 new wxDialogModalData(this));
354 modalData->RunLoop();
355 }
356
357
358 // and restore focus
359 // Note that this code MUST NOT access the dialog object's data
360 // in case the object has been deleted (which will be the case
361 // for a modal dialog that has been destroyed before calling EndModal).
362 if ( oldFocus && (oldFocus != this) && ::IsWindow(hwndOldFocus))
363 {
364 // This is likely to prove that the object still exists
365 if (wxFindWinFromHandle((WXHWND) hwndOldFocus) == oldFocus)
366 oldFocus->SetFocus();
367 }
368 }
5e1febfa 369
b6c588e1 370 return GetReturnCode();
2bda0e17
KB
371}
372
373void wxDialog::EndModal(int retCode)
374{
f46f4c86
VZ
375 wxASSERT_MSG( IsModal(), _T("EndModal() called for non modal dialog") );
376
044fe836 377 m_endModalCalled = true;
b6c588e1 378 SetReturnCode(retCode);
6a088435 379
12b58624
VZ
380 Hide();
381}
382
383void wxDialog::EndDialog(int rc)
384{
385 if ( IsModal() )
386 EndModal(rc);
387 else
388 Hide();
2bda0e17
KB
389}
390
b6c588e1
VZ
391// ----------------------------------------------------------------------------
392// wxWin event handlers
393// ----------------------------------------------------------------------------
2bda0e17 394
f55fee08
VZ
395bool wxDialog::EmulateButtonClickIfPresent(int id)
396{
397 wxButton *btn = wxDynamicCast(FindWindow(id), wxButton);
398
08f80371 399 if ( !btn || !btn->IsEnabled() || !btn->IsShown() )
f55fee08
VZ
400 return false;
401
402 btn->MSWCommand(BN_CLICKED, 0 /* unused */);
403 return true;
404}
405
2bda0e17 406// Standard buttons
33ac7e6f 407void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
2bda0e17 408{
dc1c4b62
VZ
409 if ( Validate() && TransferDataFromWindow() )
410 {
12b58624 411 EndDialog(wxID_OK);
dc1c4b62 412 }
2bda0e17
KB
413}
414
33ac7e6f 415void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
2bda0e17 416{
b6c588e1
VZ
417 if ( Validate() )
418 TransferDataFromWindow();
419
420 // TODO probably need to disable the Apply button until things change again
2bda0e17
KB
421}
422
33ac7e6f 423void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
2bda0e17 424{
12b58624 425 EndDialog(wxID_CANCEL);
2bda0e17
KB
426}
427
33ac7e6f 428void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
2bda0e17 429{
b6c588e1 430 // We'll send a Cancel message by default, which may close the dialog.
e3065973
JS
431 // Check for looping if the Cancel event handler calls Close().
432
433 // Note that if a cancel button and handler aren't present in the dialog,
434 // nothing will happen when you close the dialog via the window manager, or
b6c588e1
VZ
435 // via Close(). We wouldn't want to destroy the dialog by default, since
436 // the dialog may have been created on the stack. However, this does mean
437 // that calling dialog->Close() won't delete the dialog unless the handler
438 // for wxID_CANCEL does so. So use Destroy() if you want to be sure to
439 // destroy the dialog. The default OnCancel (above) simply ends a modal
440 // dialog, and hides a modeless dialog.
441
442 // VZ: this is horrible and MT-unsafe. Can't we reuse some of these global
443 // lists here? don't dare to change it now, but should be done later!
2bda0e17 444 static wxList closing;
bd9d76cb 445
2bda0e17 446 if ( closing.Member(this) )
e3065973 447 return;
bd9d76cb 448
2bda0e17 449 closing.Append(this);
bd9d76cb 450
387a3b02
JS
451 wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
452 cancelEvent.SetEventObject( this );
e3065973 453 GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog
2bda0e17
KB
454
455 closing.DeleteObject(this);
e3065973 456}
2bda0e17 457
33ac7e6f 458void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
2bda0e17 459{
a756f210 460 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
b6c588e1 461 Refresh();
68ad65f8 462}
42e69d6b 463
9ceeecb9
JS
464#ifdef __POCKETPC__
465// Responds to the OK button in a PocketPC titlebar. This
466// can be overridden, or you can change the id used for
467// sending the event, by calling SetAffirmativeId.
468bool wxDialog::DoOK()
469{
f55fee08
VZ
470 const int idOk = GetAffirmativeId();
471 if ( EmulateButtonClickIfPresent(idOk) )
9ceeecb9 472 return true;
9ceeecb9 473
f55fee08
VZ
474 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetAffirmativeId());
475 event.SetEventObject(this);
476
477 return GetEventHandler()->ProcessEvent(event);
9ceeecb9 478}
f55fee08 479#endif // __POCKETPC__
9ceeecb9 480
ec5f0c24
JS
481#if wxUSE_TOOLBAR && defined(__POCKETPC__)
482// create main toolbar by calling OnCreateToolBar()
483wxToolBar* wxDialog::CreateToolBar(long style, wxWindowID winid, const wxString& name)
484{
485 m_dialogToolBar = OnCreateToolBar(style, winid, name);
486
487 return m_dialogToolBar;
488}
489
490// return a new toolbar
491wxToolBar *wxDialog::OnCreateToolBar(long style,
492 wxWindowID winid,
493 const wxString& name)
494{
495 return new wxToolMenuBar(this, winid,
496 wxDefaultPosition, wxDefaultSize,
497 style, name);
660296aa 498}
ec5f0c24 499#endif
9ceeecb9 500
42e69d6b 501// ---------------------------------------------------------------------------
f55fee08 502// dialog Windows messages processing
42e69d6b
VZ
503// ---------------------------------------------------------------------------
504
f55fee08
VZ
505bool wxDialog::MSWProcessMessage(WXMSG* pMsg)
506{
507 const MSG * const msg = wx_reinterpret_cast(MSG *, pMsg);
508 if ( msg->message == WM_KEYDOWN && msg->wParam == VK_ESCAPE )
509 {
510 int idCancel = GetEscapeId();
511 switch ( idCancel )
512 {
513 case wxID_NONE:
514 // don't handle Esc specially at all
515 break;
516
517 case wxID_ANY:
518 // this value is special: it means translate Esc to wxID_CANCEL
519 // but if there is no such button, then fall back to wxID_OK
520 if ( EmulateButtonClickIfPresent(wxID_CANCEL) )
521 return true;
522 idCancel = wxID_OK;
523 // fall through
524
525 default:
526 // translate Esc to button press for the button with given id
527 if ( EmulateButtonClickIfPresent(idCancel) )
528 return true;
529 }
530 }
531
532 return wxDialogBase::MSWProcessMessage(pMsg);
533}
534
c140b7e7 535WXLRESULT wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
42e69d6b 536{
c140b7e7 537 WXLRESULT rc = 0;
044fe836 538 bool processed = false;
42e69d6b
VZ
539
540 switch ( message )
541 {
0fc58b86
RR
542#ifdef __WXWINCE__
543 // react to pressing the OK button in the title
544 case WM_COMMAND:
ef6d716b
WS
545 {
546 switch ( LOWORD(wParam) )
0fc58b86 547 {
9ceeecb9 548#ifdef __POCKETPC__
ef6d716b 549 case IDOK:
9ceeecb9
JS
550 processed = DoOK();
551 if (!processed)
b554cf63 552 processed = !Close();
9ceeecb9
JS
553#endif
554#ifdef __SMARTPHONE__
ef6d716b
WS
555 case IDM_LEFT:
556 case IDM_RIGHT:
557 processed = HandleCommand( LOWORD(wParam) , 0 , NULL );
0fc58b86 558 break;
ef6d716b 559#endif // __SMARTPHONE__
0fc58b86
RR
560 }
561 break;
ef6d716b 562 }
044fe836 563#endif
42e69d6b
VZ
564 case WM_CLOSE:
565 // if we can't close, tell the system that we processed the
566 // message - otherwise it would close us
567 processed = !Close();
568 break;
abceee76 569
f73f67be
VZ
570 case WM_SIZE:
571 // the Windows dialogs unfortunately are not meant to be resizeable
572 // at all and their standard class doesn't include CS_[VH]REDRAW
573 // styles which means that the window is not refreshed properly
574 // after the resize and no amount of WS_CLIPCHILDREN/SIBLINGS can
575 // help with it - so we have to refresh it manually which certainly
576 // creates flicker but at least doesn't show garbage on the screen
577 rc = wxWindow::MSWWindowProc(message, wParam, lParam);
044fe836 578 processed = true;
e441e1f4 579 if ( HasFlag(wxFULL_REPAINT_ON_RESIZE) )
f73f67be 580 {
044fe836 581 ::InvalidateRect(GetHwnd(), NULL, false /* erase bg */);
f73f67be
VZ
582 }
583 break;
584
04ef50df 585#ifndef __WXMICROWIN__
abceee76
VZ
586 case WM_SETCURSOR:
587 // we want to override the busy cursor for modal dialogs:
588 // typically, wxBeginBusyCursor() is called and then a modal dialog
bfbd6dc1 589 // is shown, but the modal dialog shouldn't have hourglass cursor
f46f4c86 590 if ( IsModal() && wxIsBusy() )
abceee76 591 {
bfbd6dc1
VZ
592 // set our cursor for all windows (but see below)
593 wxCursor cursor = m_cursor;
594 if ( !cursor.Ok() )
595 cursor = wxCURSOR_ARROW;
abceee76 596
bfbd6dc1
VZ
597 ::SetCursor(GetHcursorOf(cursor));
598
599 // in any case, stop here and don't let wxWindow process this
600 // message (it would set the busy cursor)
044fe836 601 processed = true;
bfbd6dc1 602
044fe836 603 // but return false to tell the child window (if the event
bfbd6dc1
VZ
604 // comes from one of them and not from ourselves) that it can
605 // set its own cursor if it has one: thus, standard controls
606 // (e.g. text ctrl) still have correct cursors in a dialog
607 // invoked while wxIsBusy()
044fe836 608 rc = false;
abceee76 609 }
bfbd6dc1 610 break;
82c9f85c 611#endif // __WXMICROWIN__
42e69d6b
VZ
612 }
613
614 if ( !processed )
615 rc = wxWindow::MSWWindowProc(message, wParam, lParam);
616
617 return rc;
618}