blob: fc16d1ba08b2d78ed163052e5277d1c1fe6b2f48 [file] [log] [blame]
Alexandre Julliard0e607781993-11-03 19:23:37 +00001/*
2 * Default dialog procedure
3 *
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00004 * Copyright 1993, 1996 Alexandre Julliard
Alexandre Julliard234bc241994-12-10 13:02:28 +00005 *
Alexandre Julliard59730ae1996-03-24 16:20:51 +00006 */
Alexandre Julliard0e607781993-11-03 19:23:37 +00007
Jeremy Whited3e22d92000-02-10 19:03:02 +00008#include "windef.h"
Patrik Stridvall6cc47d42000-03-08 18:26:56 +00009#include "winbase.h"
Jeremy Whited3e22d92000-02-10 19:03:02 +000010#include "wingdi.h"
Michael Vekslerca1bc861999-01-01 18:57:33 +000011#include "wine/winuser16.h"
Alexandre Julliard91222da2000-12-10 23:01:33 +000012#include "controls.h"
Alexandre Julliard0e607781993-11-03 19:23:37 +000013#include "win.h"
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000014#include "winproc.h"
15
Alexandre Julliardaca05781994-10-17 18:12:41 +000016
Alexandre Julliardaca05781994-10-17 18:12:41 +000017/***********************************************************************
18 * DEFDLG_SetFocus
19 *
20 * Set the focus to a control of the dialog, selecting the text if
21 * the control is an edit dialog.
22 */
Alexandre Julliarda3960291999-02-26 11:11:13 +000023static void DEFDLG_SetFocus( HWND hwndDlg, HWND hwndCtrl )
Alexandre Julliardaca05781994-10-17 18:12:41 +000024{
Alexandre Julliarda3960291999-02-26 11:11:13 +000025 HWND hwndPrev = GetFocus();
Alexandre Julliardaca05781994-10-17 18:12:41 +000026
Alexandre Julliarda3960291999-02-26 11:11:13 +000027 if (IsChild( hwndDlg, hwndPrev ))
Alexandre Julliardaca05781994-10-17 18:12:41 +000028 {
Alexandre Julliard2d93d001996-05-21 15:01:41 +000029 if (SendMessage16( hwndPrev, WM_GETDLGCODE, 0, 0 ) & DLGC_HASSETSEL)
Alexandre Julliardc6c09441997-01-12 18:32:19 +000030 SendMessage16( hwndPrev, EM_SETSEL16, TRUE, MAKELONG( -1, 0 ) );
Alexandre Julliardaca05781994-10-17 18:12:41 +000031 }
Alexandre Julliard2d93d001996-05-21 15:01:41 +000032 if (SendMessage16( hwndCtrl, WM_GETDLGCODE, 0, 0 ) & DLGC_HASSETSEL)
Alexandre Julliardc6c09441997-01-12 18:32:19 +000033 SendMessage16( hwndCtrl, EM_SETSEL16, FALSE, MAKELONG( 0, -1 ) );
Alexandre Julliarda3960291999-02-26 11:11:13 +000034 SetFocus( hwndCtrl );
Alexandre Julliardaca05781994-10-17 18:12:41 +000035}
36
37
38/***********************************************************************
39 * DEFDLG_SaveFocus
40 */
Alexandre Julliarda3960291999-02-26 11:11:13 +000041static BOOL DEFDLG_SaveFocus( HWND hwnd, DIALOGINFO *infoPtr )
Alexandre Julliardaca05781994-10-17 18:12:41 +000042{
Alexandre Julliarda3960291999-02-26 11:11:13 +000043 HWND hwndFocus = GetFocus();
Alexandre Julliardaca05781994-10-17 18:12:41 +000044
Alexandre Julliarda3960291999-02-26 11:11:13 +000045 if (!hwndFocus || !IsChild( hwnd, hwndFocus )) return FALSE;
Alexandre Julliardaca05781994-10-17 18:12:41 +000046 infoPtr->hwndFocus = hwndFocus;
47 /* Remove default button */
48 return TRUE;
49}
50
51
52/***********************************************************************
53 * DEFDLG_RestoreFocus
54 */
Alexandre Julliarda3960291999-02-26 11:11:13 +000055static BOOL DEFDLG_RestoreFocus( HWND hwnd, DIALOGINFO *infoPtr )
Alexandre Julliardaca05781994-10-17 18:12:41 +000056{
Alexandre Julliarda3960291999-02-26 11:11:13 +000057 if (!infoPtr->hwndFocus || IsIconic(hwnd)) return FALSE;
58 if (!IsWindow( infoPtr->hwndFocus )) return FALSE;
Abey George15c58c41999-08-07 14:10:04 +000059
60 /* Don't set the focus back to controls if EndDialog is already called.*/
61 if (!(infoPtr->flags & DF_END))
62 DEFDLG_SetFocus( hwnd, infoPtr->hwndFocus );
63
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000064 /* This used to set infoPtr->hwndFocus to NULL for no apparent reason,
65 sometimes losing focus when receiving WM_SETFOCUS messages. */
Alexandre Julliardaca05781994-10-17 18:12:41 +000066 return TRUE;
67}
68
69
70/***********************************************************************
71 * DEFDLG_FindDefButton
72 *
73 * Find the current default push-button.
74 */
Alexandre Julliarda3960291999-02-26 11:11:13 +000075static HWND DEFDLG_FindDefButton( HWND hwndDlg )
Alexandre Julliardaca05781994-10-17 18:12:41 +000076{
Alexandre Julliarda3960291999-02-26 11:11:13 +000077 HWND hwndChild = GetWindow( hwndDlg, GW_CHILD );
Alexandre Julliardaca05781994-10-17 18:12:41 +000078 while (hwndChild)
79 {
Alexandre Julliard2d93d001996-05-21 15:01:41 +000080 if (SendMessage16( hwndChild, WM_GETDLGCODE, 0, 0 ) & DLGC_DEFPUSHBUTTON)
Alexandre Julliardaca05781994-10-17 18:12:41 +000081 break;
Alexandre Julliarda3960291999-02-26 11:11:13 +000082 hwndChild = GetWindow( hwndChild, GW_HWNDNEXT );
Alexandre Julliardaca05781994-10-17 18:12:41 +000083 }
84 return hwndChild;
85}
86
87
88/***********************************************************************
89 * DEFDLG_SetDefButton
90 *
91 * Set the new default button to be hwndNew.
92 */
Alexandre Julliarda3960291999-02-26 11:11:13 +000093static BOOL DEFDLG_SetDefButton( HWND hwndDlg, DIALOGINFO *dlgInfo,
94 HWND hwndNew )
Alexandre Julliardaca05781994-10-17 18:12:41 +000095{
96 if (hwndNew &&
Alexandre Julliard2d93d001996-05-21 15:01:41 +000097 !(SendMessage16(hwndNew, WM_GETDLGCODE, 0, 0 ) & DLGC_UNDEFPUSHBUTTON))
Alexandre Julliardaca05781994-10-17 18:12:41 +000098 return FALSE; /* Destination is not a push button */
99
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +0000100 if (dlgInfo->idResult) /* There's already a default pushbutton */
Alexandre Julliardaca05781994-10-17 18:12:41 +0000101 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000102 HWND hwndOld = GetDlgItem( hwndDlg, dlgInfo->idResult );
103 if (SendMessageA( hwndOld, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
104 SendMessageA( hwndOld, BM_SETSTYLE, BS_PUSHBUTTON, TRUE );
Alexandre Julliardaca05781994-10-17 18:12:41 +0000105 }
106 if (hwndNew)
107 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000108 SendMessageA( hwndNew, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
109 dlgInfo->idResult = GetDlgCtrlID( hwndNew );
Alexandre Julliardaca05781994-10-17 18:12:41 +0000110 }
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +0000111 else dlgInfo->idResult = 0;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000112 return TRUE;
113}
Alexandre Julliard0e607781993-11-03 19:23:37 +0000114
115
116/***********************************************************************
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000117 * DEFDLG_Proc
118 *
119 * Implementation of DefDlgProc(). Only handle messages that need special
120 * handling for dialogs.
Alexandre Julliard0e607781993-11-03 19:23:37 +0000121 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000122static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000123 LPARAM lParam, DIALOGINFO *dlgInfo )
Alexandre Julliard0e607781993-11-03 19:23:37 +0000124{
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000125 switch(msg)
Alexandre Julliard0e607781993-11-03 19:23:37 +0000126 {
Alexandre Julliard0e607781993-11-03 19:23:37 +0000127 case WM_ERASEBKGND:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000128 FillWindow16( hwnd, hwnd, (HDC16)wParam, (HBRUSH16)CTLCOLOR_DLG );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000129 return 1;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000130
131 case WM_NCDESTROY:
132
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +0000133 /* Free dialog heap (if created) */
134 if (dlgInfo->hDialogHeap)
135 {
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000136 GlobalUnlock16(dlgInfo->hDialogHeap);
137 GlobalFree16(dlgInfo->hDialogHeap);
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +0000138 dlgInfo->hDialogHeap = 0;
139 }
140
Alexandre Julliard0e607781993-11-03 19:23:37 +0000141 /* Delete font */
142 if (dlgInfo->hUserFont)
143 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000144 DeleteObject( dlgInfo->hUserFont );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000145 dlgInfo->hUserFont = 0;
146 }
147
148 /* Delete menu */
149 if (dlgInfo->hMenu)
150 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000151 DestroyMenu( dlgInfo->hMenu );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000152 dlgInfo->hMenu = 0;
153 }
154
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000155 /* Delete window procedure */
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000156 WINPROC_FreeProc( dlgInfo->dlgProc, WIN_PROC_WINDOW );
Alexandre Julliard3051b641996-07-05 17:14:13 +0000157 dlgInfo->dlgProc = (HWINDOWPROC)0;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000158 dlgInfo->flags |= DF_END; /* just in case */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000159
Alexandre Julliard0e607781993-11-03 19:23:37 +0000160 /* Window clean-up */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000161 return DefWindowProcA( hwnd, msg, wParam, lParam );
Alexandre Julliardaca05781994-10-17 18:12:41 +0000162
163 case WM_SHOWWINDOW:
164 if (!wParam) DEFDLG_SaveFocus( hwnd, dlgInfo );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000165 return DefWindowProcA( hwnd, msg, wParam, lParam );
Alexandre Julliardaca05781994-10-17 18:12:41 +0000166
167 case WM_ACTIVATE:
168 if (wParam) DEFDLG_RestoreFocus( hwnd, dlgInfo );
169 else DEFDLG_SaveFocus( hwnd, dlgInfo );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000170 return 0;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000171
172 case WM_SETFOCUS:
173 DEFDLG_RestoreFocus( hwnd, dlgInfo );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000174 return 0;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000175
176 case DM_SETDEFID:
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000177 if (dlgInfo->flags & DF_END) return 1;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000178 DEFDLG_SetDefButton( hwnd, dlgInfo,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000179 wParam ? GetDlgItem( hwnd, wParam ) : 0 );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000180 return 1;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000181
182 case DM_GETDEFID:
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000183 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000184 HWND hwndDefId;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000185 if (dlgInfo->flags & DF_END) return 0;
186 if (dlgInfo->idResult)
187 return MAKELONG( dlgInfo->idResult, DC_HASDEFID );
188 if ((hwndDefId = DEFDLG_FindDefButton( hwnd )))
Alexandre Julliarda3960291999-02-26 11:11:13 +0000189 return MAKELONG( GetDlgCtrlID( hwndDefId ), DC_HASDEFID);
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000190 }
Alexandre Julliardf1aa3031996-08-05 17:42:43 +0000191 return 0;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000192
193 case WM_NEXTDLGCTL:
194 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000195 HWND hwndDest = (HWND)wParam;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000196 if (!lParam)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000197 hwndDest = GetNextDlgTabItem(hwnd, GetFocus(), wParam);
Alexandre Julliardaca05781994-10-17 18:12:41 +0000198 if (hwndDest) DEFDLG_SetFocus( hwnd, hwndDest );
199 DEFDLG_SetDefButton( hwnd, dlgInfo, hwndDest );
200 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000201 return 0;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000202
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000203 case WM_ENTERMENULOOP:
204 case WM_LBUTTONDOWN:
205 case WM_NCLBUTTONDOWN:
206 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000207 HWND hwndFocus = GetFocus();
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000208 if (hwndFocus)
209 {
Alexandre Julliardb83a16c2000-12-07 23:24:41 +0000210 /* always make combo box hide its listbox control */
211 if (!SendMessageA( hwndFocus, CB_SHOWDROPDOWN, FALSE, 0 ))
212 SendMessageA( GetParent(hwndFocus), CB_SHOWDROPDOWN, FALSE, 0 );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000213 }
214 }
Alexandre Julliarda3960291999-02-26 11:11:13 +0000215 return DefWindowProcA( hwnd, msg, wParam, lParam );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000216
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000217 case WM_GETFONT:
218 return dlgInfo->hUserFont;
219
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000220 case WM_CLOSE:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000221 PostMessageA( hwnd, WM_COMMAND, IDCANCEL,
222 (LPARAM)GetDlgItem( hwnd, IDCANCEL ) );
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000223 return 0;
Luc Tourangeau5591bc61999-04-01 10:10:24 +0000224
225 case WM_NOTIFYFORMAT:
226 return DefWindowProcA( hwnd, msg, wParam, lParam );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000227 }
228 return 0;
229}
230
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000231/***********************************************************************
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000232 * DEFDLG_Epilog
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000233 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000234static LRESULT DEFDLG_Epilog(DIALOGINFO* dlgInfo, UINT msg, BOOL fResult)
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000235{
236 /* see SDK 3.1 */
237
238 if ((msg >= WM_CTLCOLORMSGBOX && msg <= WM_CTLCOLORSTATIC) ||
239 msg == WM_CTLCOLOR || msg == WM_COMPAREITEM ||
240 msg == WM_VKEYTOITEM || msg == WM_CHARTOITEM ||
241 msg == WM_QUERYDRAGICON || msg == WM_INITDIALOG)
242 return fResult;
243
244 return dlgInfo->msgResult;
245}
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000246
247/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000248 * DefDlgProc (USER.308)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000249 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000250LRESULT WINAPI DefDlgProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
251 LPARAM lParam )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000252{
253 DIALOGINFO * dlgInfo;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000254 BOOL result = FALSE;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000255 WND * wndPtr = WIN_FindWndPtr( hwnd );
256
257 if (!wndPtr) return 0;
258 dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000259 dlgInfo->msgResult = 0;
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000260
Tim Newsomee7cdbb01998-11-01 13:04:43 +0000261 if (dlgInfo->dlgProc) { /* Call dialog procedure */
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000262 result = CallWindowProc16( (WNDPROC16)dlgInfo->dlgProc,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000263 hwnd, msg, wParam, lParam );
NF Stevense365a231999-01-03 16:13:08 +0000264 /* 16 bit dlg procs only return BOOL16 */
265 if( WINPROC_GetProcType( dlgInfo->dlgProc ) == WIN_PROC_16 )
266 result = LOWORD(result);
Tim Newsomee7cdbb01998-11-01 13:04:43 +0000267 }
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +0000268
Alexandre Julliarda3960291999-02-26 11:11:13 +0000269 if (!result && IsWindow(hwnd))
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000270 {
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000271 /* callback didn't process this message */
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000272
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000273 switch(msg)
274 {
275 case WM_ERASEBKGND:
276 case WM_SHOWWINDOW:
277 case WM_ACTIVATE:
278 case WM_SETFOCUS:
279 case DM_SETDEFID:
280 case DM_GETDEFID:
281 case WM_NEXTDLGCTL:
282 case WM_GETFONT:
283 case WM_CLOSE:
284 case WM_NCDESTROY:
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000285 case WM_ENTERMENULOOP:
286 case WM_LBUTTONDOWN:
287 case WM_NCLBUTTONDOWN:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000288 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000289 return DEFDLG_Proc( (HWND)hwnd, msg,
290 (WPARAM)wParam, lParam, dlgInfo );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000291 case WM_INITDIALOG:
292 case WM_VKEYTOITEM:
293 case WM_COMPAREITEM:
294 case WM_CHARTOITEM:
295 break;
296
297 default:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000298 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000299 return DefWindowProc16( hwnd, msg, wParam, lParam );
300 }
301 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000302 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000303 return DEFDLG_Epilog(dlgInfo, msg, result);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000304}
305
306
307/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000308 * DefDlgProcA (USER32.@)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000309 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000310LRESULT WINAPI DefDlgProcA( HWND hwnd, UINT msg,
311 WPARAM wParam, LPARAM lParam )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000312{
313 DIALOGINFO * dlgInfo;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000314 BOOL result = FALSE;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000315 WND * wndPtr = WIN_FindWndPtr( hwnd );
316
317 if (!wndPtr) return 0;
318 dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000319 dlgInfo->msgResult = 0;
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000320
Tim Newsomee7cdbb01998-11-01 13:04:43 +0000321 if (dlgInfo->dlgProc) { /* Call dialog procedure */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000322 result = CallWindowProcA( (WNDPROC)dlgInfo->dlgProc,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000323 hwnd, msg, wParam, lParam );
NF Stevense365a231999-01-03 16:13:08 +0000324 /* 16 bit dlg procs only return BOOL16 */
325 if( WINPROC_GetProcType( dlgInfo->dlgProc ) == WIN_PROC_16 )
326 result = LOWORD(result);
Tim Newsomee7cdbb01998-11-01 13:04:43 +0000327 }
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +0000328
Alexandre Julliarda3960291999-02-26 11:11:13 +0000329 if (!result && IsWindow(hwnd))
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000330 {
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000331 /* callback didn't process this message */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000332
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000333 switch(msg)
334 {
335 case WM_ERASEBKGND:
336 case WM_SHOWWINDOW:
337 case WM_ACTIVATE:
338 case WM_SETFOCUS:
339 case DM_SETDEFID:
340 case DM_GETDEFID:
341 case WM_NEXTDLGCTL:
342 case WM_GETFONT:
343 case WM_CLOSE:
344 case WM_NCDESTROY:
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000345 case WM_ENTERMENULOOP:
346 case WM_LBUTTONDOWN:
347 case WM_NCLBUTTONDOWN:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000348 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000349 return DEFDLG_Proc( (HWND)hwnd, msg,
350 (WPARAM)wParam, lParam, dlgInfo );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000351 case WM_INITDIALOG:
352 case WM_VKEYTOITEM:
353 case WM_COMPAREITEM:
354 case WM_CHARTOITEM:
355 break;
356
357 default:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000358 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000359 return DefWindowProcA( hwnd, msg, wParam, lParam );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000360 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000361 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000362 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000363 return DEFDLG_Epilog(dlgInfo, msg, result);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000364}
365
366
367/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000368 * DefDlgProcW (USER32.@)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000369 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000370LRESULT WINAPI DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000371 LPARAM lParam )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000372{
373 DIALOGINFO * dlgInfo;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000374 BOOL result = FALSE;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000375 WND * wndPtr = WIN_FindWndPtr( hwnd );
376
377 if (!wndPtr) return 0;
378 dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000379 dlgInfo->msgResult = 0;
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000380
Tim Newsomee7cdbb01998-11-01 13:04:43 +0000381 if (dlgInfo->dlgProc) { /* Call dialog procedure */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000382 result = CallWindowProcW( (WNDPROC)dlgInfo->dlgProc,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000383 hwnd, msg, wParam, lParam );
NF Stevense365a231999-01-03 16:13:08 +0000384 /* 16 bit dlg procs only return BOOL16 */
385 if( WINPROC_GetProcType( dlgInfo->dlgProc ) == WIN_PROC_16 )
386 result = LOWORD(result);
Tim Newsomee7cdbb01998-11-01 13:04:43 +0000387 }
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +0000388
Alexandre Julliarda3960291999-02-26 11:11:13 +0000389 if (!result && IsWindow(hwnd))
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000390 {
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000391 /* callback didn't process this message */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000392
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000393 switch(msg)
394 {
395 case WM_ERASEBKGND:
396 case WM_SHOWWINDOW:
397 case WM_ACTIVATE:
398 case WM_SETFOCUS:
399 case DM_SETDEFID:
400 case DM_GETDEFID:
401 case WM_NEXTDLGCTL:
402 case WM_GETFONT:
403 case WM_CLOSE:
404 case WM_NCDESTROY:
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000405 case WM_ENTERMENULOOP:
406 case WM_LBUTTONDOWN:
407 case WM_NCLBUTTONDOWN:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000408 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000409 return DEFDLG_Proc( (HWND)hwnd, msg,
410 (WPARAM)wParam, lParam, dlgInfo );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000411 case WM_INITDIALOG:
412 case WM_VKEYTOITEM:
413 case WM_COMPAREITEM:
414 case WM_CHARTOITEM:
415 break;
416
417 default:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000418 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000419 return DefWindowProcW( hwnd, msg, wParam, lParam );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000420 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000421 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000422 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000423 return DEFDLG_Epilog(dlgInfo, msg, result);
Alexandre Julliard0e607781993-11-03 19:23:37 +0000424}