Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Dialog functions |
| 3 | * |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 4 | * Copyright 1993, 1994, 1996 Alexandre Julliard |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 19 | */ |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 20 | |
François Gouget | 1425941 | 2001-11-06 20:57:11 +0000 | [diff] [blame] | 21 | #include "config.h" |
Francois Gouget | 386cf6e | 2001-10-14 16:25:47 +0000 | [diff] [blame] | 22 | #include "wine/port.h" |
| 23 | |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 24 | #include <ctype.h> |
Patrik Stridvall | 1e1cf48 | 1998-10-17 12:56:00 +0000 | [diff] [blame] | 25 | #include <errno.h> |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 26 | #include <limits.h> |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 27 | #include <stdlib.h> |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 28 | #include <stdio.h> |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 29 | #include <string.h> |
François Gouget | 44a1822 | 2000-12-19 04:53:20 +0000 | [diff] [blame] | 30 | |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 31 | #include "windef.h" |
Alexandre Julliard | 24a62ab | 2000-11-28 22:40:56 +0000 | [diff] [blame] | 32 | #include "winnls.h" |
François Gouget | 44a1822 | 2000-12-19 04:53:20 +0000 | [diff] [blame] | 33 | #include "winbase.h" |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 34 | #include "wingdi.h" |
Marcus Meissner | 61afa33 | 1999-02-22 10:16:00 +0000 | [diff] [blame] | 35 | #include "winuser.h" |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 36 | #include "windowsx.h" |
Marcus Meissner | 61afa33 | 1999-02-22 10:16:00 +0000 | [diff] [blame] | 37 | #include "wine/winuser16.h" |
| 38 | #include "wine/winbase16.h" |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 39 | #include "wine/unicode.h" |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 40 | #include "controls.h" |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 41 | #include "heap.h" |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 42 | #include "win.h" |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 43 | #include "user.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 44 | #include "wine/debug.h" |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 45 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 46 | WINE_DEFAULT_DEBUG_CHANNEL(dialog); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 47 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 48 | |
| 49 | /* Dialog control information */ |
| 50 | typedef struct |
| 51 | { |
| 52 | DWORD style; |
| 53 | DWORD exStyle; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 54 | DWORD helpId; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 55 | INT16 x; |
| 56 | INT16 y; |
| 57 | INT16 cx; |
| 58 | INT16 cy; |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 59 | UINT id; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 60 | LPCSTR className; |
| 61 | LPCSTR windowName; |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 62 | LPCVOID data; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 63 | } DLG_CONTROL_INFO; |
| 64 | |
| 65 | /* Dialog template */ |
| 66 | typedef struct |
| 67 | { |
| 68 | DWORD style; |
| 69 | DWORD exStyle; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 70 | DWORD helpId; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 71 | UINT16 nbItems; |
| 72 | INT16 x; |
| 73 | INT16 y; |
| 74 | INT16 cx; |
| 75 | INT16 cy; |
| 76 | LPCSTR menuName; |
| 77 | LPCSTR className; |
| 78 | LPCSTR caption; |
| 79 | WORD pointSize; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 80 | WORD weight; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 81 | BOOL italic; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 82 | LPCSTR faceName; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 83 | BOOL dialogEx; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 84 | } DLG_TEMPLATE; |
| 85 | |
Luc Tourangeau | 8e238d0 | 1999-05-29 14:19:42 +0000 | [diff] [blame] | 86 | /* Radio button group */ |
| 87 | typedef struct |
| 88 | { |
| 89 | UINT firstID; |
| 90 | UINT lastID; |
| 91 | UINT checkID; |
| 92 | } RADIOGROUP; |
| 93 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 94 | /* Dialog base units */ |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 95 | static WORD xBaseUnit = 0, yBaseUnit = 0; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 96 | |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 97 | |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 98 | /********************************************************************* |
| 99 | * dialog class descriptor |
| 100 | */ |
| 101 | const struct builtin_class_descr DIALOG_builtin_class = |
| 102 | { |
| 103 | DIALOG_CLASS_ATOM, /* name */ |
| 104 | CS_GLOBALCLASS | CS_SAVEBITS, /* style */ |
| 105 | DefDlgProcA, /* procA */ |
| 106 | DefDlgProcW, /* procW */ |
| 107 | DLGWINDOWEXTRA, /* extra */ |
| 108 | IDC_ARROWA, /* cursor */ |
| 109 | 0 /* brush */ |
| 110 | }; |
| 111 | |
| 112 | |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 113 | /*********************************************************************** |
| 114 | * DIALOG_EnableOwner |
| 115 | * |
| 116 | * Helper function for modal dialogs to enable again the |
| 117 | * owner of the dialog box. |
| 118 | */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 119 | void DIALOG_EnableOwner( HWND hOwner ) |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 120 | { |
| 121 | /* Owner must be a top-level window */ |
| 122 | if (hOwner) |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 123 | hOwner = GetAncestor( hOwner, GA_ROOT ); |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 124 | if (!hOwner) return; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 125 | EnableWindow( hOwner, TRUE ); |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | |
| 129 | /*********************************************************************** |
| 130 | * DIALOG_DisableOwner |
| 131 | * |
| 132 | * Helper function for modal dialogs to disable the |
| 133 | * owner of the dialog box. Returns TRUE if owner was enabled. |
| 134 | */ |
| 135 | BOOL DIALOG_DisableOwner( HWND hOwner ) |
| 136 | { |
| 137 | /* Owner must be a top-level window */ |
| 138 | if (hOwner) |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 139 | hOwner = GetAncestor( hOwner, GA_ROOT ); |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 140 | if (!hOwner) return FALSE; |
| 141 | if (IsWindowEnabled( hOwner )) |
| 142 | { |
| 143 | EnableWindow( hOwner, FALSE ); |
| 144 | return TRUE; |
| 145 | } |
| 146 | else |
| 147 | return FALSE; |
| 148 | } |
| 149 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 150 | /*********************************************************************** |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 151 | * DIALOG_GetCharSizeFromDC |
| 152 | * |
Huw D M Davies | 79fdd84 | 2002-04-03 20:06:04 +0000 | [diff] [blame] | 153 | * Despite most of MSDN insisting that the horizontal base unit is |
| 154 | * tmAveCharWidth it isn't. Knowledge base article Q145994 |
| 155 | * "HOWTO: Calculate Dialog Units When Not Using the System Font", |
| 156 | * says that we should take the average of the 52 English upper and lower |
| 157 | * case characters. |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 158 | */ |
| 159 | static BOOL DIALOG_GetCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize ) |
| 160 | { |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 161 | HFONT hFontPrev = 0; |
Huw D M Davies | 79fdd84 | 2002-04-03 20:06:04 +0000 | [diff] [blame] | 162 | char *alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
| 163 | SIZE sz; |
| 164 | TEXTMETRICA tm; |
| 165 | |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 166 | pSize->cx = xBaseUnit; |
| 167 | pSize->cy = yBaseUnit; |
Huw D M Davies | 79fdd84 | 2002-04-03 20:06:04 +0000 | [diff] [blame] | 168 | |
| 169 | if(!hDC) return FALSE; |
| 170 | |
| 171 | if(hFont) hFontPrev = SelectFont(hDC, hFont); |
| 172 | if(!GetTextMetricsA(hDC, &tm)) return FALSE; |
| 173 | if(!GetTextExtentPointA(hDC, alphabet, 52, &sz)) return FALSE; |
| 174 | |
| 175 | pSize->cy = tm.tmHeight; |
| 176 | pSize->cx = (sz.cx / 26 + 1) / 2; |
| 177 | |
| 178 | if (hFontPrev) SelectFont(hDC, hFontPrev); |
| 179 | |
| 180 | TRACE("dlg base units: %ld x %ld\n", pSize->cx, pSize->cy); |
| 181 | return TRUE; |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 182 | } |
| 183 | |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 184 | /*********************************************************************** |
| 185 | * DIALOG_GetCharSize |
| 186 | * |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 187 | * A convenient variant of DIALOG_GetCharSizeFromDC. |
| 188 | */ |
| 189 | static BOOL DIALOG_GetCharSize( HFONT hFont, SIZE * pSize ) |
| 190 | { |
| 191 | HDC hDC = GetDC(0); |
| 192 | BOOL Success = DIALOG_GetCharSizeFromDC( hDC, hFont, pSize ); |
| 193 | ReleaseDC(0, hDC); |
| 194 | return Success; |
| 195 | } |
| 196 | |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 197 | /*********************************************************************** |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 198 | * DIALOG_Init |
| 199 | * |
| 200 | * Initialisation of the dialog manager. |
| 201 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 202 | BOOL DIALOG_Init(void) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 203 | { |
Alexandre Julliard | b0efe28 | 2000-08-04 04:18:04 +0000 | [diff] [blame] | 204 | HDC hdc; |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 205 | SIZE size; |
| 206 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 207 | /* Calculate the dialog base units */ |
| 208 | |
Dmitry Timoshkov | 75b25be | 2000-10-31 01:01:41 +0000 | [diff] [blame] | 209 | if (!(hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL ))) |
| 210 | { |
| 211 | ERR("Could not create Display DC\n"); |
| 212 | return FALSE; |
| 213 | } |
| 214 | |
| 215 | if (!DIALOG_GetCharSizeFromDC( hdc, 0, &size )) |
| 216 | { |
| 217 | DeleteDC( hdc ); |
| 218 | ERR("Could not initialize base dialog units\n"); |
| 219 | return FALSE; |
| 220 | } |
| 221 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 222 | DeleteDC( hdc ); |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 223 | xBaseUnit = size.cx; |
| 224 | yBaseUnit = size.cy; |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 225 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 226 | TRACE("base units = %d,%d\n", xBaseUnit, yBaseUnit ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 227 | return TRUE; |
| 228 | } |
| 229 | |
| 230 | |
| 231 | /*********************************************************************** |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 232 | * DIALOG_GetControl16 |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 233 | * |
| 234 | * Return the class and text of the control pointed to by ptr, |
Alexandre Julliard | 329f068 | 1996-04-14 13:21:20 +0000 | [diff] [blame] | 235 | * fill the header structure and return a pointer to the next control. |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 236 | */ |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 237 | static LPCSTR DIALOG_GetControl16( LPCSTR p, DLG_CONTROL_INFO *info ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 238 | { |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 239 | static char buffer[10]; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 240 | int int_id; |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 241 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 242 | info->x = GET_WORD(p); p += sizeof(WORD); |
| 243 | info->y = GET_WORD(p); p += sizeof(WORD); |
| 244 | info->cx = GET_WORD(p); p += sizeof(WORD); |
| 245 | info->cy = GET_WORD(p); p += sizeof(WORD); |
| 246 | info->id = GET_WORD(p); p += sizeof(WORD); |
| 247 | info->style = GET_DWORD(p); p += sizeof(DWORD); |
| 248 | info->exStyle = 0; |
Alexandre Julliard | 7e50df3 | 1994-08-06 11:22:41 +0000 | [diff] [blame] | 249 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 250 | if (*p & 0x80) |
| 251 | { |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 252 | switch((BYTE)*p) |
| 253 | { |
| 254 | case 0x80: strcpy( buffer, "BUTTON" ); break; |
| 255 | case 0x81: strcpy( buffer, "EDIT" ); break; |
| 256 | case 0x82: strcpy( buffer, "STATIC" ); break; |
| 257 | case 0x83: strcpy( buffer, "LISTBOX" ); break; |
| 258 | case 0x84: strcpy( buffer, "SCROLLBAR" ); break; |
| 259 | case 0x85: strcpy( buffer, "COMBOBOX" ); break; |
| 260 | default: buffer[0] = '\0'; break; |
| 261 | } |
| 262 | info->className = buffer; |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 263 | p++; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 264 | } |
| 265 | else |
| 266 | { |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 267 | info->className = p; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 268 | p += strlen(p) + 1; |
| 269 | } |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 270 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 271 | int_id = ((BYTE)*p == 0xff); |
| 272 | if (int_id) |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 273 | { |
| 274 | /* Integer id, not documented (?). Only works for SS_ICON controls */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 275 | info->windowName = (LPCSTR)(UINT)GET_WORD(p+1); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 276 | p += 3; |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 277 | } |
| 278 | else |
| 279 | { |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 280 | info->windowName = p; |
| 281 | p += strlen(p) + 1; |
Alexandre Julliard | 7e50df3 | 1994-08-06 11:22:41 +0000 | [diff] [blame] | 282 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 283 | |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 284 | if (*p) info->data = p + 1; |
Bernd Herd | 5b60bf0 | 2000-05-11 00:05:22 +0000 | [diff] [blame] | 285 | else info->data = NULL; |
| 286 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 287 | p += *p + 1; |
| 288 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 289 | if(int_id) |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 290 | TRACE(" %s %04x %d, %d, %d, %d, %d, %08lx, %p\n", |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 291 | info->className, LOWORD(info->windowName), |
| 292 | info->id, info->x, info->y, info->cx, info->cy, |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 293 | info->style, info->data ); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 294 | else |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 295 | TRACE(" %s '%s' %d, %d, %d, %d, %d, %08lx, %p\n", |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 296 | info->className, info->windowName, |
| 297 | info->id, info->x, info->y, info->cx, info->cy, |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 298 | info->style, info->data ); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 299 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 300 | return p; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | |
| 304 | /*********************************************************************** |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 305 | * DIALOG_GetControl32 |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 306 | * |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 307 | * Return the class and text of the control pointed to by ptr, |
| 308 | * fill the header structure and return a pointer to the next control. |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 309 | */ |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 310 | static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 311 | BOOL dialogEx ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 312 | { |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 313 | if (dialogEx) |
| 314 | { |
| 315 | info->helpId = GET_DWORD(p); p += 2; |
| 316 | info->exStyle = GET_DWORD(p); p += 2; |
| 317 | info->style = GET_DWORD(p); p += 2; |
| 318 | } |
| 319 | else |
| 320 | { |
| 321 | info->helpId = 0; |
| 322 | info->style = GET_DWORD(p); p += 2; |
| 323 | info->exStyle = GET_DWORD(p); p += 2; |
| 324 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 325 | info->x = GET_WORD(p); p++; |
| 326 | info->y = GET_WORD(p); p++; |
| 327 | info->cx = GET_WORD(p); p++; |
| 328 | info->cy = GET_WORD(p); p++; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 329 | |
| 330 | if (dialogEx) |
| 331 | { |
| 332 | /* id is a DWORD for DIALOGEX */ |
| 333 | info->id = GET_DWORD(p); |
| 334 | p += 2; |
| 335 | } |
| 336 | else |
| 337 | { |
| 338 | info->id = GET_WORD(p); |
| 339 | p++; |
| 340 | } |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 341 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 342 | if (GET_WORD(p) == 0xffff) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 343 | { |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 344 | static const WCHAR class_names[6][10] = |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 345 | { |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 346 | { 'B','u','t','t','o','n', }, /* 0x80 */ |
| 347 | { 'E','d','i','t', }, /* 0x81 */ |
| 348 | { 'S','t','a','t','i','c', }, /* 0x82 */ |
| 349 | { 'L','i','s','t','B','o','x', }, /* 0x83 */ |
| 350 | { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */ |
| 351 | { 'C','o','m','b','o','B','o','x', } /* 0x85 */ |
| 352 | }; |
| 353 | WORD id = GET_WORD(p+1); |
| 354 | if ((id >= 0x80) && (id <= 0x85)) |
| 355 | info->className = (LPCSTR)class_names[id - 0x80]; |
| 356 | else |
| 357 | { |
| 358 | info->className = NULL; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 359 | ERR("Unknown built-in class id %04x\n", id ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 360 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 361 | p += 2; |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 362 | } |
| 363 | else |
| 364 | { |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 365 | info->className = (LPCSTR)p; |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 366 | p += strlenW( (LPCWSTR)p ) + 1; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 367 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 368 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 369 | if (GET_WORD(p) == 0xffff) /* Is it an integer id? */ |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 370 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 371 | info->windowName = (LPCSTR)(UINT)GET_WORD(p + 1); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 372 | p += 2; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 373 | } |
| 374 | else |
| 375 | { |
| 376 | info->windowName = (LPCSTR)p; |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 377 | p += strlenW( (LPCWSTR)p ) + 1; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 378 | } |
| 379 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 380 | TRACE(" %s %s %d, %d, %d, %d, %d, %08lx, %08lx, %08lx\n", |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 381 | debugstr_w( (LPCWSTR)info->className ), |
| 382 | debugres_w( (LPCWSTR)info->windowName ), |
| 383 | info->id, info->x, info->y, info->cx, info->cy, |
| 384 | info->style, info->exStyle, info->helpId ); |
| 385 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 386 | if (GET_WORD(p)) |
| 387 | { |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 388 | if (TRACE_ON(dialog)) |
| 389 | { |
| 390 | WORD i, count = GET_WORD(p) / sizeof(WORD); |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 391 | TRACE(" BEGIN\n"); |
| 392 | TRACE(" "); |
| 393 | for (i = 0; i < count; i++) DPRINTF( "%04x,", GET_WORD(p+i+1) ); |
| 394 | DPRINTF("\n"); |
| 395 | TRACE(" END\n" ); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 396 | } |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 397 | info->data = p + 1; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 398 | p += GET_WORD(p) / sizeof(WORD); |
| 399 | } |
| 400 | else info->data = NULL; |
| 401 | p++; |
| 402 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 403 | /* Next control is on dword boundary */ |
| 404 | return (const WORD *)((((int)p) + 3) & ~3); |
| 405 | } |
| 406 | |
| 407 | |
| 408 | /*********************************************************************** |
| 409 | * DIALOG_CreateControls |
| 410 | * |
| 411 | * Create the control windows for a dialog. |
| 412 | */ |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 413 | static BOOL DIALOG_CreateControls( HWND hwnd, LPCSTR template, const DLG_TEMPLATE *dlgTemplate, |
| 414 | HINSTANCE hInst, BOOL win32 ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 415 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 416 | DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 417 | DLG_CONTROL_INFO info; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 418 | HWND hwndCtrl, hwndDefButton = 0; |
| 419 | INT items = dlgTemplate->nbItems; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 420 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 421 | TRACE(" BEGIN\n" ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 422 | while (items--) |
| 423 | { |
| 424 | if (!win32) |
| 425 | { |
| 426 | HINSTANCE16 instance; |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 427 | SEGPTR segptr; |
| 428 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 429 | template = DIALOG_GetControl16( template, &info ); |
| 430 | if (HIWORD(info.className) && !strcmp( info.className, "EDIT") && |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 431 | !(GetWindowLongW( hwnd, GWL_STYLE ) & DS_LOCALEDIT)) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 432 | { |
| 433 | if (!dlgInfo->hDialogHeap) |
| 434 | { |
| 435 | dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000); |
| 436 | if (!dlgInfo->hDialogHeap) |
| 437 | { |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 438 | ERR("Insufficient memory to create heap for edit control\n" ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 439 | continue; |
| 440 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 441 | LocalInit16(dlgInfo->hDialogHeap, 0, 0xffff); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 442 | } |
| 443 | instance = dlgInfo->hDialogHeap; |
| 444 | } |
| 445 | else instance = (HINSTANCE16)hInst; |
| 446 | |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 447 | segptr = MapLS( info.data ); |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 448 | hwndCtrl = WIN_Handle32( CreateWindowEx16( info.exStyle | WS_EX_NOPARENTNOTIFY, |
| 449 | info.className, info.windowName, |
| 450 | info.style | WS_CHILD, |
| 451 | MulDiv(info.x, dlgInfo->xBaseUnit, 4), |
| 452 | MulDiv(info.y, dlgInfo->yBaseUnit, 8), |
| 453 | MulDiv(info.cx, dlgInfo->xBaseUnit, 4), |
| 454 | MulDiv(info.cy, dlgInfo->yBaseUnit, 8), |
| 455 | WIN_Handle16(hwnd), (HMENU16)info.id, |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 456 | instance, (LPVOID)segptr )); |
| 457 | UnMapLS( segptr ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 458 | } |
| 459 | else |
| 460 | { |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 461 | template = (LPCSTR)DIALOG_GetControl32( (WORD *)template, &info, |
| 462 | dlgTemplate->dialogEx ); |
Bill Medland | 137420a | 2001-07-11 17:26:33 +0000 | [diff] [blame] | 463 | /* Is this it? */ |
| 464 | if (info.style & WS_BORDER) |
| 465 | { |
| 466 | info.style &= ~WS_BORDER; |
| 467 | info.exStyle |= WS_EX_CLIENTEDGE; |
| 468 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 469 | hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY, |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 470 | (LPCWSTR)info.className, |
| 471 | (LPCWSTR)info.windowName, |
| 472 | info.style | WS_CHILD, |
Francis Beaudet | eb13dd4 | 1999-09-03 15:14:27 +0000 | [diff] [blame] | 473 | MulDiv(info.x, dlgInfo->xBaseUnit, 4), |
| 474 | MulDiv(info.y, dlgInfo->yBaseUnit, 8), |
| 475 | MulDiv(info.cx, dlgInfo->xBaseUnit, 4), |
| 476 | MulDiv(info.cy, dlgInfo->yBaseUnit, 8), |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 477 | hwnd, (HMENU)info.id, |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 478 | hInst, (LPVOID)info.data ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 479 | } |
| 480 | if (!hwndCtrl) return FALSE; |
| 481 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 482 | /* Send initialisation messages to the control */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 483 | if (dlgInfo->hUserFont) SendMessageA( hwndCtrl, WM_SETFONT, |
| 484 | (WPARAM)dlgInfo->hUserFont, 0 ); |
| 485 | if (SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 486 | { |
| 487 | /* If there's already a default push-button, set it back */ |
| 488 | /* to normal and use this one instead. */ |
| 489 | if (hwndDefButton) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 490 | SendMessageA( hwndDefButton, BM_SETSTYLE, |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 491 | BS_PUSHBUTTON,FALSE ); |
| 492 | hwndDefButton = hwndCtrl; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 493 | dlgInfo->idResult = GetWindowLongA( hwndCtrl, GWL_ID ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 494 | } |
| 495 | } |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 496 | TRACE(" END\n" ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 497 | return TRUE; |
| 498 | } |
| 499 | |
| 500 | |
| 501 | /*********************************************************************** |
| 502 | * DIALOG_ParseTemplate16 |
| 503 | * |
| 504 | * Fill a DLG_TEMPLATE structure from the dialog template, and return |
| 505 | * a pointer to the first control. |
| 506 | */ |
| 507 | static LPCSTR DIALOG_ParseTemplate16( LPCSTR p, DLG_TEMPLATE * result ) |
| 508 | { |
| 509 | result->style = GET_DWORD(p); p += sizeof(DWORD); |
| 510 | result->exStyle = 0; |
Pavel Roskin | 4b5f876 | 1999-06-12 08:11:32 +0000 | [diff] [blame] | 511 | result->nbItems = (unsigned char) *p++; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 512 | result->x = GET_WORD(p); p += sizeof(WORD); |
| 513 | result->y = GET_WORD(p); p += sizeof(WORD); |
| 514 | result->cx = GET_WORD(p); p += sizeof(WORD); |
| 515 | result->cy = GET_WORD(p); p += sizeof(WORD); |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 516 | TRACE("DIALOG %d, %d, %d, %d\n", |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 517 | result->x, result->y, result->cx, result->cy ); |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 518 | TRACE(" STYLE %08lx\n", result->style ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 519 | |
| 520 | /* Get the menu name */ |
| 521 | |
| 522 | switch( (BYTE)*p ) |
| 523 | { |
| 524 | case 0: |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 525 | result->menuName = 0; |
| 526 | p++; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 527 | break; |
| 528 | case 0xff: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 529 | result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 530 | p += 3; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 531 | TRACE(" MENU %04x\n", LOWORD(result->menuName) ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 532 | break; |
| 533 | default: |
| 534 | result->menuName = p; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 535 | TRACE(" MENU '%s'\n", p ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 536 | p += strlen(p) + 1; |
| 537 | break; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 538 | } |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 539 | |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 540 | /* Get the class name */ |
| 541 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 542 | if (*p) |
| 543 | { |
| 544 | result->className = p; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 545 | TRACE(" CLASS '%s'\n", result->className ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 546 | } |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 547 | else result->className = DIALOG_CLASS_ATOM; |
| 548 | p += strlen(p) + 1; |
| 549 | |
| 550 | /* Get the window caption */ |
| 551 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 552 | result->caption = p; |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 553 | p += strlen(p) + 1; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 554 | TRACE(" CAPTION '%s'\n", result->caption ); |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 555 | |
| 556 | /* Get the font name */ |
| 557 | |
Alexandre Julliard | 329f068 | 1996-04-14 13:21:20 +0000 | [diff] [blame] | 558 | if (result->style & DS_SETFONT) |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 559 | { |
Alexandre Julliard | 329f068 | 1996-04-14 13:21:20 +0000 | [diff] [blame] | 560 | result->pointSize = GET_WORD(p); |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 561 | p += sizeof(WORD); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 562 | result->faceName = p; |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 563 | p += strlen(p) + 1; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 564 | TRACE(" FONT %d,'%s'\n", |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 565 | result->pointSize, result->faceName ); |
| 566 | } |
| 567 | return p; |
| 568 | } |
| 569 | |
| 570 | |
| 571 | /*********************************************************************** |
| 572 | * DIALOG_ParseTemplate32 |
| 573 | * |
| 574 | * Fill a DLG_TEMPLATE structure from the dialog template, and return |
| 575 | * a pointer to the first control. |
| 576 | */ |
| 577 | static LPCSTR DIALOG_ParseTemplate32( LPCSTR template, DLG_TEMPLATE * result ) |
| 578 | { |
| 579 | const WORD *p = (const WORD *)template; |
| 580 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 581 | result->style = GET_DWORD(p); p += 2; |
| 582 | if (result->style == 0xffff0001) /* DIALOGEX resource */ |
| 583 | { |
| 584 | result->dialogEx = TRUE; |
| 585 | result->helpId = GET_DWORD(p); p += 2; |
| 586 | result->exStyle = GET_DWORD(p); p += 2; |
| 587 | result->style = GET_DWORD(p); p += 2; |
| 588 | } |
| 589 | else |
| 590 | { |
| 591 | result->dialogEx = FALSE; |
| 592 | result->helpId = 0; |
| 593 | result->exStyle = GET_DWORD(p); p += 2; |
| 594 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 595 | result->nbItems = GET_WORD(p); p++; |
| 596 | result->x = GET_WORD(p); p++; |
| 597 | result->y = GET_WORD(p); p++; |
| 598 | result->cx = GET_WORD(p); p++; |
| 599 | result->cy = GET_WORD(p); p++; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 600 | TRACE("DIALOG%s %d, %d, %d, %d, %ld\n", |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 601 | result->dialogEx ? "EX" : "", result->x, result->y, |
| 602 | result->cx, result->cy, result->helpId ); |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 603 | TRACE(" STYLE 0x%08lx\n", result->style ); |
| 604 | TRACE(" EXSTYLE 0x%08lx\n", result->exStyle ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 605 | |
| 606 | /* Get the menu name */ |
| 607 | |
| 608 | switch(GET_WORD(p)) |
| 609 | { |
| 610 | case 0x0000: |
| 611 | result->menuName = NULL; |
| 612 | p++; |
| 613 | break; |
| 614 | case 0xffff: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 615 | result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 616 | p += 2; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 617 | TRACE(" MENU %04x\n", LOWORD(result->menuName) ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 618 | break; |
| 619 | default: |
| 620 | result->menuName = (LPCSTR)p; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 621 | TRACE(" MENU %s\n", debugstr_w( (LPCWSTR)p )); |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 622 | p += strlenW( (LPCWSTR)p ) + 1; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 623 | break; |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 624 | } |
| 625 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 626 | /* Get the class name */ |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 627 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 628 | switch(GET_WORD(p)) |
| 629 | { |
| 630 | case 0x0000: |
| 631 | result->className = DIALOG_CLASS_ATOM; |
| 632 | p++; |
| 633 | break; |
| 634 | case 0xffff: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 635 | result->className = (LPCSTR)(UINT)GET_WORD( p + 1 ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 636 | p += 2; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 637 | TRACE(" CLASS %04x\n", LOWORD(result->className) ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 638 | break; |
| 639 | default: |
| 640 | result->className = (LPCSTR)p; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 641 | TRACE(" CLASS %s\n", debugstr_w( (LPCWSTR)p )); |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 642 | p += strlenW( (LPCWSTR)p ) + 1; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 643 | break; |
| 644 | } |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 645 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 646 | /* Get the window caption */ |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 647 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 648 | result->caption = (LPCSTR)p; |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 649 | p += strlenW( (LPCWSTR)p ) + 1; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 650 | TRACE(" CAPTION %s\n", debugstr_w( (LPCWSTR)result->caption ) ); |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 651 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 652 | /* Get the font name */ |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 653 | |
Alexandre Julliard | 329f068 | 1996-04-14 13:21:20 +0000 | [diff] [blame] | 654 | if (result->style & DS_SETFONT) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 655 | { |
| 656 | result->pointSize = GET_WORD(p); |
| 657 | p++; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 658 | if (result->dialogEx) |
| 659 | { |
| 660 | result->weight = GET_WORD(p); p++; |
| 661 | result->italic = LOBYTE(GET_WORD(p)); p++; |
| 662 | } |
| 663 | else |
| 664 | { |
| 665 | result->weight = FW_DONTCARE; |
| 666 | result->italic = FALSE; |
| 667 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 668 | result->faceName = (LPCSTR)p; |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 669 | p += strlenW( (LPCWSTR)p ) + 1; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 670 | TRACE(" FONT %d, %s, %d, %s\n", |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 671 | result->pointSize, debugstr_w( (LPCWSTR)result->faceName ), |
| 672 | result->weight, result->italic ? "TRUE" : "FALSE" ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 673 | } |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 674 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 675 | /* First control is on dword boundary */ |
| 676 | return (LPCSTR)((((int)p) + 3) & ~3); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 677 | } |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 678 | |
| 679 | |
| 680 | /*********************************************************************** |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 681 | * DIALOG_CreateIndirect |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 682 | * Creates a dialog box window |
| 683 | * |
| 684 | * modal = TRUE if we are called from a modal dialog box. |
| 685 | * (it's more compatible to do it here, as under Windows the owner |
| 686 | * is never disabled if the dialog fails because of an invalid template) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 687 | */ |
Gerard Patel | e3bd8d0 | 2000-08-18 23:05:44 +0000 | [diff] [blame] | 688 | static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCSTR dlgTemplate, |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 689 | HWND owner, DLGPROC dlgProc, LPARAM param, |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 690 | WINDOWPROCTYPE procType, BOOL modal ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 691 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 692 | HWND hwnd; |
| 693 | RECT rect; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 694 | WND * wndPtr; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 695 | DLG_TEMPLATE template; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 696 | DIALOGINFO * dlgInfo; |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 697 | BOOL ownerEnabled = TRUE; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 698 | BOOL win32Template = (procType != WIN_PROC_16); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 699 | |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 700 | /* Parse dialog template */ |
| 701 | |
| 702 | if (!dlgTemplate) return 0; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 703 | if (win32Template) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 704 | dlgTemplate = DIALOG_ParseTemplate32( dlgTemplate, &template ); |
| 705 | else |
| 706 | dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 707 | |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 708 | /* Initialise dialog extra data */ |
| 709 | |
| 710 | if (!(dlgInfo = HeapAlloc( GetProcessHeap(), 0, sizeof(*dlgInfo) ))) return 0; |
| 711 | dlgInfo->hwndFocus = 0; |
| 712 | dlgInfo->hUserFont = 0; |
| 713 | dlgInfo->hMenu = 0; |
| 714 | dlgInfo->xBaseUnit = xBaseUnit; |
| 715 | dlgInfo->yBaseUnit = yBaseUnit; |
| 716 | dlgInfo->idResult = 0; |
| 717 | dlgInfo->flags = 0; |
| 718 | dlgInfo->hDialogHeap = 0; |
| 719 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 720 | /* Load menu */ |
| 721 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 722 | if (template.menuName) |
| 723 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 724 | if (!win32Template) dlgInfo->hMenu = LoadMenu16( hInst, template.menuName ); |
| 725 | else dlgInfo->hMenu = LoadMenuW( hInst, (LPCWSTR)template.menuName ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 726 | } |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 727 | |
| 728 | /* Create custom font if needed */ |
| 729 | |
Alexandre Julliard | 329f068 | 1996-04-14 13:21:20 +0000 | [diff] [blame] | 730 | if (template.style & DS_SETFONT) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 731 | { |
Huw D M Davies | 79fdd84 | 2002-04-03 20:06:04 +0000 | [diff] [blame] | 732 | /* We convert the size to pixels and then make it -ve. This works |
| 733 | * for both +ve and -ve template.pointSize */ |
Gerard Patel | 6e8519b | 2000-12-18 03:11:10 +0000 | [diff] [blame] | 734 | HDC dc; |
| 735 | int pixels; |
Huw D M Davies | 79fdd84 | 2002-04-03 20:06:04 +0000 | [diff] [blame] | 736 | dc = GetDC(0); |
| 737 | pixels = MulDiv(template.pointSize, GetDeviceCaps(dc , LOGPIXELSY), 72); |
| 738 | ReleaseDC(0, dc); |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 739 | if (win32Template) |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 740 | dlgInfo->hUserFont = CreateFontW( -pixels, 0, 0, 0, template.weight, |
| 741 | template.italic, FALSE, FALSE, DEFAULT_CHARSET, 0, 0, |
| 742 | PROOF_QUALITY, FF_DONTCARE, |
| 743 | (LPCWSTR)template.faceName ); |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 744 | else |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 745 | dlgInfo->hUserFont = CreateFontA( -pixels, 0, 0, 0, FW_DONTCARE, |
| 746 | FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0, |
| 747 | PROOF_QUALITY, FF_DONTCARE, template.faceName ); |
| 748 | if (dlgInfo->hUserFont) |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 749 | { |
| 750 | SIZE charSize; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 751 | if (DIALOG_GetCharSize( dlgInfo->hUserFont, &charSize )) |
Slava Monich | e6dd5d1 | 2000-07-08 18:27:24 +0000 | [diff] [blame] | 752 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 753 | dlgInfo->xBaseUnit = charSize.cx; |
| 754 | dlgInfo->yBaseUnit = charSize.cy; |
Slava Monich | e6dd5d1 | 2000-07-08 18:27:24 +0000 | [diff] [blame] | 755 | } |
Slava Monich | 3a170a1 | 1999-06-06 09:03:08 +0000 | [diff] [blame] | 756 | } |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 757 | TRACE("units = %d,%d\n", dlgInfo->xBaseUnit, dlgInfo->yBaseUnit ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 758 | } |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 759 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 760 | /* Create dialog main window */ |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 761 | |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 762 | rect.left = rect.top = 0; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 763 | rect.right = MulDiv(template.cx, dlgInfo->xBaseUnit, 4); |
| 764 | rect.bottom = MulDiv(template.cy, dlgInfo->yBaseUnit, 8); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 765 | if (template.style & DS_MODALFRAME) |
| 766 | template.exStyle |= WS_EX_DLGMODALFRAME; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 767 | AdjustWindowRectEx( &rect, template.style, (dlgInfo->hMenu != 0), template.exStyle ); |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 768 | rect.right -= rect.left; |
| 769 | rect.bottom -= rect.top; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 770 | |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 771 | if ((INT16)template.x == CW_USEDEFAULT16) |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 772 | { |
Ulrich Weigand | f03c936 | 1999-07-10 13:08:50 +0000 | [diff] [blame] | 773 | rect.left = rect.top = win32Template? CW_USEDEFAULT : CW_USEDEFAULT16; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 774 | } |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 775 | else |
| 776 | { |
Dave Pickles | fcc9d13 | 1998-10-10 15:52:46 +0000 | [diff] [blame] | 777 | if (template.style & DS_CENTER) |
| 778 | { |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 779 | rect.left = (GetSystemMetrics(SM_CXSCREEN) - rect.right) / 2; |
| 780 | rect.top = (GetSystemMetrics(SM_CYSCREEN) - rect.bottom) / 2; |
Dave Pickles | fcc9d13 | 1998-10-10 15:52:46 +0000 | [diff] [blame] | 781 | } |
| 782 | else |
| 783 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 784 | rect.left += MulDiv(template.x, dlgInfo->xBaseUnit, 4); |
| 785 | rect.top += MulDiv(template.y, dlgInfo->yBaseUnit, 8); |
Dave Pickles | fcc9d13 | 1998-10-10 15:52:46 +0000 | [diff] [blame] | 786 | } |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 787 | if ( !(template.style & WS_CHILD) ) |
| 788 | { |
| 789 | INT16 dX, dY; |
| 790 | |
| 791 | if( !(template.style & DS_ABSALIGN) ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 792 | ClientToScreen( owner, (POINT *)&rect ); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 793 | |
| 794 | /* try to fit it into the desktop */ |
| 795 | |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 796 | if( (dX = rect.left + rect.right + GetSystemMetrics(SM_CXDLGFRAME) |
| 797 | - GetSystemMetrics(SM_CXSCREEN)) > 0 ) rect.left -= dX; |
| 798 | if( (dY = rect.top + rect.bottom + GetSystemMetrics(SM_CYDLGFRAME) |
| 799 | - GetSystemMetrics(SM_CYSCREEN)) > 0 ) rect.top -= dY; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 800 | if( rect.left < 0 ) rect.left = 0; |
| 801 | if( rect.top < 0 ) rect.top = 0; |
| 802 | } |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 803 | } |
| 804 | |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 805 | if (modal) |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 806 | { |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 807 | ownerEnabled = DIALOG_DisableOwner( owner ); |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 808 | if (ownerEnabled) dlgInfo->flags |= DF_OWNERENABLED; |
| 809 | } |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 810 | |
Ulrich Weigand | f03c936 | 1999-07-10 13:08:50 +0000 | [diff] [blame] | 811 | if (!win32Template) |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 812 | hwnd = WIN_Handle32( CreateWindowEx16(template.exStyle, template.className, |
| 813 | template.caption, template.style & ~WS_VISIBLE, |
| 814 | rect.left, rect.top, rect.right, rect.bottom, |
| 815 | WIN_Handle16(owner), dlgInfo->hMenu, hInst, NULL )); |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 816 | else |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 817 | hwnd = CreateWindowExW(template.exStyle, (LPCWSTR)template.className, |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 818 | (LPCWSTR)template.caption, |
| 819 | template.style & ~WS_VISIBLE, |
| 820 | rect.left, rect.top, rect.right, rect.bottom, |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 821 | owner, dlgInfo->hMenu, hInst, NULL ); |
| 822 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 823 | if (!hwnd) |
| 824 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 825 | if (dlgInfo->hUserFont) DeleteObject( dlgInfo->hUserFont ); |
| 826 | if (dlgInfo->hMenu) DestroyMenu( dlgInfo->hMenu ); |
| 827 | if (modal && (dlgInfo->flags & DF_OWNERENABLED)) DIALOG_EnableOwner(owner); |
| 828 | HeapFree( GetProcessHeap(), 0, dlgInfo ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 829 | return 0; |
| 830 | } |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 831 | wndPtr = WIN_GetPtr( hwnd ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 832 | wndPtr->flags |= WIN_ISDIALOG; |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 833 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | 902da69 | 1995-11-05 14:39:02 +0000 | [diff] [blame] | 834 | |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 835 | if (template.helpId) SetWindowContextHelpId( hwnd, template.helpId ); |
| 836 | SetWindowLongW( hwnd, DWL_WINE_DIALOGINFO, (LONG)dlgInfo ); |
| 837 | switch(procType) |
| 838 | { |
| 839 | case WIN_PROC_16: SetWindowLong16( WIN_Handle16(hwnd), DWL_DLGPROC, (LONG)dlgProc ); break; |
| 840 | case WIN_PROC_32A: SetWindowLongA( hwnd, DWL_DLGPROC, (LONG)dlgProc ); break; |
| 841 | case WIN_PROC_32W: SetWindowLongW( hwnd, DWL_DLGPROC, (LONG)dlgProc ); break; |
| 842 | default: break; |
| 843 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 844 | |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 845 | if (dlgInfo->hUserFont) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 846 | SendMessageA( hwnd, WM_SETFONT, (WPARAM)dlgInfo->hUserFont, 0 ); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 847 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 848 | /* Create controls */ |
| 849 | |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 850 | if (DIALOG_CreateControls( hwnd, dlgTemplate, &template, |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 851 | hInst, win32Template )) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 852 | { |
Adrian Thurston | 00442ba | 1999-10-23 16:48:05 +0000 | [diff] [blame] | 853 | HWND hwndPreInitFocus; |
| 854 | |
| 855 | /* Send initialisation messages and set focus */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 856 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 857 | dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE ); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 858 | |
Adrian Thurston | 00442ba | 1999-10-23 16:48:05 +0000 | [diff] [blame] | 859 | hwndPreInitFocus = GetFocus(); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 860 | if (SendMessageA( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param )) |
Sheri Steeves | a4b73d4 | 2000-06-15 01:00:42 +0000 | [diff] [blame] | 861 | { |
Alexandre Julliard | 908464d | 2000-11-01 03:11:12 +0000 | [diff] [blame] | 862 | /* check where the focus is again, |
| 863 | * some controls status might have changed in WM_INITDIALOG */ |
Dave Hawkes | 5446abe | 2001-12-06 22:21:36 +0000 | [diff] [blame] | 864 | dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE); |
| 865 | if( dlgInfo->hwndFocus ) |
| 866 | SetFocus( dlgInfo->hwndFocus ); |
Sheri Steeves | a4b73d4 | 2000-06-15 01:00:42 +0000 | [diff] [blame] | 867 | } |
| 868 | else |
| 869 | { |
| 870 | /* If the dlgproc has returned FALSE (indicating handling of keyboard focus) |
| 871 | but the focus has not changed, set the focus where we expect it. */ |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 872 | if ((GetFocus() == hwndPreInitFocus) && |
| 873 | (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) |
Sheri Steeves | a4b73d4 | 2000-06-15 01:00:42 +0000 | [diff] [blame] | 874 | { |
| 875 | dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE); |
Dave Hawkes | 5446abe | 2001-12-06 22:21:36 +0000 | [diff] [blame] | 876 | if( dlgInfo->hwndFocus ) |
| 877 | SetFocus( dlgInfo->hwndFocus ); |
Sheri Steeves | a4b73d4 | 2000-06-15 01:00:42 +0000 | [diff] [blame] | 878 | } |
| 879 | } |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 880 | |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 881 | if (template.style & WS_VISIBLE && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 882 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 883 | ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */ |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 884 | } |
| 885 | return hwnd; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 886 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 887 | if( IsWindow(hwnd) ) DestroyWindow( hwnd ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 888 | if (modal && ownerEnabled) DIALOG_EnableOwner(owner); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 889 | return 0; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 890 | } |
| 891 | |
| 892 | |
| 893 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 894 | * CreateDialog (USER.89) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 895 | */ |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 896 | HWND16 WINAPI CreateDialog16( HINSTANCE16 hInst, LPCSTR dlgTemplate, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 897 | HWND16 owner, DLGPROC16 dlgProc ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 898 | { |
| 899 | return CreateDialogParam16( hInst, dlgTemplate, owner, dlgProc, 0 ); |
| 900 | } |
| 901 | |
| 902 | |
| 903 | /*********************************************************************** |
Patrik Stridvall | 0c61028 | 2001-01-25 22:22:21 +0000 | [diff] [blame] | 904 | * CreateDialogParam (USER.241) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 905 | */ |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 906 | HWND16 WINAPI CreateDialogParam16( HINSTANCE16 hInst, LPCSTR dlgTemplate, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 907 | HWND16 owner, DLGPROC16 dlgProc, |
| 908 | LPARAM param ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 909 | { |
| 910 | HWND16 hwnd = 0; |
Alexandre Julliard | 8cc3a5e | 1996-08-11 15:49:51 +0000 | [diff] [blame] | 911 | HRSRC16 hRsrc; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 912 | HGLOBAL16 hmem; |
| 913 | LPCVOID data; |
| 914 | |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 915 | TRACE("%04x,%s,%04x,%08lx,%ld\n", |
| 916 | hInst, debugres_a(dlgTemplate), owner, (DWORD)dlgProc, param ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 917 | |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 918 | if (!(hRsrc = FindResource16( hInst, dlgTemplate, RT_DIALOGA ))) return 0; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 919 | if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0; |
| 920 | if (!(data = LockResource16( hmem ))) hwnd = 0; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 921 | else hwnd = CreateDialogIndirectParam16( hInst, data, owner, |
| 922 | dlgProc, param ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 923 | FreeResource16( hmem ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 924 | return hwnd; |
| 925 | } |
| 926 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 927 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 928 | * CreateDialogParamA (USER32.@) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 929 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 930 | HWND WINAPI CreateDialogParamA( HINSTANCE hInst, LPCSTR name, |
| 931 | HWND owner, DLGPROC dlgProc, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 932 | LPARAM param ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 933 | { |
Ove Kaaven | 483c548 | 1999-07-18 15:29:09 +0000 | [diff] [blame] | 934 | HANDLE hrsrc = FindResourceA( hInst, name, RT_DIALOGA ); |
| 935 | if (!hrsrc) return 0; |
| 936 | return CreateDialogIndirectParamA( hInst, |
| 937 | (LPVOID)LoadResource(hInst, hrsrc), |
| 938 | owner, dlgProc, param ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 939 | } |
| 940 | |
| 941 | |
| 942 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 943 | * CreateDialogParamW (USER32.@) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 944 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 945 | HWND WINAPI CreateDialogParamW( HINSTANCE hInst, LPCWSTR name, |
| 946 | HWND owner, DLGPROC dlgProc, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 947 | LPARAM param ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 948 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 949 | HANDLE hrsrc = FindResourceW( hInst, name, RT_DIALOGW ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 950 | if (!hrsrc) return 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 951 | return CreateDialogIndirectParamW( hInst, |
| 952 | (LPVOID)LoadResource(hInst, hrsrc), |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 953 | owner, dlgProc, param ); |
| 954 | } |
| 955 | |
| 956 | |
| 957 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 958 | * CreateDialogIndirect (USER.219) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 959 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 960 | HWND16 WINAPI CreateDialogIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate, |
| 961 | HWND16 owner, DLGPROC16 dlgProc ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 962 | { |
| 963 | return CreateDialogIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0); |
| 964 | } |
| 965 | |
| 966 | |
| 967 | /*********************************************************************** |
Patrik Stridvall | 0c61028 | 2001-01-25 22:22:21 +0000 | [diff] [blame] | 968 | * CreateDialogIndirectParam (USER.242) |
| 969 | * CreateDialogIndirectParam16 (USER32.@) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 970 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 971 | HWND16 WINAPI CreateDialogIndirectParam16( HINSTANCE16 hInst, |
| 972 | LPCVOID dlgTemplate, |
| 973 | HWND16 owner, DLGPROC16 dlgProc, |
| 974 | LPARAM param ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 975 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 976 | return WIN_Handle16( DIALOG_CreateIndirect( hInst, dlgTemplate, WIN_Handle32(owner), |
| 977 | (DLGPROC)dlgProc, param, WIN_PROC_16, FALSE )); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | |
| 981 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 982 | * CreateDialogIndirectParamA (USER32.@) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 983 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 984 | HWND WINAPI CreateDialogIndirectParamA( HINSTANCE hInst, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 985 | LPCVOID dlgTemplate, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 986 | HWND owner, DLGPROC dlgProc, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 987 | LPARAM param ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 988 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 989 | return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32A, FALSE ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 990 | } |
| 991 | |
Juergen Schmied | 84b358d | 1998-10-11 15:38:35 +0000 | [diff] [blame] | 992 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 993 | * CreateDialogIndirectParamAorW (USER32.@) |
Juergen Schmied | 84b358d | 1998-10-11 15:38:35 +0000 | [diff] [blame] | 994 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 995 | HWND WINAPI CreateDialogIndirectParamAorW( HINSTANCE hInst, |
Juergen Schmied | 84b358d | 1998-10-11 15:38:35 +0000 | [diff] [blame] | 996 | LPCVOID dlgTemplate, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 997 | HWND owner, DLGPROC dlgProc, |
Juergen Schmied | 84b358d | 1998-10-11 15:38:35 +0000 | [diff] [blame] | 998 | LPARAM param ) |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 999 | { FIXME("assume WIN_PROC_32W\n"); |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1000 | return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32W, FALSE ); |
Juergen Schmied | 84b358d | 1998-10-11 15:38:35 +0000 | [diff] [blame] | 1001 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1002 | |
| 1003 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1004 | * CreateDialogIndirectParamW (USER32.@) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1005 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1006 | HWND WINAPI CreateDialogIndirectParamW( HINSTANCE hInst, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1007 | LPCVOID dlgTemplate, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1008 | HWND owner, DLGPROC dlgProc, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1009 | LPARAM param ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1010 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1011 | return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32W, FALSE ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | |
| 1015 | /*********************************************************************** |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1016 | * DIALOG_DoDialogBox |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1017 | */ |
Gerard Patel | e3bd8d0 | 2000-08-18 23:05:44 +0000 | [diff] [blame] | 1018 | static INT DIALOG_DoDialogBox( HWND hwnd, HWND owner ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1019 | { |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1020 | DIALOGINFO * dlgInfo; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1021 | MSG msg; |
| 1022 | INT retval; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1023 | HWND ownerMsg = GetAncestor( owner, GA_ROOT ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1024 | |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1025 | if (!(dlgInfo = DIALOG_get_info( hwnd ))) return -1; |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1026 | |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 1027 | if (!(dlgInfo->flags & DF_END)) /* was EndDialog called in WM_INITDIALOG ? */ |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1028 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1029 | ShowWindow( hwnd, SW_SHOW ); |
Alexandre Julliard | bfb4a23 | 2001-08-06 18:05:47 +0000 | [diff] [blame] | 1030 | for (;;) |
Gerard Patel | 902f9c6 | 1999-02-14 11:22:03 +0000 | [diff] [blame] | 1031 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1032 | if (!(GetWindowLongW( hwnd, GWL_STYLE ) & DS_NOIDLEMSG)) |
Alexandre Julliard | bfb4a23 | 2001-08-06 18:05:47 +0000 | [diff] [blame] | 1033 | { |
| 1034 | if (!PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) |
| 1035 | { |
| 1036 | /* No message present -> send ENTERIDLE and wait */ |
| 1037 | SendMessageW( ownerMsg, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)hwnd ); |
| 1038 | if (!GetMessageW( &msg, 0, 0, 0 )) break; |
| 1039 | } |
| 1040 | } |
| 1041 | else if (!GetMessageW( &msg, 0, 0, 0 )) break; |
| 1042 | |
| 1043 | if (CallMsgFilterW( &msg, MSGF_DIALOGBOX )) continue; |
| 1044 | |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1045 | if (!IsWindow( hwnd )) return -1; |
Alexandre Julliard | bfb4a23 | 2001-08-06 18:05:47 +0000 | [diff] [blame] | 1046 | if (!(dlgInfo->flags & DF_END) && !IsDialogMessageW( hwnd, &msg)) |
Gerard Patel | 902f9c6 | 1999-02-14 11:22:03 +0000 | [diff] [blame] | 1047 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1048 | TranslateMessage( &msg ); |
Alexandre Julliard | bfb4a23 | 2001-08-06 18:05:47 +0000 | [diff] [blame] | 1049 | DispatchMessageW( &msg ); |
Gerard Patel | 902f9c6 | 1999-02-14 11:22:03 +0000 | [diff] [blame] | 1050 | } |
| 1051 | if (dlgInfo->flags & DF_END) break; |
| 1052 | } |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1053 | } |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1054 | if (dlgInfo->flags & DF_OWNERENABLED) DIALOG_EnableOwner( owner ); |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1055 | retval = dlgInfo->idResult; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1056 | DestroyWindow( hwnd ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1057 | return retval; |
| 1058 | } |
| 1059 | |
| 1060 | |
| 1061 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1062 | * DialogBox (USER.87) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1063 | */ |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 1064 | INT16 WINAPI DialogBox16( HINSTANCE16 hInst, LPCSTR dlgTemplate, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1065 | HWND16 owner, DLGPROC16 dlgProc ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1066 | { |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1067 | return DialogBoxParam16( hInst, dlgTemplate, owner, dlgProc, 0 ); |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1068 | } |
| 1069 | |
| 1070 | |
| 1071 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1072 | * DialogBoxParam (USER.239) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1073 | */ |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 1074 | INT16 WINAPI DialogBoxParam16( HINSTANCE16 hInst, LPCSTR template, |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1075 | HWND16 owner16, DLGPROC16 dlgProc, LPARAM param ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1076 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1077 | HWND hwnd = 0; |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 1078 | HRSRC16 hRsrc; |
| 1079 | HGLOBAL16 hmem; |
| 1080 | LPCVOID data; |
| 1081 | int ret = -1; |
| 1082 | |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 1083 | if (!(hRsrc = FindResource16( hInst, template, RT_DIALOGA ))) return 0; |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 1084 | if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1085 | if ((data = LockResource16( hmem ))) |
| 1086 | { |
| 1087 | HWND owner = WIN_Handle32(owner16); |
| 1088 | hwnd = DIALOG_CreateIndirect( hInst, data, owner, |
| 1089 | (DLGPROC)dlgProc, param, WIN_PROC_16, TRUE ); |
| 1090 | if (hwnd) ret = DIALOG_DoDialogBox( hwnd, owner ); |
| 1091 | GlobalUnlock16( hmem ); |
| 1092 | } |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 1093 | FreeResource16( hmem ); |
| 1094 | return ret; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1095 | } |
| 1096 | |
| 1097 | |
| 1098 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1099 | * DialogBoxParamA (USER32.@) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1100 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1101 | INT WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name, |
| 1102 | HWND owner, DLGPROC dlgProc, LPARAM param ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1103 | { |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 1104 | HWND hwnd; |
| 1105 | HANDLE hrsrc = FindResourceA( hInst, name, RT_DIALOGA ); |
| 1106 | if (!hrsrc) return 0; |
| 1107 | hwnd = DIALOG_CreateIndirect( hInst, (LPVOID)LoadResource(hInst, hrsrc), |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1108 | owner, dlgProc, param, WIN_PROC_32A, TRUE ); |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 1109 | if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1110 | return -1; |
| 1111 | } |
| 1112 | |
| 1113 | |
| 1114 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1115 | * DialogBoxParamW (USER32.@) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1116 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1117 | INT WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name, |
| 1118 | HWND owner, DLGPROC dlgProc, LPARAM param ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1119 | { |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 1120 | HWND hwnd; |
| 1121 | HANDLE hrsrc = FindResourceW( hInst, name, RT_DIALOGW ); |
| 1122 | if (!hrsrc) return 0; |
| 1123 | hwnd = DIALOG_CreateIndirect( hInst, (LPVOID)LoadResource(hInst, hrsrc), |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1124 | owner, dlgProc, param, WIN_PROC_32W, TRUE ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1125 | if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); |
| 1126 | return -1; |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1127 | } |
| 1128 | |
| 1129 | |
| 1130 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1131 | * DialogBoxIndirect (USER.218) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1132 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1133 | INT16 WINAPI DialogBoxIndirect16( HINSTANCE16 hInst, HANDLE16 dlgTemplate, |
| 1134 | HWND16 owner, DLGPROC16 dlgProc ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1135 | { |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1136 | return DialogBoxIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0 ); |
| 1137 | } |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1138 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1139 | |
| 1140 | /*********************************************************************** |
Patrik Stridvall | 0c61028 | 2001-01-25 22:22:21 +0000 | [diff] [blame] | 1141 | * DialogBoxIndirectParam (USER.240) |
| 1142 | * DialogBoxIndirectParam16 (USER32.@) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1143 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1144 | INT16 WINAPI DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate, |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1145 | HWND16 owner16, DLGPROC16 dlgProc, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1146 | LPARAM param ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1147 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1148 | HWND hwnd, owner = WIN_Handle32( owner16 ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1149 | LPCVOID ptr; |
| 1150 | |
| 1151 | if (!(ptr = GlobalLock16( dlgTemplate ))) return -1; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1152 | hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, (DLGPROC)dlgProc, |
| 1153 | param, WIN_PROC_16, TRUE ); |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 1154 | GlobalUnlock16( dlgTemplate ); |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 1155 | if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1156 | return -1; |
| 1157 | } |
| 1158 | |
| 1159 | |
| 1160 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1161 | * DialogBoxIndirectParamA (USER32.@) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1162 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1163 | INT WINAPI DialogBoxIndirectParamA(HINSTANCE hInstance, LPCVOID template, |
| 1164 | HWND owner, DLGPROC dlgProc, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1165 | LPARAM param ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1166 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1167 | HWND hwnd = DIALOG_CreateIndirect( hInstance, template, owner, |
| 1168 | dlgProc, param, WIN_PROC_32A, TRUE ); |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 1169 | if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1170 | return -1; |
| 1171 | } |
| 1172 | |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 1173 | |
Alexandre Julliard | 3ed37e0 | 1994-11-07 18:20:42 +0000 | [diff] [blame] | 1174 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1175 | * DialogBoxIndirectParamW (USER32.@) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1176 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1177 | INT WINAPI DialogBoxIndirectParamW(HINSTANCE hInstance, LPCVOID template, |
| 1178 | HWND owner, DLGPROC dlgProc, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1179 | LPARAM param ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1180 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1181 | HWND hwnd = DIALOG_CreateIndirect( hInstance, template, owner, |
| 1182 | dlgProc, param, WIN_PROC_32W, TRUE ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1183 | if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); |
| 1184 | return -1; |
| 1185 | } |
| 1186 | |
Juergen Schmied | a4d7ca0 | 2000-01-04 00:29:44 +0000 | [diff] [blame] | 1187 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1188 | * DialogBoxIndirectParamAorW (USER32.@) |
Juergen Schmied | a4d7ca0 | 2000-01-04 00:29:44 +0000 | [diff] [blame] | 1189 | */ |
| 1190 | INT WINAPI DialogBoxIndirectParamAorW(HINSTANCE hInstance, LPCVOID template, |
| 1191 | HWND owner, DLGPROC dlgProc, |
| 1192 | LPARAM param, DWORD x ) |
| 1193 | { |
| 1194 | HWND hwnd; |
| 1195 | FIXME("0x%08x %p 0x%08x %p 0x%08lx 0x%08lx\n", |
| 1196 | hInstance, template, owner, dlgProc, param, x); |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1197 | hwnd = DIALOG_CreateIndirect( hInstance, template, owner, dlgProc, param, WIN_PROC_32W, TRUE ); |
Juergen Schmied | a4d7ca0 | 2000-01-04 00:29:44 +0000 | [diff] [blame] | 1198 | if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); |
| 1199 | return -1; |
| 1200 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1201 | |
| 1202 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1203 | * EndDialog (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1204 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1205 | BOOL WINAPI EndDialog( HWND hwnd, INT retval ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1206 | { |
Gerard Patel | f314e5e | 2000-08-21 03:31:39 +0000 | [diff] [blame] | 1207 | BOOL wasEnabled = TRUE; |
Andreas Mohr | beae14d | 2000-02-12 13:21:23 +0000 | [diff] [blame] | 1208 | DIALOGINFO * dlgInfo; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1209 | HWND owner; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1210 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 1211 | TRACE("%04x %d\n", hwnd, retval ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1212 | |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1213 | if (!(dlgInfo = DIALOG_get_info( hwnd ))) |
Andreas Mohr | beae14d | 2000-02-12 13:21:23 +0000 | [diff] [blame] | 1214 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1215 | ERR("got invalid window handle (%04x); buggy app !?\n", hwnd); |
| 1216 | return FALSE; |
Andreas Mohr | beae14d | 2000-02-12 13:21:23 +0000 | [diff] [blame] | 1217 | } |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1218 | dlgInfo->idResult = retval; |
| 1219 | dlgInfo->flags |= DF_END; |
| 1220 | wasEnabled = (dlgInfo->flags & DF_OWNERENABLED); |
Andreas Mohr | 01f8426 | 1999-03-19 16:49:30 +0000 | [diff] [blame] | 1221 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1222 | if (wasEnabled && (owner = GetWindow( hwnd, GW_OWNER ))) |
| 1223 | DIALOG_EnableOwner( owner ); |
| 1224 | |
Abey George | 3336f48 | 1999-10-13 15:45:23 +0000 | [diff] [blame] | 1225 | /* Windows sets the focus to the dialog itself in EndDialog */ |
Abey George | 15c58c4 | 1999-08-07 14:10:04 +0000 | [diff] [blame] | 1226 | |
| 1227 | if (IsChild(hwnd, GetFocus())) |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1228 | SetFocus( hwnd ); |
Abey George | 15c58c4 | 1999-08-07 14:10:04 +0000 | [diff] [blame] | 1229 | |
Abey George | 3336f48 | 1999-10-13 15:45:23 +0000 | [diff] [blame] | 1230 | /* Don't have to send a ShowWindow(SW_HIDE), just do |
| 1231 | SetWindowPos with SWP_HIDEWINDOW as done in Windows */ |
Andreas Mohr | 01f8426 | 1999-03-19 16:49:30 +0000 | [diff] [blame] | 1232 | |
Abey George | 3336f48 | 1999-10-13 15:45:23 +0000 | [diff] [blame] | 1233 | SetWindowPos(hwnd, (HWND)0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE |
| 1234 | | SWP_NOZORDER | SWP_NOACTIVATE | SWP_HIDEWINDOW); |
Stephane Lussier | 18613bb | 1999-07-24 10:18:02 +0000 | [diff] [blame] | 1235 | |
Gerard Patel | 53cad8b | 2001-03-05 19:59:50 +0000 | [diff] [blame] | 1236 | /* unblock dialog loop */ |
| 1237 | PostMessageA(hwnd, WM_NULL, 0, 0); |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 1238 | return TRUE; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | |
| 1242 | /*********************************************************************** |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1243 | * DIALOG_IsAccelerator |
| 1244 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1245 | static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM vKey ) |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1246 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1247 | HWND hwndControl = hwnd; |
| 1248 | HWND hwndNext; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1249 | INT dlgCode; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1250 | WCHAR buffer[128]; |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1251 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1252 | do |
| 1253 | { |
| 1254 | DWORD style = GetWindowLongW( hwndControl, GWL_STYLE ); |
| 1255 | if ((style & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE) |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1256 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1257 | dlgCode = SendMessageA( hwndControl, WM_GETDLGCODE, 0, 0 ); |
| 1258 | if ( (dlgCode & (DLGC_BUTTON | DLGC_STATIC)) && |
| 1259 | GetWindowTextW( hwndControl, buffer, sizeof(buffer)/sizeof(WCHAR) )) |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1260 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1261 | /* find the accelerator key */ |
| 1262 | LPWSTR p = buffer - 2; |
| 1263 | char a_char = vKey; |
| 1264 | WCHAR w_char = 0; |
| 1265 | |
| 1266 | do |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1267 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1268 | p = strchrW( p + 2, '&' ); |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1269 | } |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1270 | while (p != NULL && p[1] == '&'); |
Dmitry Timoshkov | f92a777 | 1999-12-05 23:51:15 +0000 | [diff] [blame] | 1271 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1272 | /* and check if it's the one we're looking for */ |
| 1273 | MultiByteToWideChar(CP_ACP, 0, &a_char, 1, &w_char, 1); |
| 1274 | if (p != NULL && toupperW( p[1] ) == toupperW( w_char ) ) |
| 1275 | { |
| 1276 | if ((dlgCode & DLGC_STATIC) || (style & 0x0f) == BS_GROUPBOX ) |
| 1277 | { |
| 1278 | /* set focus to the control */ |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1279 | SendMessageA( hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndControl, 1); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1280 | /* and bump it on to next */ |
| 1281 | SendMessageA( hwndDlg, WM_NEXTDLGCTL, 0, 0); |
| 1282 | } |
| 1283 | else if (dlgCode & DLGC_BUTTON) |
| 1284 | { |
| 1285 | /* send BM_CLICK message to the control */ |
| 1286 | SendMessageA( hwndControl, BM_CLICK, 0, 0 ); |
| 1287 | } |
| 1288 | return TRUE; |
| 1289 | } |
| 1290 | } |
| 1291 | hwndNext = GetWindow( hwndControl, GW_CHILD ); |
| 1292 | } |
| 1293 | else hwndNext = 0; |
| 1294 | |
| 1295 | if (!hwndNext) hwndNext = GetWindow( hwndControl, GW_HWNDNEXT ); |
| 1296 | |
| 1297 | while (!hwndNext && hwndControl) |
| 1298 | { |
| 1299 | hwndControl = GetParent( hwndControl ); |
| 1300 | if (hwndControl == hwndDlg) |
| 1301 | { |
| 1302 | if(hwnd==hwndDlg) /* prevent endless loop */ |
| 1303 | { |
| 1304 | hwndNext=hwnd; |
| 1305 | break; |
| 1306 | } |
| 1307 | hwndNext = GetWindow( hwndDlg, GW_CHILD ); |
| 1308 | } |
| 1309 | else |
| 1310 | hwndNext = GetWindow( hwndControl, GW_HWNDNEXT ); |
| 1311 | } |
| 1312 | hwndControl = hwndNext; |
| 1313 | } |
| 1314 | while (hwndControl && (hwndControl != hwnd)); |
| 1315 | |
| 1316 | return FALSE; |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1317 | } |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1318 | |
Andrew Lewycky | 0ceb255 | 2000-03-19 14:20:52 +0000 | [diff] [blame] | 1319 | /*********************************************************************** |
| 1320 | * DIALOG_FindMsgDestination |
| 1321 | * |
Alexandre Julliard | 908464d | 2000-11-01 03:11:12 +0000 | [diff] [blame] | 1322 | * The messages that IsDialogMessage sends may not go to the dialog |
Andrew Lewycky | 0ceb255 | 2000-03-19 14:20:52 +0000 | [diff] [blame] | 1323 | * calling IsDialogMessage if that dialog is a child, and it has the |
| 1324 | * DS_CONTROL style set. |
Alexandre Julliard | 908464d | 2000-11-01 03:11:12 +0000 | [diff] [blame] | 1325 | * We propagate up until we hit one that does not have DS_CONTROL, or |
Andrew Lewycky | 0ceb255 | 2000-03-19 14:20:52 +0000 | [diff] [blame] | 1326 | * whose parent is not a dialog. |
| 1327 | * |
| 1328 | * This is undocumented behaviour. |
| 1329 | */ |
| 1330 | static HWND DIALOG_FindMsgDestination( HWND hwndDlg ) |
| 1331 | { |
| 1332 | while (GetWindowLongA(hwndDlg, GWL_STYLE) & DS_CONTROL) |
| 1333 | { |
| 1334 | WND *pParent; |
| 1335 | HWND hParent = GetParent(hwndDlg); |
| 1336 | if (!hParent) break; |
| 1337 | |
| 1338 | pParent = WIN_FindWndPtr(hParent); |
| 1339 | if (!pParent) break; |
| 1340 | |
| 1341 | if (!(pParent->flags & WIN_ISDIALOG)) |
| 1342 | { |
| 1343 | WIN_ReleaseWndPtr(pParent); |
| 1344 | break; |
| 1345 | } |
| 1346 | WIN_ReleaseWndPtr(pParent); |
| 1347 | |
| 1348 | hwndDlg = hParent; |
| 1349 | } |
| 1350 | |
| 1351 | return hwndDlg; |
| 1352 | } |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1353 | |
| 1354 | /*********************************************************************** |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1355 | * DIALOG_IsDialogMessage |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1356 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1357 | static BOOL DIALOG_IsDialogMessage( HWND hwnd, HWND hwndDlg, |
| 1358 | UINT message, WPARAM wParam, |
| 1359 | LPARAM lParam, BOOL *translate, |
| 1360 | BOOL *dispatch, INT dlgCode ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1361 | { |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1362 | *translate = *dispatch = FALSE; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1363 | |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 1364 | if (message == WM_PAINT) |
| 1365 | { |
| 1366 | /* Apparently, we have to handle this one as well */ |
| 1367 | *dispatch = TRUE; |
| 1368 | return TRUE; |
| 1369 | } |
| 1370 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1371 | /* Only the key messages get special processing */ |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1372 | if ((message != WM_KEYDOWN) && |
Dmitry Timoshkov | 780bb79 | 2000-11-25 02:10:04 +0000 | [diff] [blame] | 1373 | (message != WM_SYSKEYDOWN) && |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1374 | (message != WM_SYSCHAR) && |
| 1375 | (message != WM_CHAR)) |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 1376 | return FALSE; |
| 1377 | |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 1378 | if (dlgCode & DLGC_WANTMESSAGE) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1379 | { |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1380 | *translate = *dispatch = TRUE; |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 1381 | return TRUE; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1382 | } |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1383 | |
Andrew Lewycky | 0ceb255 | 2000-03-19 14:20:52 +0000 | [diff] [blame] | 1384 | hwndDlg = DIALOG_FindMsgDestination(hwndDlg); |
| 1385 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1386 | switch(message) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1387 | { |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1388 | case WM_KEYDOWN: |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1389 | switch(wParam) |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1390 | { |
| 1391 | case VK_TAB: |
| 1392 | if (!(dlgCode & DLGC_WANTTAB)) |
| 1393 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1394 | SendMessageA( hwndDlg, WM_NEXTDLGCTL, |
| 1395 | (GetKeyState(VK_SHIFT) & 0x8000), 0 ); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1396 | return TRUE; |
| 1397 | } |
| 1398 | break; |
| 1399 | |
| 1400 | case VK_RIGHT: |
| 1401 | case VK_DOWN: |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1402 | case VK_LEFT: |
| 1403 | case VK_UP: |
| 1404 | if (!(dlgCode & DLGC_WANTARROWS)) |
| 1405 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1406 | BOOL fPrevious = (wParam == VK_LEFT || wParam == VK_UP); |
| 1407 | HWND hwndNext = |
| 1408 | GetNextDlgGroupItem (hwndDlg, GetFocus(), fPrevious ); |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1409 | SendMessageA( hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndNext, 1 ); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1410 | return TRUE; |
| 1411 | } |
| 1412 | break; |
| 1413 | |
| 1414 | case VK_ESCAPE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1415 | SendMessageA( hwndDlg, WM_COMMAND, IDCANCEL, |
| 1416 | (LPARAM)GetDlgItem( hwndDlg, IDCANCEL ) ); |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1417 | return TRUE; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1418 | |
| 1419 | case VK_RETURN: |
| 1420 | { |
Alexandre Julliard | bfb4a23 | 2001-08-06 18:05:47 +0000 | [diff] [blame] | 1421 | DWORD dw = SendMessageW( hwndDlg, DM_GETDEFID, 0, 0 ); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1422 | if (HIWORD(dw) == DC_HASDEFID) |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1423 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1424 | SendMessageA( hwndDlg, WM_COMMAND, |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1425 | MAKEWPARAM( LOWORD(dw), BN_CLICKED ), |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1426 | (LPARAM)GetDlgItem(hwndDlg, LOWORD(dw))); |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1427 | } |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 1428 | else |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1429 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1430 | SendMessageA( hwndDlg, WM_COMMAND, IDOK, |
| 1431 | (LPARAM)GetDlgItem( hwndDlg, IDOK ) ); |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1432 | |
| 1433 | } |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1434 | } |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1435 | return TRUE; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1436 | } |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1437 | *translate = TRUE; |
| 1438 | break; /* case WM_KEYDOWN */ |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1439 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1440 | case WM_CHAR: |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1441 | if (dlgCode & DLGC_WANTCHARS) break; |
| 1442 | /* drop through */ |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1443 | |
| 1444 | case WM_SYSCHAR: |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1445 | if (DIALOG_IsAccelerator( WIN_GetFullHandle(hwnd), hwndDlg, wParam )) |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1446 | { |
| 1447 | /* don't translate or dispatch */ |
| 1448 | return TRUE; |
| 1449 | } |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1450 | break; |
Dmitry Timoshkov | 780bb79 | 2000-11-25 02:10:04 +0000 | [diff] [blame] | 1451 | |
| 1452 | case WM_SYSKEYDOWN: |
| 1453 | *translate = TRUE; |
| 1454 | break; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1455 | } |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1456 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1457 | /* If we get here, the message has not been treated specially */ |
| 1458 | /* and can be sent to its destination window. */ |
| 1459 | *dispatch = TRUE; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1460 | return TRUE; |
| 1461 | } |
| 1462 | |
| 1463 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1464 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1465 | * IsDialogMessage (USER.90) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1466 | */ |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 1467 | BOOL16 WINAPI IsDialogMessage16( HWND16 hwndDlg, SEGPTR msg16 ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1468 | { |
Alexandre Julliard | 982a223 | 2000-12-13 20:20:09 +0000 | [diff] [blame] | 1469 | LPMSG16 msg = MapSL(msg16); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1470 | BOOL ret, translate, dispatch; |
David Grant | edb7797 | 1999-11-07 21:02:17 +0000 | [diff] [blame] | 1471 | INT dlgCode = 0; |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1472 | |
| 1473 | if ((hwndDlg != msg->hwnd) && !IsChild16( hwndDlg, msg->hwnd )) |
| 1474 | return FALSE; |
| 1475 | |
David Grant | edb7797 | 1999-11-07 21:02:17 +0000 | [diff] [blame] | 1476 | if ((msg->message == WM_KEYDOWN) || |
David Grant | edb7797 | 1999-11-07 21:02:17 +0000 | [diff] [blame] | 1477 | (msg->message == WM_CHAR)) |
| 1478 | { |
| 1479 | dlgCode = SendMessage16( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg16); |
| 1480 | } |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1481 | ret = DIALOG_IsDialogMessage( WIN_Handle32(msg->hwnd), WIN_Handle32(hwndDlg), |
| 1482 | msg->message, msg->wParam, msg->lParam, |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1483 | &translate, &dispatch, dlgCode ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1484 | if (translate) TranslateMessage16( msg ); |
| 1485 | if (dispatch) DispatchMessage16( msg ); |
| 1486 | return ret; |
| 1487 | } |
| 1488 | |
| 1489 | |
| 1490 | /*********************************************************************** |
Patrik Stridvall | 17fd4e3 | 2001-06-28 18:04:41 +0000 | [diff] [blame] | 1491 | * IsDialogMessage (USER32.@) |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1492 | * IsDialogMessageA (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1493 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1494 | BOOL WINAPI IsDialogMessageA( HWND hwndDlg, LPMSG msg ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1495 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1496 | BOOL ret, translate, dispatch; |
David Grant | edb7797 | 1999-11-07 21:02:17 +0000 | [diff] [blame] | 1497 | INT dlgCode = 0; |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1498 | |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1499 | hwndDlg = WIN_GetFullHandle( hwndDlg ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1500 | if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd )) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1501 | return FALSE; |
| 1502 | |
David Grant | edb7797 | 1999-11-07 21:02:17 +0000 | [diff] [blame] | 1503 | if ((msg->message == WM_KEYDOWN) || |
David Grant | edb7797 | 1999-11-07 21:02:17 +0000 | [diff] [blame] | 1504 | (msg->message == WM_CHAR)) |
| 1505 | { |
| 1506 | dlgCode = SendMessageA( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg); |
| 1507 | } |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1508 | ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message, |
| 1509 | msg->wParam, msg->lParam, |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1510 | &translate, &dispatch, dlgCode ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1511 | if (translate) TranslateMessage( msg ); |
| 1512 | if (dispatch) DispatchMessageA( msg ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1513 | return ret; |
| 1514 | } |
| 1515 | |
| 1516 | |
| 1517 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1518 | * IsDialogMessageW (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1519 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1520 | BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1521 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1522 | BOOL ret, translate, dispatch; |
David Grant | edb7797 | 1999-11-07 21:02:17 +0000 | [diff] [blame] | 1523 | INT dlgCode = 0; |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1524 | |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1525 | hwndDlg = WIN_GetFullHandle( hwndDlg ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1526 | if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd )) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1527 | return FALSE; |
| 1528 | |
David Grant | edb7797 | 1999-11-07 21:02:17 +0000 | [diff] [blame] | 1529 | if ((msg->message == WM_KEYDOWN) || |
David Grant | edb7797 | 1999-11-07 21:02:17 +0000 | [diff] [blame] | 1530 | (msg->message == WM_CHAR)) |
| 1531 | { |
| 1532 | dlgCode = SendMessageW( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg); |
| 1533 | } |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1534 | ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message, |
| 1535 | msg->wParam, msg->lParam, |
Norman Stevens | a83d065 | 1998-10-12 07:25:35 +0000 | [diff] [blame] | 1536 | &translate, &dispatch, dlgCode ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1537 | if (translate) TranslateMessage( msg ); |
| 1538 | if (dispatch) DispatchMessageW( msg ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1539 | return ret; |
| 1540 | } |
| 1541 | |
| 1542 | |
Patrik Stridvall | 54fe838 | 2000-04-06 20:21:16 +0000 | [diff] [blame] | 1543 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1544 | * GetDlgCtrlID (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1545 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1546 | INT WINAPI GetDlgCtrlID( HWND hwnd ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1547 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1548 | return GetWindowLongW( hwnd, GWL_ID ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1549 | } |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1550 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1551 | |
| 1552 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1553 | * GetDlgItem (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1554 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1555 | HWND WINAPI GetDlgItem( HWND hwndDlg, INT id ) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1556 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1557 | int i; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 1558 | HWND *list = WIN_ListChildren( hwndDlg ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1559 | HWND ret = 0; |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1560 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1561 | if (!list) return 0; |
| 1562 | |
| 1563 | for (i = 0; list[i]; i++) if (GetWindowLongW( list[i], GWL_ID ) == id) break; |
| 1564 | ret = list[i]; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 1565 | HeapFree( GetProcessHeap(), 0, list ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1566 | return ret; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1567 | } |
| 1568 | |
| 1569 | |
| 1570 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1571 | * SendDlgItemMessageA (USER32.@) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1572 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1573 | LRESULT WINAPI SendDlgItemMessageA( HWND hwnd, INT id, UINT msg, |
| 1574 | WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1575 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1576 | HWND hwndCtrl = GetDlgItem( hwnd, id ); |
| 1577 | if (hwndCtrl) return SendMessageA( hwndCtrl, msg, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1578 | else return 0; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1579 | } |
| 1580 | |
| 1581 | |
| 1582 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1583 | * SendDlgItemMessageW (USER32.@) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1584 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1585 | LRESULT WINAPI SendDlgItemMessageW( HWND hwnd, INT id, UINT msg, |
| 1586 | WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1587 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1588 | HWND hwndCtrl = GetDlgItem( hwnd, id ); |
| 1589 | if (hwndCtrl) return SendMessageW( hwndCtrl, msg, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1590 | else return 0; |
| 1591 | } |
| 1592 | |
| 1593 | |
| 1594 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1595 | * SetDlgItemTextA (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1596 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1597 | BOOL WINAPI SetDlgItemTextA( HWND hwnd, INT id, LPCSTR lpString ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1598 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1599 | return SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1600 | } |
| 1601 | |
| 1602 | |
| 1603 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1604 | * SetDlgItemTextW (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1605 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1606 | BOOL WINAPI SetDlgItemTextW( HWND hwnd, INT id, LPCWSTR lpString ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1607 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1608 | return SendDlgItemMessageW( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1609 | } |
| 1610 | |
| 1611 | |
| 1612 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1613 | * GetDlgItemTextA (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1614 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1615 | INT WINAPI GetDlgItemTextA( HWND hwnd, INT id, LPSTR str, UINT len ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1616 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1617 | return (INT)SendDlgItemMessageA( hwnd, id, WM_GETTEXT, |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1618 | len, (LPARAM)str ); |
| 1619 | } |
| 1620 | |
| 1621 | |
| 1622 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1623 | * GetDlgItemTextW (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1624 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1625 | INT WINAPI GetDlgItemTextW( HWND hwnd, INT id, LPWSTR str, UINT len ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1626 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1627 | return (INT)SendDlgItemMessageW( hwnd, id, WM_GETTEXT, |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1628 | len, (LPARAM)str ); |
| 1629 | } |
| 1630 | |
| 1631 | |
| 1632 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1633 | * SetDlgItemInt (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1634 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1635 | BOOL WINAPI SetDlgItemInt( HWND hwnd, INT id, UINT value, |
| 1636 | BOOL fSigned ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1637 | { |
| 1638 | char str[20]; |
| 1639 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1640 | if (fSigned) sprintf( str, "%d", (INT)value ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1641 | else sprintf( str, "%u", value ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1642 | SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)str ); |
Eric Pouech | b9544f1 | 1999-02-14 14:09:42 +0000 | [diff] [blame] | 1643 | return TRUE; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1644 | } |
| 1645 | |
| 1646 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1647 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1648 | * GetDlgItemInt (USER32.@) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1649 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1650 | UINT WINAPI GetDlgItemInt( HWND hwnd, INT id, BOOL *translated, |
| 1651 | BOOL fSigned ) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1652 | { |
| 1653 | char str[30]; |
| 1654 | char * endptr; |
| 1655 | long result = 0; |
| 1656 | |
| 1657 | if (translated) *translated = FALSE; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1658 | if (!SendDlgItemMessageA(hwnd, id, WM_GETTEXT, sizeof(str), (LPARAM)str)) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1659 | return 0; |
| 1660 | if (fSigned) |
| 1661 | { |
| 1662 | result = strtol( str, &endptr, 10 ); |
| 1663 | if (!endptr || (endptr == str)) /* Conversion was unsuccessful */ |
| 1664 | return 0; |
| 1665 | if (((result == LONG_MIN) || (result == LONG_MAX)) && (errno==ERANGE)) |
| 1666 | return 0; |
| 1667 | } |
| 1668 | else |
| 1669 | { |
| 1670 | result = strtoul( str, &endptr, 10 ); |
| 1671 | if (!endptr || (endptr == str)) /* Conversion was unsuccessful */ |
| 1672 | return 0; |
| 1673 | if ((result == ULONG_MAX) && (errno == ERANGE)) return 0; |
| 1674 | } |
| 1675 | if (translated) *translated = TRUE; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1676 | return (UINT)result; |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1677 | } |
| 1678 | |
| 1679 | |
| 1680 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1681 | * CheckDlgButton (USER32.@) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1682 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1683 | BOOL WINAPI CheckDlgButton( HWND hwnd, INT id, UINT check ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1684 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1685 | SendDlgItemMessageA( hwnd, id, BM_SETCHECK, check, 0 ); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1686 | return TRUE; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1687 | } |
| 1688 | |
| 1689 | |
| 1690 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1691 | * IsDlgButtonChecked (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1692 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1693 | UINT WINAPI IsDlgButtonChecked( HWND hwnd, UINT id ) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1694 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1695 | return (UINT)SendDlgItemMessageA( hwnd, id, BM_GETCHECK, 0, 0 ); |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1696 | } |
| 1697 | |
| 1698 | |
| 1699 | /*********************************************************************** |
Luc Tourangeau | 8e238d0 | 1999-05-29 14:19:42 +0000 | [diff] [blame] | 1700 | * CheckRB |
| 1701 | * |
| 1702 | * Callback function used to check/uncheck radio buttons that fall |
| 1703 | * within a specific range of IDs. |
| 1704 | */ |
| 1705 | static BOOL CALLBACK CheckRB(HWND hwndChild, LPARAM lParam) |
| 1706 | { |
| 1707 | LONG lChildID = GetWindowLongA(hwndChild, GWL_ID); |
| 1708 | RADIOGROUP *lpRadioGroup = (RADIOGROUP *) lParam; |
| 1709 | |
| 1710 | if ((lChildID >= lpRadioGroup->firstID) && |
| 1711 | (lChildID <= lpRadioGroup->lastID)) |
| 1712 | { |
| 1713 | if (lChildID == lpRadioGroup->checkID) |
| 1714 | { |
| 1715 | SendMessageA(hwndChild, BM_SETCHECK, BST_CHECKED, 0); |
| 1716 | } |
| 1717 | else |
| 1718 | { |
| 1719 | SendMessageA(hwndChild, BM_SETCHECK, BST_UNCHECKED, 0); |
| 1720 | } |
| 1721 | } |
| 1722 | |
| 1723 | return TRUE; |
| 1724 | } |
| 1725 | |
| 1726 | |
| 1727 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1728 | * CheckRadioButton (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1729 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1730 | BOOL WINAPI CheckRadioButton( HWND hwndDlg, UINT firstID, |
Luc Tourangeau | 8e238d0 | 1999-05-29 14:19:42 +0000 | [diff] [blame] | 1731 | UINT lastID, UINT checkID ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1732 | { |
Luc Tourangeau | 8e238d0 | 1999-05-29 14:19:42 +0000 | [diff] [blame] | 1733 | RADIOGROUP radioGroup; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1734 | |
Luc Tourangeau | 8e238d0 | 1999-05-29 14:19:42 +0000 | [diff] [blame] | 1735 | /* perform bounds checking for a radio button group */ |
| 1736 | radioGroup.firstID = min(min(firstID, lastID), checkID); |
| 1737 | radioGroup.lastID = max(max(firstID, lastID), checkID); |
| 1738 | radioGroup.checkID = checkID; |
| 1739 | |
| 1740 | return EnumChildWindows(hwndDlg, (WNDENUMPROC)CheckRB, |
| 1741 | (LPARAM)&radioGroup); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1742 | } |
| 1743 | |
| 1744 | |
| 1745 | /*********************************************************************** |
Patrik Stridvall | 01d5e5b | 2001-07-02 19:59:40 +0000 | [diff] [blame] | 1746 | * GetDialogBaseUnits (USER.243) |
| 1747 | * GetDialogBaseUnits (USER32.@) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1748 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1749 | DWORD WINAPI GetDialogBaseUnits(void) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1750 | { |
| 1751 | return MAKELONG( xBaseUnit, yBaseUnit ); |
| 1752 | } |
| 1753 | |
| 1754 | |
| 1755 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1756 | * MapDialogRect (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1757 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1758 | BOOL WINAPI MapDialogRect( HWND hwnd, LPRECT rect ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1759 | { |
| 1760 | DIALOGINFO * dlgInfo; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1761 | if (!(dlgInfo = DIALOG_get_info( hwnd ))) return FALSE; |
Francis Beaudet | eb13dd4 | 1999-09-03 15:14:27 +0000 | [diff] [blame] | 1762 | rect->left = MulDiv(rect->left, dlgInfo->xBaseUnit, 4); |
| 1763 | rect->right = MulDiv(rect->right, dlgInfo->xBaseUnit, 4); |
| 1764 | rect->top = MulDiv(rect->top, dlgInfo->yBaseUnit, 8); |
| 1765 | rect->bottom = MulDiv(rect->bottom, dlgInfo->yBaseUnit, 8); |
Eric Pouech | b9544f1 | 1999-02-14 14:09:42 +0000 | [diff] [blame] | 1766 | return TRUE; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1767 | } |
| 1768 | |
| 1769 | |
| 1770 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1771 | * GetNextDlgGroupItem (USER32.@) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1772 | */ |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1773 | HWND WINAPI GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1774 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1775 | HWND hwnd, retvalue; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1776 | |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 1777 | hwndDlg = WIN_GetFullHandle( hwndDlg ); |
| 1778 | hwndCtrl = WIN_GetFullHandle( hwndCtrl ); |
| 1779 | |
Alexandre Julliard | e6b82e7 | 1999-12-12 20:17:59 +0000 | [diff] [blame] | 1780 | if(hwndCtrl) |
| 1781 | { |
Alexandre Julliard | 908464d | 2000-11-01 03:11:12 +0000 | [diff] [blame] | 1782 | /* if the hwndCtrl is the child of the control in the hwndDlg, |
| 1783 | * then the hwndDlg has to be the parent of the hwndCtrl */ |
Alexandre Julliard | e6b82e7 | 1999-12-12 20:17:59 +0000 | [diff] [blame] | 1784 | if(GetParent(hwndCtrl) != hwndDlg && GetParent(GetParent(hwndCtrl)) == hwndDlg) |
| 1785 | hwndDlg = GetParent(hwndCtrl); |
| 1786 | } |
| 1787 | |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1788 | if (hwndCtrl) |
| 1789 | { |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1790 | /* Make sure hwndCtrl is a top-level child */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1791 | HWND parent = GetParent( hwndCtrl ); |
| 1792 | while (parent && parent != hwndDlg) parent = GetParent(parent); |
| 1793 | if (parent != hwndDlg) return 0; |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1794 | } |
| 1795 | else |
| 1796 | { |
| 1797 | /* No ctrl specified -> start from the beginning */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1798 | if (!(hwndCtrl = GetWindow( hwndDlg, GW_CHILD ))) return 0; |
| 1799 | if (fPrevious) hwndCtrl = GetWindow( hwndCtrl, GW_HWNDLAST ); |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1800 | } |
| 1801 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1802 | retvalue = hwndCtrl; |
| 1803 | hwnd = GetWindow( hwndCtrl, GW_HWNDNEXT ); |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1804 | while (1) |
| 1805 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1806 | if (!hwnd || (GetWindowLongW( hwnd, GWL_STYLE ) & WS_GROUP)) |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1807 | { |
| 1808 | /* Wrap-around to the beginning of the group */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1809 | HWND tmp; |
Ulrich Weigand | 9c3b18f | 1999-05-17 14:54:09 +0000 | [diff] [blame] | 1810 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1811 | hwnd = GetWindow( hwndDlg, GW_CHILD ); |
| 1812 | for (tmp = hwnd; tmp; tmp = GetWindow( tmp, GW_HWNDNEXT ) ) |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1813 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1814 | if (GetWindowLongW( tmp, GWL_STYLE ) & WS_GROUP) hwnd = tmp; |
| 1815 | if (tmp == hwndCtrl) break; |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1816 | } |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1817 | } |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1818 | if (hwnd == hwndCtrl) break; |
| 1819 | if ((GetWindowLongW( hwnd, GWL_STYLE ) & (WS_VISIBLE|WS_DISABLED)) == WS_VISIBLE) |
| 1820 | { |
| 1821 | retvalue = hwnd; |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1822 | if (!fPrevious) break; |
| 1823 | } |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1824 | hwnd = GetWindow( hwnd, GW_HWNDNEXT ); |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1825 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1826 | return retvalue; |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1827 | } |
| 1828 | |
| 1829 | |
| 1830 | /*********************************************************************** |
Ulrich Czekalla | 1720c98 | 1999-10-31 21:35:35 +0000 | [diff] [blame] | 1831 | * DIALOG_GetNextTabItem |
| 1832 | * |
| 1833 | * Helper for GetNextDlgTabItem |
| 1834 | */ |
| 1835 | static HWND DIALOG_GetNextTabItem( HWND hwndMain, HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious ) |
| 1836 | { |
| 1837 | LONG dsStyle; |
| 1838 | LONG exStyle; |
| 1839 | UINT wndSearch = fPrevious ? GW_HWNDPREV : GW_HWNDNEXT; |
| 1840 | HWND retWnd = 0; |
| 1841 | HWND hChildFirst = 0; |
| 1842 | |
| 1843 | if(!hwndCtrl) |
| 1844 | { |
| 1845 | hChildFirst = GetWindow(hwndDlg,GW_CHILD); |
| 1846 | if(fPrevious) hChildFirst = GetWindow(hChildFirst,GW_HWNDLAST); |
| 1847 | } |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1848 | else if (IsChild( hwndMain, hwndCtrl )) |
Ulrich Czekalla | 1720c98 | 1999-10-31 21:35:35 +0000 | [diff] [blame] | 1849 | { |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1850 | hChildFirst = GetWindow(hwndCtrl,wndSearch); |
| 1851 | if(!hChildFirst) |
Ulrich Czekalla | 1720c98 | 1999-10-31 21:35:35 +0000 | [diff] [blame] | 1852 | { |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1853 | if(GetParent(hwndCtrl) != hwndMain) |
| 1854 | hChildFirst = GetWindow(GetParent(hwndCtrl),wndSearch); |
| 1855 | else |
Ulrich Czekalla | 1720c98 | 1999-10-31 21:35:35 +0000 | [diff] [blame] | 1856 | { |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1857 | if(fPrevious) |
| 1858 | hChildFirst = GetWindow(hwndCtrl,GW_HWNDLAST); |
Ulrich Czekalla | 1720c98 | 1999-10-31 21:35:35 +0000 | [diff] [blame] | 1859 | else |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1860 | hChildFirst = GetWindow(hwndCtrl,GW_HWNDFIRST); |
Ulrich Czekalla | 1720c98 | 1999-10-31 21:35:35 +0000 | [diff] [blame] | 1861 | } |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1862 | } |
Ulrich Czekalla | 1720c98 | 1999-10-31 21:35:35 +0000 | [diff] [blame] | 1863 | } |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1864 | |
Ulrich Czekalla | 1720c98 | 1999-10-31 21:35:35 +0000 | [diff] [blame] | 1865 | while(hChildFirst) |
| 1866 | { |
| 1867 | BOOL bCtrl = FALSE; |
| 1868 | while(hChildFirst) |
| 1869 | { |
| 1870 | dsStyle = GetWindowLongA(hChildFirst,GWL_STYLE); |
| 1871 | exStyle = GetWindowLongA(hChildFirst,GWL_EXSTYLE); |
Alexandre Julliard | e6b82e7 | 1999-12-12 20:17:59 +0000 | [diff] [blame] | 1872 | if( (dsStyle & DS_CONTROL || exStyle & WS_EX_CONTROLPARENT) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED)) |
Ulrich Czekalla | 1720c98 | 1999-10-31 21:35:35 +0000 | [diff] [blame] | 1873 | { |
| 1874 | bCtrl=TRUE; |
| 1875 | break; |
| 1876 | } |
| 1877 | else if( (dsStyle & WS_TABSTOP) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED)) |
| 1878 | break; |
| 1879 | hChildFirst = GetWindow(hChildFirst,wndSearch); |
| 1880 | } |
| 1881 | if(hChildFirst) |
| 1882 | { |
| 1883 | if(bCtrl) |
| 1884 | retWnd = DIALOG_GetNextTabItem(hwndMain,hChildFirst,(HWND)NULL,fPrevious ); |
| 1885 | else |
| 1886 | retWnd = hChildFirst; |
| 1887 | } |
| 1888 | if(retWnd) break; |
| 1889 | hChildFirst = GetWindow(hChildFirst,wndSearch); |
| 1890 | } |
| 1891 | if(!retWnd && hwndCtrl) |
| 1892 | { |
| 1893 | HWND hParent = GetParent(hwndCtrl); |
| 1894 | while(hParent) |
| 1895 | { |
| 1896 | if(hParent == hwndMain) break; |
| 1897 | retWnd = DIALOG_GetNextTabItem(hwndMain,GetParent(hParent),hParent,fPrevious ); |
| 1898 | if(retWnd) break; |
| 1899 | hParent = GetParent(hParent); |
| 1900 | } |
| 1901 | if(!retWnd) |
| 1902 | retWnd = DIALOG_GetNextTabItem(hwndMain,hwndMain,(HWND)NULL,fPrevious ); |
| 1903 | } |
| 1904 | return retWnd; |
| 1905 | } |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1906 | |
| 1907 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1908 | * GetNextDlgTabItem (USER32.@) |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1909 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1910 | HWND WINAPI GetNextDlgTabItem( HWND hwndDlg, HWND hwndCtrl, |
| 1911 | BOOL fPrevious ) |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1912 | { |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 1913 | hwndDlg = WIN_GetFullHandle( hwndDlg ); |
| 1914 | hwndCtrl = WIN_GetFullHandle( hwndCtrl ); |
Ulrich Czekalla | 1720c98 | 1999-10-31 21:35:35 +0000 | [diff] [blame] | 1915 | return DIALOG_GetNextTabItem(hwndDlg,hwndDlg,hwndCtrl,fPrevious); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1916 | } |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1917 | |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1918 | /********************************************************************** |
| 1919 | * DIALOG_DlgDirSelect |
| 1920 | * |
| 1921 | * Helper function for DlgDirSelect* |
| 1922 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1923 | static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len, |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 1924 | INT id, BOOL unicode, BOOL combo ) |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1925 | { |
| 1926 | char *buffer, *ptr; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1927 | INT item, size; |
| 1928 | BOOL ret; |
| 1929 | HWND listbox = GetDlgItem( hwnd, id ); |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1930 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 1931 | TRACE("%04x '%s' %d\n", hwnd, str, id ); |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1932 | if (!listbox) return FALSE; |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1933 | |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 1934 | item = SendMessageA(listbox, combo ? CB_GETCURSEL : LB_GETCURSEL, 0, 0 ); |
| 1935 | if (item == LB_ERR) return FALSE; |
| 1936 | size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN : LB_GETTEXTLEN, 0, 0 ); |
| 1937 | if (size == LB_ERR) return FALSE; |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1938 | |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 1939 | if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size+1 ))) return FALSE; |
| 1940 | |
| 1941 | SendMessageA( listbox, combo ? CB_GETLBTEXT : LB_GETTEXT, item, (LPARAM)buffer ); |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1942 | |
| 1943 | if ((ret = (buffer[0] == '['))) /* drive or directory */ |
| 1944 | { |
| 1945 | if (buffer[1] == '-') /* drive */ |
| 1946 | { |
| 1947 | buffer[3] = ':'; |
| 1948 | buffer[4] = 0; |
| 1949 | ptr = buffer + 2; |
| 1950 | } |
| 1951 | else |
| 1952 | { |
| 1953 | buffer[strlen(buffer)-1] = '\\'; |
| 1954 | ptr = buffer + 1; |
| 1955 | } |
| 1956 | } |
| 1957 | else ptr = buffer; |
| 1958 | |
Alexandre Julliard | 24a62ab | 2000-11-28 22:40:56 +0000 | [diff] [blame] | 1959 | if (unicode) |
| 1960 | { |
| 1961 | if (len > 0 && !MultiByteToWideChar( CP_ACP, 0, ptr, -1, (LPWSTR)str, len )) |
| 1962 | ((LPWSTR)str)[len-1] = 0; |
| 1963 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1964 | else lstrcpynA( str, ptr, len ); |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 1965 | HeapFree( GetProcessHeap(), 0, buffer ); |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 1966 | TRACE("Returning %d '%s'\n", ret, str ); |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1967 | return ret; |
| 1968 | } |
| 1969 | |
| 1970 | |
| 1971 | /********************************************************************** |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1972 | * DIALOG_DlgDirList |
| 1973 | * |
| 1974 | * Helper function for DlgDirList* |
| 1975 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1976 | static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox, |
| 1977 | INT idStatic, UINT attrib, BOOL combo ) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1978 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1979 | HWND hwnd; |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 1980 | LPSTR orig_spec = spec; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1981 | |
| 1982 | #define SENDMSG(msg,wparam,lparam) \ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1983 | ((attrib & DDL_POSTMSGS) ? PostMessageA( hwnd, msg, wparam, lparam ) \ |
| 1984 | : SendMessageA( hwnd, msg, wparam, lparam )) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1985 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 1986 | TRACE("%04x '%s' %d %d %04x\n", |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1987 | hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib ); |
| 1988 | |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 1989 | /* If the path exists and is a directory, chdir to it */ |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 1990 | if (!spec || !spec[0] || SetCurrentDirectoryA( spec )) spec = "*.*"; |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 1991 | else |
| 1992 | { |
| 1993 | char *p, *p2; |
| 1994 | p = spec; |
| 1995 | if ((p2 = strrchr( p, '\\' ))) p = p2; |
| 1996 | if ((p2 = strrchr( p, '/' ))) p = p2; |
| 1997 | if (p != spec) |
| 1998 | { |
| 1999 | char sep = *p; |
| 2000 | *p = 0; |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 2001 | if (!SetCurrentDirectoryA( spec )) |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2002 | { |
| 2003 | *p = sep; /* Restore the original spec */ |
| 2004 | return FALSE; |
| 2005 | } |
| 2006 | spec = p + 1; |
| 2007 | } |
| 2008 | } |
| 2009 | |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 2010 | TRACE( "mask=%s\n", spec ); |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2011 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2012 | if (idLBox && ((hwnd = GetDlgItem( hDlg, idLBox )) != 0)) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2013 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2014 | SENDMSG( combo ? CB_RESETCONTENT : LB_RESETCONTENT, 0, 0 ); |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2015 | if (attrib & DDL_DIRECTORY) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2016 | { |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2017 | if (!(attrib & DDL_EXCLUSIVE)) |
| 2018 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2019 | if (SENDMSG( combo ? CB_DIR : LB_DIR, |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2020 | attrib & ~(DDL_DIRECTORY | DDL_DRIVES), |
| 2021 | (LPARAM)spec ) == LB_ERR) |
| 2022 | return FALSE; |
| 2023 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2024 | if (SENDMSG( combo ? CB_DIR : LB_DIR, |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2025 | (attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE, |
| 2026 | (LPARAM)"*.*" ) == LB_ERR) |
| 2027 | return FALSE; |
| 2028 | } |
| 2029 | else |
| 2030 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2031 | if (SENDMSG( combo ? CB_DIR : LB_DIR, attrib, |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2032 | (LPARAM)spec ) == LB_ERR) |
| 2033 | return FALSE; |
| 2034 | } |
| 2035 | } |
| 2036 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2037 | if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0)) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2038 | { |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 2039 | char temp[MAX_PATH]; |
| 2040 | GetCurrentDirectoryA( sizeof(temp), temp ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2041 | CharLowerA( temp ); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2042 | /* Can't use PostMessage() here, because the string is on the stack */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2043 | SetDlgItemTextA( hDlg, idStatic, temp ); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2044 | } |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2045 | |
| 2046 | if (orig_spec && (spec != orig_spec)) |
| 2047 | { |
| 2048 | /* Update the original file spec */ |
| 2049 | char *p = spec; |
| 2050 | while ((*orig_spec++ = *p++)); |
| 2051 | } |
| 2052 | |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2053 | return TRUE; |
| 2054 | #undef SENDMSG |
| 2055 | } |
| 2056 | |
| 2057 | |
| 2058 | /********************************************************************** |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2059 | * DIALOG_DlgDirListW |
| 2060 | * |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 2061 | * Helper function for DlgDirList*W |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2062 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2063 | static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox, |
| 2064 | INT idStatic, UINT attrib, BOOL combo ) |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2065 | { |
| 2066 | if (spec) |
| 2067 | { |
| 2068 | LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2069 | INT ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic, |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2070 | attrib, combo ); |
Alexandre Julliard | 24a62ab | 2000-11-28 22:40:56 +0000 | [diff] [blame] | 2071 | MultiByteToWideChar( CP_ACP, 0, specA, -1, spec, 0x7fffffff ); |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2072 | HeapFree( GetProcessHeap(), 0, specA ); |
| 2073 | return ret; |
| 2074 | } |
| 2075 | return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo ); |
| 2076 | } |
| 2077 | |
| 2078 | |
| 2079 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2080 | * DlgDirSelectExA (USER32.@) |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 2081 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2082 | BOOL WINAPI DlgDirSelectExA( HWND hwnd, LPSTR str, INT len, INT id ) |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 2083 | { |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 2084 | return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE ); |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 2085 | } |
| 2086 | |
| 2087 | |
| 2088 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2089 | * DlgDirSelectExW (USER32.@) |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 2090 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2091 | BOOL WINAPI DlgDirSelectExW( HWND hwnd, LPWSTR str, INT len, INT id ) |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 2092 | { |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 2093 | return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, FALSE ); |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 2094 | } |
| 2095 | |
| 2096 | |
| 2097 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2098 | * DlgDirSelectComboBoxExA (USER32.@) |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 2099 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2100 | BOOL WINAPI DlgDirSelectComboBoxExA( HWND hwnd, LPSTR str, INT len, |
| 2101 | INT id ) |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 2102 | { |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 2103 | return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, TRUE ); |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 2104 | } |
| 2105 | |
| 2106 | |
| 2107 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2108 | * DlgDirSelectComboBoxExW (USER32.@) |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 2109 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2110 | BOOL WINAPI DlgDirSelectComboBoxExW( HWND hwnd, LPWSTR str, INT len, |
| 2111 | INT id) |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 2112 | { |
Alexandre Julliard | cb25e25 | 2001-08-08 23:28:42 +0000 | [diff] [blame] | 2113 | return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE ); |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 2114 | } |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2115 | |
| 2116 | |
| 2117 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2118 | * DlgDirListA (USER32.@) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2119 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2120 | INT WINAPI DlgDirListA( HWND hDlg, LPSTR spec, INT idLBox, |
| 2121 | INT idStatic, UINT attrib ) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2122 | { |
| 2123 | return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE ); |
| 2124 | } |
| 2125 | |
| 2126 | |
| 2127 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2128 | * DlgDirListW (USER32.@) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2129 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2130 | INT WINAPI DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox, |
| 2131 | INT idStatic, UINT attrib ) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2132 | { |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2133 | return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE ); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2134 | } |
| 2135 | |
| 2136 | |
| 2137 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2138 | * DlgDirListComboBoxA (USER32.@) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2139 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2140 | INT WINAPI DlgDirListComboBoxA( HWND hDlg, LPSTR spec, INT idCBox, |
| 2141 | INT idStatic, UINT attrib ) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2142 | { |
| 2143 | return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE ); |
| 2144 | } |
| 2145 | |
| 2146 | |
| 2147 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2148 | * DlgDirListComboBoxW (USER32.@) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2149 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2150 | INT WINAPI DlgDirListComboBoxW( HWND hDlg, LPWSTR spec, INT idCBox, |
| 2151 | INT idStatic, UINT attrib ) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2152 | { |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 2153 | return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE ); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2154 | } |