blob: e00dec68a8183fc50c1871a8221234e3f2818762 [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 Julliard0e607781993-11-03 19:23:37 +000012#include "dialog.h"
13#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 {
210 WND *wnd = WIN_FindWndPtr( hwndFocus );
211
212 if( wnd )
213 {
214 /* always make combo box hide its listbox control */
215
Alexandre Julliarda3960291999-02-26 11:11:13 +0000216 if( WIDGETS_IsControl( wnd, BIC32_COMBO ) )
217 SendMessageA( hwndFocus, CB_SHOWDROPDOWN,
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000218 FALSE, 0 );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000219 else if( WIDGETS_IsControl( wnd, BIC32_EDIT ) &&
220 WIDGETS_IsControl( wnd->parent,
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000221 BIC32_COMBO ))
Alexandre Julliarda3960291999-02-26 11:11:13 +0000222 SendMessageA( wnd->parent->hwndSelf,
223 CB_SHOWDROPDOWN, FALSE, 0 );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000224 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000225 WIN_ReleaseWndPtr(wnd);
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000226 }
227 }
Alexandre Julliarda3960291999-02-26 11:11:13 +0000228 return DefWindowProcA( hwnd, msg, wParam, lParam );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000229
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000230 case WM_GETFONT:
231 return dlgInfo->hUserFont;
232
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000233 case WM_CLOSE:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000234 PostMessageA( hwnd, WM_COMMAND, IDCANCEL,
235 (LPARAM)GetDlgItem( hwnd, IDCANCEL ) );
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000236 return 0;
Luc Tourangeau5591bc61999-04-01 10:10:24 +0000237
238 case WM_NOTIFYFORMAT:
239 return DefWindowProcA( hwnd, msg, wParam, lParam );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000240 }
241 return 0;
242}
243
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000244/***********************************************************************
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000245 * DEFDLG_Epilog
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000246 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000247static LRESULT DEFDLG_Epilog(DIALOGINFO* dlgInfo, UINT msg, BOOL fResult)
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000248{
249 /* see SDK 3.1 */
250
251 if ((msg >= WM_CTLCOLORMSGBOX && msg <= WM_CTLCOLORSTATIC) ||
252 msg == WM_CTLCOLOR || msg == WM_COMPAREITEM ||
253 msg == WM_VKEYTOITEM || msg == WM_CHARTOITEM ||
254 msg == WM_QUERYDRAGICON || msg == WM_INITDIALOG)
255 return fResult;
256
257 return dlgInfo->msgResult;
258}
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000259
260/***********************************************************************
261 * DefDlgProc16 (USER.308)
262 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000263LRESULT WINAPI DefDlgProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
264 LPARAM lParam )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000265{
266 DIALOGINFO * dlgInfo;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000267 BOOL result = FALSE;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000268 WND * wndPtr = WIN_FindWndPtr( hwnd );
269
270 if (!wndPtr) return 0;
271 dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000272 dlgInfo->msgResult = 0;
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000273
Tim Newsomee7cdbb01998-11-01 13:04:43 +0000274 if (dlgInfo->dlgProc) { /* Call dialog procedure */
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000275 result = CallWindowProc16( (WNDPROC16)dlgInfo->dlgProc,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000276 hwnd, msg, wParam, lParam );
NF Stevense365a231999-01-03 16:13:08 +0000277 /* 16 bit dlg procs only return BOOL16 */
278 if( WINPROC_GetProcType( dlgInfo->dlgProc ) == WIN_PROC_16 )
279 result = LOWORD(result);
Tim Newsomee7cdbb01998-11-01 13:04:43 +0000280 }
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +0000281
Alexandre Julliarda3960291999-02-26 11:11:13 +0000282 if (!result && IsWindow(hwnd))
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000283 {
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000284 /* callback didn't process this message */
Alexandre Julliarde2abbb11995-03-19 17:39:39 +0000285
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000286 switch(msg)
287 {
288 case WM_ERASEBKGND:
289 case WM_SHOWWINDOW:
290 case WM_ACTIVATE:
291 case WM_SETFOCUS:
292 case DM_SETDEFID:
293 case DM_GETDEFID:
294 case WM_NEXTDLGCTL:
295 case WM_GETFONT:
296 case WM_CLOSE:
297 case WM_NCDESTROY:
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000298 case WM_ENTERMENULOOP:
299 case WM_LBUTTONDOWN:
300 case WM_NCLBUTTONDOWN:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000301 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000302 return DEFDLG_Proc( (HWND)hwnd, msg,
303 (WPARAM)wParam, lParam, dlgInfo );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000304 case WM_INITDIALOG:
305 case WM_VKEYTOITEM:
306 case WM_COMPAREITEM:
307 case WM_CHARTOITEM:
308 break;
309
310 default:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000311 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000312 return DefWindowProc16( hwnd, msg, wParam, lParam );
313 }
314 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000315 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000316 return DEFDLG_Epilog(dlgInfo, msg, result);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000317}
318
319
320/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000321 * DefDlgProcA (USER32.120)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000322 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000323LRESULT WINAPI DefDlgProcA( HWND hwnd, UINT msg,
324 WPARAM wParam, LPARAM lParam )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000325{
326 DIALOGINFO * dlgInfo;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000327 BOOL result = FALSE;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000328 WND * wndPtr = WIN_FindWndPtr( hwnd );
329
330 if (!wndPtr) return 0;
331 dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000332 dlgInfo->msgResult = 0;
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000333
Tim Newsomee7cdbb01998-11-01 13:04:43 +0000334 if (dlgInfo->dlgProc) { /* Call dialog procedure */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000335 result = CallWindowProcA( (WNDPROC)dlgInfo->dlgProc,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000336 hwnd, msg, wParam, lParam );
NF Stevense365a231999-01-03 16:13:08 +0000337 /* 16 bit dlg procs only return BOOL16 */
338 if( WINPROC_GetProcType( dlgInfo->dlgProc ) == WIN_PROC_16 )
339 result = LOWORD(result);
Tim Newsomee7cdbb01998-11-01 13:04:43 +0000340 }
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +0000341
Alexandre Julliarda3960291999-02-26 11:11:13 +0000342 if (!result && IsWindow(hwnd))
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000343 {
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000344 /* callback didn't process this message */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000345
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000346 switch(msg)
347 {
348 case WM_ERASEBKGND:
349 case WM_SHOWWINDOW:
350 case WM_ACTIVATE:
351 case WM_SETFOCUS:
352 case DM_SETDEFID:
353 case DM_GETDEFID:
354 case WM_NEXTDLGCTL:
355 case WM_GETFONT:
356 case WM_CLOSE:
357 case WM_NCDESTROY:
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000358 case WM_ENTERMENULOOP:
359 case WM_LBUTTONDOWN:
360 case WM_NCLBUTTONDOWN:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000361 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000362 return DEFDLG_Proc( (HWND)hwnd, msg,
363 (WPARAM)wParam, lParam, dlgInfo );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000364 case WM_INITDIALOG:
365 case WM_VKEYTOITEM:
366 case WM_COMPAREITEM:
367 case WM_CHARTOITEM:
368 break;
369
370 default:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000371 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000372 return DefWindowProcA( hwnd, msg, wParam, lParam );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000373 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000374 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000375 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000376 return DEFDLG_Epilog(dlgInfo, msg, result);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000377}
378
379
380/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000381 * DefDlgProcW (USER32.121)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000382 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000383LRESULT WINAPI DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000384 LPARAM lParam )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000385{
386 DIALOGINFO * dlgInfo;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000387 BOOL result = FALSE;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000388 WND * wndPtr = WIN_FindWndPtr( hwnd );
389
390 if (!wndPtr) return 0;
391 dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000392 dlgInfo->msgResult = 0;
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000393
Tim Newsomee7cdbb01998-11-01 13:04:43 +0000394 if (dlgInfo->dlgProc) { /* Call dialog procedure */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000395 result = CallWindowProcW( (WNDPROC)dlgInfo->dlgProc,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000396 hwnd, msg, wParam, lParam );
NF Stevense365a231999-01-03 16:13:08 +0000397 /* 16 bit dlg procs only return BOOL16 */
398 if( WINPROC_GetProcType( dlgInfo->dlgProc ) == WIN_PROC_16 )
399 result = LOWORD(result);
Tim Newsomee7cdbb01998-11-01 13:04:43 +0000400 }
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +0000401
Alexandre Julliarda3960291999-02-26 11:11:13 +0000402 if (!result && IsWindow(hwnd))
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000403 {
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000404 /* callback didn't process this message */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000405
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000406 switch(msg)
407 {
408 case WM_ERASEBKGND:
409 case WM_SHOWWINDOW:
410 case WM_ACTIVATE:
411 case WM_SETFOCUS:
412 case DM_SETDEFID:
413 case DM_GETDEFID:
414 case WM_NEXTDLGCTL:
415 case WM_GETFONT:
416 case WM_CLOSE:
417 case WM_NCDESTROY:
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000418 case WM_ENTERMENULOOP:
419 case WM_LBUTTONDOWN:
420 case WM_NCLBUTTONDOWN:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000421 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000422 return DEFDLG_Proc( (HWND)hwnd, msg,
423 (WPARAM)wParam, lParam, dlgInfo );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000424 case WM_INITDIALOG:
425 case WM_VKEYTOITEM:
426 case WM_COMPAREITEM:
427 case WM_CHARTOITEM:
428 break;
429
430 default:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000431 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000432 return DefWindowProcW( hwnd, msg, wParam, lParam );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000433 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000434 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000435 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000436 return DEFDLG_Epilog(dlgInfo, msg, result);
Alexandre Julliard0e607781993-11-03 19:23:37 +0000437}