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