]> git.saurik.com Git - wxWidgets.git/blame - src/msw/dialog.cpp
Added missing file
[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$
8// Copyright: (c) Julian Smart and Markus Holzem
dc1c4b62 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
b6c588e1
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
2bda0e17 20#ifdef __GNUG__
b6c588e1 21 #pragma implementation "dialog.h"
2bda0e17
KB
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
b6c588e1 28 #pragma hdrstop
2bda0e17
KB
29#endif
30
31#ifndef WX_PRECOMP
b6c588e1
VZ
32 #include "wx/dialog.h"
33 #include "wx/utils.h"
34 #include "wx/frame.h"
35 #include "wx/app.h"
36 #include "wx/settings.h"
37 #include "wx/intl.h"
38 #include "wx/log.h"
2bda0e17
KB
39#endif
40
41#include "wx/msw/private.h"
dbda9e86 42#include "wx/log.h"
2bda0e17 43
47d67540 44#if wxUSE_COMMON_DIALOGS
b6c588e1 45 #include <commdlg.h>
2bda0e17
KB
46#endif
47
b6c588e1
VZ
48// ----------------------------------------------------------------------------
49// constants
50// ----------------------------------------------------------------------------
51
52// default dialog pos and size
53
2bda0e17
KB
54#define wxDIALOG_DEFAULT_X 300
55#define wxDIALOG_DEFAULT_Y 300
56
b6c588e1
VZ
57#define wxDIALOG_DEFAULT_WIDTH 500
58#define wxDIALOG_DEFAULT_HEIGHT 500
59
60// ----------------------------------------------------------------------------
61// globals
62// ----------------------------------------------------------------------------
63
64// all objects to be deleted during next idle processing - from window.cpp
cde9f08e 65extern wxList WXDLLEXPORT wxPendingDelete;
2bda0e17 66
b6c588e1
VZ
67// all frames and modeless dialogs - not static, used in frame.cpp, mdi.cpp &c
68wxWindowList wxModelessWindows;
69
70// all modal dialogs currently shown
71static wxWindowList wxModalDialogs;
72
73// ----------------------------------------------------------------------------
74// wxWin macros
75// ----------------------------------------------------------------------------
76
1b6452df
VZ
77IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
78
79BEGIN_EVENT_TABLE(wxDialog, wxPanel)
1b6452df
VZ
80 EVT_BUTTON(wxID_OK, wxDialog::OnOK)
81 EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
82 EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
b6c588e1 83
1b6452df 84 EVT_CHAR_HOOK(wxDialog::OnCharHook)
b6c588e1 85
1b6452df 86 EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
b6c588e1 87
1b6452df
VZ
88 EVT_CLOSE(wxDialog::OnCloseWindow)
89END_EVENT_TABLE()
2bda0e17 90
b6c588e1
VZ
91// ============================================================================
92// implementation
93// ============================================================================
94
95// ----------------------------------------------------------------------------
96// wxDialog construction
97// ----------------------------------------------------------------------------
98
b0a6bb75 99void wxDialog::Init()
2bda0e17 100{
52a07708 101 m_oldFocus = (wxWindow *)NULL;
b0a6bb75 102
b6c588e1 103 m_isShown = FALSE;
2bda0e17 104
b0a6bb75
VZ
105 m_windowDisabler = (wxWindowDisabler *)NULL;
106
b6c588e1 107 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
2bda0e17
KB
108}
109
b3daa5a3
VZ
110bool wxDialog::Create(wxWindow *parent,
111 wxWindowID id,
462e2437
VZ
112 const wxString& title,
113 const wxPoint& pos,
114 const wxSize& size,
115 long style,
116 const wxString& name)
2bda0e17 117{
b0a6bb75
VZ
118 Init();
119
abceee76
VZ
120 m_oldFocus = FindFocus();
121
462e2437 122 SetName(name);
bd9d76cb 123
f6bcfd97 124 wxTopLevelWindows.Append(this);
2bda0e17 125
b3daa5a3
VZ
126 if ( parent )
127 parent->AddChild(this);
2bda0e17 128
462e2437
VZ
129 if ( id == -1 )
130 m_windowId = (int)NewControlId();
131 else
132 m_windowId = id;
133
134 int x = pos.x;
135 int y = pos.y;
136 int width = size.x;
137 int height = size.y;
138
b6c588e1
VZ
139 if (x < 0)
140 x = wxDIALOG_DEFAULT_X;
141 if (y < 0)
142 y = wxDIALOG_DEFAULT_Y;
462e2437
VZ
143
144 m_windowStyle = style;
145
462e2437 146 if (width < 0)
b6c588e1 147 width = wxDIALOG_DEFAULT_WIDTH;
462e2437 148 if (height < 0)
b6c588e1 149 height = wxDIALOG_DEFAULT_HEIGHT;
462e2437 150
706bb5f9
JS
151 // All dialogs should really have this style
152 m_windowStyle |= wxTAB_TRAVERSAL;
153
462e2437
VZ
154 WXDWORD extendedStyle = MakeExtendedStyle(m_windowStyle);
155 if (m_windowStyle & wxSTAY_ON_TOP)
156 extendedStyle |= WS_EX_TOPMOST;
157
4204da65
JS
158#ifndef __WIN16__
159 if (m_exStyle & wxDIALOG_EX_CONTEXTHELP)
160 extendedStyle |= WS_EX_CONTEXTHELP;
161#endif
b3daa5a3 162
462e2437
VZ
163 // Allows creation of dialogs with & without captions under MSWindows,
164 // resizeable or not (but a resizeable dialog always has caption -
165 // otherwise it would look too strange)
837e5743 166 const wxChar *dlg;
257bf510 167 if ( style & wxRESIZE_BORDER )
223d09f6 168 dlg = wxT("wxResizeableDialog");
462e2437 169 else if ( style & wxCAPTION )
223d09f6 170 dlg = wxT("wxCaptionDialog");
462e2437 171 else
223d09f6 172 dlg = wxT("wxNoCaptionDialog");
54800df8
JS
173
174#ifdef __WXMICROWIN__
175 extern const wxChar *wxFrameClassName;
176
177 int msflags = WS_OVERLAPPED;
178 if (style & wxCAPTION)
179 msflags |= WS_CAPTION;
180 if (style & wxCLIP_CHILDREN)
181 msflags |= WS_CLIPCHILDREN;
182 if ((style & wxTHICK_FRAME) == 0)
183 msflags |= WS_BORDER;
184 MSWCreate(m_windowId, parent, wxFrameClassName, this, NULL,
185 x, y, width, height,
186 msflags,
187 NULL,
188 extendedStyle);
189
190#else
462e2437
VZ
191 MSWCreate(m_windowId, parent, NULL, this, NULL,
192 x, y, width, height,
193 0, // style is not used if we have dlg template
194 dlg,
195 extendedStyle);
54800df8 196#endif
462e2437 197 HWND hwnd = (HWND)GetHWND();
2bda0e17 198
462e2437
VZ
199 if ( !hwnd )
200 {
f6bcfd97 201 wxFAIL_MSG(_("Failed to create dialog. You probably forgot to include wx/msw/wx.rc in your resources."));
2bda0e17 202
462e2437
VZ
203 return FALSE;
204 }
2bda0e17 205
54800df8 206#ifndef __WXMICROWIN__
462e2437 207 SubclassWin(GetHWND());
54800df8
JS
208#endif
209
462e2437 210 SetWindowText(hwnd, title);
2bda0e17 211
462e2437 212 return TRUE;
2bda0e17
KB
213}
214
c4d305b7
VZ
215bool wxDialog::EnableCloseButton(bool enable)
216{
8cb172b4 217#ifndef __WXMICROWIN__
c4d305b7
VZ
218 // get system (a.k.a. window) menu
219 HMENU hmenu = ::GetSystemMenu(GetHwnd(), FALSE /* get it */);
220 if ( !hmenu )
221 {
222 wxLogLastError(_T("GetSystemMenu"));
223
224 return FALSE;
225 }
226
227 // enabling/disabling the close item from it also automatically
228 // disables/enabling the close title bar button
229 if ( !::EnableMenuItem(hmenu, SC_CLOSE,
230 MF_BYCOMMAND | (enable ? MF_ENABLED : MF_GRAYED)) )
231 {
e6ba3fd4 232 wxLogLastError(_T("EnableMenuItem(SC_CLOSE)"));
c4d305b7
VZ
233
234 return FALSE;
235 }
236
237 // update appearance immediately
238 if ( !::DrawMenuBar(GetHwnd()) )
239 {
240 wxLogLastError(_T("DrawMenuBar"));
241 }
8cb172b4
JS
242#endif
243
c4d305b7
VZ
244 return TRUE;
245}
246
debe6624 247void wxDialog::SetModal(bool flag)
2bda0e17 248{
b6c588e1
VZ
249 if ( flag )
250 {
251 m_windowStyle |= wxDIALOG_MODAL;
252
253 wxModelessWindows.DeleteObject(this);
254 }
255 else
256 {
257 m_windowStyle &= ~wxDIALOG_MODAL;
258
259 wxModelessWindows.Append(this);
260 }
2bda0e17
KB
261}
262
263wxDialog::~wxDialog()
264{
b6c588e1 265 m_isBeingDeleted = TRUE;
2bda0e17 266
b6c588e1 267 wxTopLevelWindows.DeleteObject(this);
2bda0e17 268
b0a6bb75 269 // this will also reenable all the other windows for a modal dialog
b6c588e1 270 Show(FALSE);
edccf428 271
b6c588e1
VZ
272 if ( !IsModal() )
273 wxModelessWindows.DeleteObject(this);
2bda0e17 274
b6c588e1
VZ
275 // If this is the last top-level window, exit.
276 if ( wxTheApp && (wxTopLevelWindows.Number() == 0) )
2bda0e17 277 {
b6c588e1
VZ
278 wxTheApp->SetTopWindow(NULL);
279
280 if ( wxTheApp->GetExitOnFrameDelete() )
281 {
282 ::PostQuitMessage(0);
283 }
2bda0e17 284 }
2bda0e17
KB
285}
286
b6c588e1
VZ
287// ----------------------------------------------------------------------------
288// kbd handling
289// ----------------------------------------------------------------------------
290
2bda0e17
KB
291// By default, pressing escape cancels the dialog
292void wxDialog::OnCharHook(wxKeyEvent& event)
293{
cbc66a27 294 if (GetHWND())
2bda0e17 295 {
cbc66a27
VZ
296 // "Esc" works as an accelerator for the "Cancel" button, but it
297 // shouldn't close the dialog which doesn't have any cancel button
298 if ( (event.m_keyCode == WXK_ESCAPE) && FindWindow(wxID_CANCEL) )
299 {
300 wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
301 cancelEvent.SetEventObject( this );
302 GetEventHandler()->ProcessEvent(cancelEvent);
303
304 // ensure that there is another message for this window so the
305 // ShowModal loop will exit and won't get stuck in GetMessage().
306 ::PostMessage(GetHwnd(), WM_NULL, 0, 0);
307
308 return;
309 }
2bda0e17 310 }
cbc66a27
VZ
311
312 // We didn't process this event.
313 event.Skip();
2bda0e17
KB
314}
315
b6c588e1
VZ
316// ----------------------------------------------------------------------------
317// Windows dialog boxes can't be iconized
318// ----------------------------------------------------------------------------
2bda0e17 319
debe6624 320void wxDialog::Iconize(bool WXUNUSED(iconize))
2bda0e17 321{
2bda0e17
KB
322}
323
a23fd0e1 324bool wxDialog::IsIconized() const
2bda0e17 325{
b6c588e1 326 return FALSE;
2bda0e17
KB
327}
328
b6c588e1
VZ
329// ----------------------------------------------------------------------------
330// size/position handling
331// ----------------------------------------------------------------------------
332
721b32e0 333void wxDialog::DoSetClientSize(int width, int height)
2bda0e17 334{
b6c588e1
VZ
335 HWND hWnd = (HWND) GetHWND();
336 RECT rect;
337 ::GetClientRect(hWnd, &rect);
2bda0e17 338
b6c588e1
VZ
339 RECT rect2;
340 GetWindowRect(hWnd, &rect2);
2bda0e17 341
b6c588e1
VZ
342 // Find the difference between the entire window (title bar and all)
343 // and the client area; add this to the new client size to move the
344 // window
345 int actual_width = rect2.right - rect2.left - rect.right + width;
346 int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
2bda0e17 347
b6c588e1 348 MoveWindow(hWnd, rect2.left, rect2.top, actual_width, actual_height, TRUE);
debe6624 349
b6c588e1
VZ
350 wxSizeEvent event(wxSize(actual_width, actual_height), m_windowId);
351 event.SetEventObject( this );
352 GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
353}
354
b6c588e1 355void wxDialog::DoGetPosition(int *x, int *y) const
2bda0e17 356{
b6c588e1
VZ
357 RECT rect;
358 GetWindowRect(GetHwnd(), &rect);
2bda0e17 359
b6c588e1
VZ
360 if ( x )
361 *x = rect.left;
362 if ( y )
363 *y = rect.top;
2bda0e17
KB
364}
365
b6c588e1
VZ
366// ----------------------------------------------------------------------------
367// showing the dialogs
368// ----------------------------------------------------------------------------
22cf5fec
VZ
369
370bool wxDialog::IsModal() const
371{
b6c588e1 372 return (GetWindowStyleFlag() & wxDIALOG_MODAL) != 0;
2bda0e17
KB
373}
374
b6c588e1 375bool wxDialog::IsModalShowing() const
2bda0e17 376{
b6c588e1 377 return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
2bda0e17
KB
378}
379
b6c588e1 380void wxDialog::DoShowModal()
2bda0e17 381{
b6c588e1 382 wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );
f6bcfd97 383 wxCHECK_RET( IsModal(), _T("can't DoShowModal() modeless dialog") );
b6c588e1
VZ
384
385 wxModalDialogs.Append(this);
386
387 wxWindow *parent = GetParent();
388
f6bcfd97 389 wxWindow* oldFocus = m_oldFocus;
b6c588e1 390
f6bcfd97
BP
391 // We have to remember the HWND because we need to check
392 // the HWND still exists (oldFocus can be garbage when the dialog
393 // exits, if it has been destroyed)
394 HWND hwndOldFocus = 0;
395 if (oldFocus)
396 hwndOldFocus = (HWND) oldFocus->GetHWND();
b6c588e1 397
b0a6bb75
VZ
398 // remember where the focus was
399 if ( !oldFocus )
b6c588e1 400 {
b0a6bb75
VZ
401 oldFocus = parent;
402 if ( parent )
403 hwndOldFocus = GetHwndOf(parent);
404 }
f6bcfd97 405
b0a6bb75
VZ
406 // disable all other app windows
407 wxASSERT_MSG( !m_windowDisabler, _T("disabling windows twice?") );
f6bcfd97 408
b0a6bb75
VZ
409 m_windowDisabler = new wxWindowDisabler(this);
410
411 // enter the modal loop
412 while ( IsModalShowing() )
413 {
b6c588e1 414#if wxUSE_THREADS
b0a6bb75 415 wxMutexGuiLeaveOrEnter();
b6c588e1
VZ
416#endif // wxUSE_THREADS
417
b0a6bb75
VZ
418 while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() )
419 ;
b6c588e1 420
b0a6bb75
VZ
421 // a message came or no more idle processing to do
422 wxTheApp->DoMessage();
b6c588e1
VZ
423 }
424
b6c588e1 425 // and restore focus
f6bcfd97
BP
426 // Note that this code MUST NOT access the dialog object's data
427 // in case the object has been deleted (which will be the case
428 // for a modal dialog that has been destroyed before calling EndModal).
429 if ( oldFocus && (oldFocus != this) && ::IsWindow(hwndOldFocus))
b6c588e1 430 {
f6bcfd97
BP
431 // This is likely to prove that the object still exists
432 if (wxFindWinFromHandle((WXHWND) hwndOldFocus) == oldFocus)
433 oldFocus->SetFocus();
b6c588e1 434 }
2bda0e17
KB
435}
436
b6c588e1 437bool wxDialog::Show(bool show)
2bda0e17 438{
abceee76 439 if ( !show )
86ad564e 440 {
b0a6bb75
VZ
441 // if we had disabled other app windows, reenable them back now because
442 // if they stay disabled Windows will activate another window (one
443 // which is enabled, anyhow) and we will lose activation
444 if ( m_windowDisabler )
86ad564e 445 {
b0a6bb75
VZ
446 delete m_windowDisabler;
447 m_windowDisabler = NULL;
86ad564e
JS
448 }
449 }
450
abceee76
VZ
451 // ShowModal() may be called for already shown dialog
452 if ( !wxDialogBase::Show(show) && !(show && IsModal()) )
b6c588e1
VZ
453 {
454 // nothing to do
455 return FALSE;
456 }
2bda0e17 457
b6c588e1
VZ
458 if ( show )
459 {
460 // usually will result in TransferDataToWindow() being called
461 InitDialog();
462 }
2bda0e17 463
b6c588e1
VZ
464 if ( IsModal() )
465 {
466 if ( show )
467 {
f6bcfd97
BP
468 // modal dialog needs a parent window, so try to find one
469 if ( !GetParent() )
470 {
471 wxWindow *parent = wxTheApp->GetTopWindow();
472 if ( parent && parent != this && parent->IsShown() )
473 {
474 // use it
475 m_parent = parent;
e5f741e5
VZ
476
477 // VZ: to make dialog behave properly we should reparent
478 // the dialog for Windows as well - unfortunately,
479 // following the docs for SetParent() results in this
480 // code which plainly doesn't work
481#if 0
482 long dwStyle = ::GetWindowLong(GetHwnd(), GWL_STYLE);
483 dwStyle &= ~WS_POPUP;
484 dwStyle |= WS_CHILD;
485 ::SetWindowLong(GetHwnd(), GWL_STYLE, dwStyle);
486 ::SetParent(GetHwnd(), GetHwndOf(parent));
487#endif // 0
f6bcfd97
BP
488 }
489 }
490
b6c588e1
VZ
491 DoShowModal();
492 }
493 else // end of modal dialog
494 {
495 // this will cause IsModalShowing() return FALSE and our local
496 // message loop will terminate
497 wxModalDialogs.DeleteObject(this);
498 }
499 }
2bda0e17 500
b6c588e1 501 return TRUE;
2bda0e17
KB
502}
503
f6bcfd97 504// a special version for Show(TRUE) for modal dialogs which returns return code
a23fd0e1 505int wxDialog::ShowModal()
2bda0e17 506{
f6bcfd97 507 if ( !IsModal() )
5e1febfa 508 {
f6bcfd97 509 SetModal(TRUE);
5e1febfa
VZ
510 }
511
b6c588e1 512 Show(TRUE);
5e1febfa 513
b6c588e1 514 return GetReturnCode();
2bda0e17
KB
515}
516
b6c588e1
VZ
517// NB: this function (surprizingly) may be called for both modal and modeless
518// dialogs and should work for both of them
2bda0e17
KB
519void wxDialog::EndModal(int retCode)
520{
b6c588e1 521 SetReturnCode(retCode);
6a088435 522
b6c588e1 523 Show(FALSE);
2bda0e17
KB
524}
525
b6c588e1
VZ
526// ----------------------------------------------------------------------------
527// wxWin event handlers
528// ----------------------------------------------------------------------------
2bda0e17
KB
529
530// Standard buttons
33ac7e6f 531void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
2bda0e17 532{
dc1c4b62
VZ
533 if ( Validate() && TransferDataFromWindow() )
534 {
b6c588e1 535 EndModal(wxID_OK);
dc1c4b62 536 }
2bda0e17
KB
537}
538
33ac7e6f 539void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
2bda0e17 540{
b6c588e1
VZ
541 if ( Validate() )
542 TransferDataFromWindow();
543
544 // TODO probably need to disable the Apply button until things change again
2bda0e17
KB
545}
546
33ac7e6f 547void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
2bda0e17 548{
b6c588e1 549 EndModal(wxID_CANCEL);
2bda0e17
KB
550}
551
33ac7e6f 552void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
2bda0e17 553{
b6c588e1 554 // We'll send a Cancel message by default, which may close the dialog.
e3065973
JS
555 // Check for looping if the Cancel event handler calls Close().
556
557 // Note that if a cancel button and handler aren't present in the dialog,
558 // nothing will happen when you close the dialog via the window manager, or
b6c588e1
VZ
559 // via Close(). We wouldn't want to destroy the dialog by default, since
560 // the dialog may have been created on the stack. However, this does mean
561 // that calling dialog->Close() won't delete the dialog unless the handler
562 // for wxID_CANCEL does so. So use Destroy() if you want to be sure to
563 // destroy the dialog. The default OnCancel (above) simply ends a modal
564 // dialog, and hides a modeless dialog.
565
566 // VZ: this is horrible and MT-unsafe. Can't we reuse some of these global
567 // lists here? don't dare to change it now, but should be done later!
2bda0e17 568 static wxList closing;
bd9d76cb 569
2bda0e17 570 if ( closing.Member(this) )
e3065973 571 return;
bd9d76cb 572
2bda0e17 573 closing.Append(this);
bd9d76cb 574
387a3b02
JS
575 wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
576 cancelEvent.SetEventObject( this );
e3065973 577 GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog
2bda0e17
KB
578
579 closing.DeleteObject(this);
e3065973 580}
2bda0e17 581
e3065973 582// Destroy the window (delayed, if a managed window)
a23fd0e1 583bool wxDialog::Destroy()
e3065973 584{
b6c588e1
VZ
585 wxCHECK_MSG( !wxPendingDelete.Member(this), FALSE,
586 _T("wxDialog destroyed twice") );
587
e3065973 588 wxPendingDelete.Append(this);
2bda0e17 589
b6c588e1 590 return TRUE;
94b49b93
JS
591}
592
33ac7e6f 593void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
2bda0e17 594{
1f112209 595#if wxUSE_CTL3D
b6c588e1 596 Ctl3dColorChange();
2bda0e17 597#else
b6c588e1
VZ
598 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
599 Refresh();
2bda0e17 600#endif
68ad65f8 601}
42e69d6b
VZ
602
603// ---------------------------------------------------------------------------
604// dialog window proc
605// ---------------------------------------------------------------------------
606
607long wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
608{
609 long rc = 0;
610 bool processed = FALSE;
611
612 switch ( message )
613 {
b0a6bb75 614#if 0 // now that we got owner window right it doesn't seem to be needed
5e1febfa
VZ
615 case WM_ACTIVATE:
616 switch ( LOWORD(wParam) )
617 {
618 case WA_ACTIVE:
619 case WA_CLICKACTIVE:
620 if ( IsModalShowing() && GetParent() )
621 {
622 // bring the owner window to top as the standard dialog
623 // boxes do
624 if ( !::SetWindowPos
625 (
626 GetHwndOf(GetParent()),
627 GetHwnd(),
628 0, 0,
629 0, 0,
630 SWP_NOACTIVATE |
631 SWP_NOMOVE |
632 SWP_NOSIZE
633 ) )
634 {
f6bcfd97 635 wxLogLastError(wxT("SetWindowPos(SWP_NOACTIVATE)"));
5e1febfa
VZ
636 }
637 }
638 // fall through to process it normally as well
639 }
640 break;
b0a6bb75 641#endif // 0
5e1febfa 642
42e69d6b
VZ
643 case WM_CLOSE:
644 // if we can't close, tell the system that we processed the
645 // message - otherwise it would close us
646 processed = !Close();
647 break;
abceee76 648
04ef50df 649#ifndef __WXMICROWIN__
abceee76
VZ
650 case WM_SETCURSOR:
651 // we want to override the busy cursor for modal dialogs:
652 // typically, wxBeginBusyCursor() is called and then a modal dialog
bfbd6dc1 653 // is shown, but the modal dialog shouldn't have hourglass cursor
d1477745 654 if ( IsModalShowing() && wxIsBusy() )
abceee76 655 {
bfbd6dc1
VZ
656 // set our cursor for all windows (but see below)
657 wxCursor cursor = m_cursor;
658 if ( !cursor.Ok() )
659 cursor = wxCURSOR_ARROW;
abceee76 660
bfbd6dc1
VZ
661 ::SetCursor(GetHcursorOf(cursor));
662
663 // in any case, stop here and don't let wxWindow process this
664 // message (it would set the busy cursor)
abceee76 665 processed = TRUE;
bfbd6dc1
VZ
666
667 // but return FALSE to tell the child window (if the event
668 // comes from one of them and not from ourselves) that it can
669 // set its own cursor if it has one: thus, standard controls
670 // (e.g. text ctrl) still have correct cursors in a dialog
671 // invoked while wxIsBusy()
672 rc = FALSE;
abceee76 673 }
bfbd6dc1 674 break;
04ef50df 675#endif
42e69d6b
VZ
676 }
677
678 if ( !processed )
679 rc = wxWindow::MSWWindowProc(message, wParam, lParam);
680
681 return rc;
682}
b6c588e1
VZ
683
684#if wxUSE_CTL3D
685
686// Define for each class of dialog and control
687WXHBRUSH wxDialog::OnCtlColor(WXHDC WXUNUSED(pDC),
688 WXHWND WXUNUSED(pWnd),
689 WXUINT WXUNUSED(nCtlColor),
690 WXUINT message,
691 WXWPARAM wParam,
692 WXLPARAM lParam)
693{
694 return (WXHBRUSH)Ctl3dCtlColorEx(message, wParam, lParam);
695}
696
697#endif // wxUSE_CTL3D
698