Sync to Wine-20050725:
[reactos.git] / reactos / lib / msi / dialog.c
1 /*
2 * Implementation of the Microsoft Installer (msi.dll)
3 *
4 * Copyright 2005 Mike McCormack for CodeWeavers
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
19 */
20
21 #define COBJMACROS
22
23 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "winnls.h"
29 #include "wingdi.h"
30 #include "msi.h"
31 #include "msipriv.h"
32 #include "msidefs.h"
33 #include "ocidl.h"
34 #include "olectl.h"
35 #include "richedit.h"
36
37 #include "wine/debug.h"
38 #include "wine/unicode.h"
39
40 #include "action.h"
41
42 WINE_DEFAULT_DEBUG_CHANNEL(msi);
43
44
45 struct msi_control_tag;
46 typedef struct msi_control_tag msi_control;
47 typedef UINT (*msi_handler)( msi_dialog *, msi_control *, WPARAM );
48
49 struct msi_control_tag
50 {
51 struct msi_control_tag *next;
52 HWND hwnd;
53 msi_handler handler;
54 LPWSTR property;
55 LPWSTR value;
56 HBITMAP hBitmap;
57 HICON hIcon;
58 LPWSTR tabnext;
59 WCHAR name[1];
60 };
61
62 typedef struct msi_font_tag
63 {
64 struct msi_font_tag *next;
65 HFONT hfont;
66 WCHAR name[1];
67 } msi_font;
68
69 struct msi_dialog_tag
70 {
71 MSIPACKAGE *package;
72 msi_dialog_event_handler event_handler;
73 BOOL finished;
74 INT scale;
75 DWORD attributes;
76 HWND hwnd;
77 LPWSTR default_font;
78 msi_font *font_list;
79 msi_control *control_list;
80 HWND hWndFocus;
81 WCHAR name[1];
82 };
83
84 typedef UINT (*msi_dialog_control_func)( msi_dialog *dialog, MSIRECORD *rec );
85 struct control_handler
86 {
87 LPCWSTR control_type;
88 msi_dialog_control_func func;
89 };
90
91 typedef struct
92 {
93 msi_dialog* dialog;
94 msi_control *parent;
95 DWORD attributes;
96 } radio_button_group_descr;
97
98 const WCHAR szMsiDialogClass[] = {
99 'M','s','i','D','i','a','l','o','g','C','l','o','s','e','C','l','a','s','s',0
100 };
101 const WCHAR szMsiHiddenWindow[] = {
102 'M','s','i','H','i','d','d','e','n','W','i','n','d','o','w',0 };
103 const static WCHAR szStatic[] = { 'S','t','a','t','i','c',0 };
104 const static WCHAR szButton[] = { 'B','U','T','T','O','N', 0 };
105 const static WCHAR szButtonData[] = { 'M','S','I','D','A','T','A',0 };
106 static const WCHAR szText[] = { 'T','e','x','t',0 };
107 static const WCHAR szPushButton[] = { 'P','u','s','h','B','u','t','t','o','n',0 };
108 static const WCHAR szLine[] = { 'L','i','n','e',0 };
109 static const WCHAR szBitmap[] = { 'B','i','t','m','a','p',0 };
110 static const WCHAR szCheckBox[] = { 'C','h','e','c','k','B','o','x',0 };
111 static const WCHAR szScrollableText[] = {
112 'S','c','r','o','l','l','a','b','l','e','T','e','x','t',0 };
113 static const WCHAR szComboBox[] = { 'C','o','m','b','o','B','o','x',0 };
114 static const WCHAR szEdit[] = { 'E','d','i','t',0 };
115 static const WCHAR szMaskedEdit[] = { 'M','a','s','k','e','d','E','d','i','t',0 };
116 static const WCHAR szPathEdit[] = { 'P','a','t','h','E','d','i','t',0 };
117 static const WCHAR szRadioButtonGroup[] = {
118 'R','a','d','i','o','B','u','t','t','o','n','G','r','o','u','p',0 };
119 static const WCHAR szIcon[] = { 'I','c','o','n',0 };
120
121 static UINT msi_dialog_checkbox_handler( msi_dialog *, msi_control *, WPARAM );
122 static void msi_dialog_checkbox_sync_state( msi_dialog *, msi_control * );
123 static UINT msi_dialog_button_handler( msi_dialog *, msi_control *, WPARAM );
124 static UINT msi_dialog_edit_handler( msi_dialog *, msi_control *, WPARAM );
125 static UINT msi_dialog_radiogroup_handler( msi_dialog *, msi_control *, WPARAM param );
126 static UINT msi_dialog_evaluate_control_conditions( msi_dialog *dialog );
127 static LRESULT WINAPI MSIRadioGroup_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
128
129
130 /* dialog sequencing */
131
132 #define WM_MSI_DIALOG_CREATE (WM_USER+0x100)
133 #define WM_MSI_DIALOG_DESTROY (WM_USER+0x101)
134
135 static DWORD uiThreadId;
136 static HWND hMsiHiddenWindow;
137 static HMODULE hRichedit;
138
139 static INT msi_dialog_scale_unit( msi_dialog *dialog, INT val )
140 {
141 return (dialog->scale * val + 5) / 10;
142 }
143
144 static msi_control *msi_dialog_find_control( msi_dialog *dialog, LPCWSTR name )
145 {
146 msi_control *control;
147
148 if( !name )
149 return NULL;
150 for( control = dialog->control_list; control; control = control->next )
151 if( !strcmpW( control->name, name ) ) /* FIXME: case sensitive? */
152 break;
153 return control;
154 }
155
156 static msi_control *msi_dialog_find_control_by_hwnd( msi_dialog *dialog, HWND hwnd )
157 {
158 msi_control *control;
159
160 for( control = dialog->control_list; control; control = control->next )
161 if( hwnd == control->hwnd )
162 break;
163 return control;
164 }
165
166 /*
167 * msi_dialog_get_style
168 *
169 * Extract the {\style} string from the front of the text to display and
170 * update the pointer.
171 */
172 static LPWSTR msi_dialog_get_style( LPCWSTR *text )
173 {
174 LPWSTR ret = NULL;
175 LPCWSTR p = *text, q;
176 DWORD len;
177
178 if( *p++ != '{' )
179 return ret;
180 q = strchrW( p, '}' );
181 if( !q )
182 return ret;
183 *text = ++q;
184 if( *p++ != '\\' )
185 return ret;
186 len = q - p;
187
188 ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
189 if( !ret )
190 return ret;
191 memcpy( ret, p, len*sizeof(WCHAR) );
192 ret[len-1] = 0;
193 return ret;
194 }
195
196 static UINT msi_dialog_add_font( MSIRECORD *rec, LPVOID param )
197 {
198 msi_dialog *dialog = param;
199 msi_font *font;
200 LPCWSTR face, name;
201 LOGFONTW lf;
202 INT style;
203 HDC hdc;
204
205 /* create a font and add it to the list */
206 name = MSI_RecordGetString( rec, 1 );
207 font = HeapAlloc( GetProcessHeap(), 0,
208 sizeof *font + strlenW( name )*sizeof (WCHAR) );
209 strcpyW( font->name, name );
210 font->next = dialog->font_list;
211 dialog->font_list = font;
212
213 memset( &lf, 0, sizeof lf );
214 face = MSI_RecordGetString( rec, 2 );
215 lf.lfHeight = MSI_RecordGetInteger( rec, 3 );
216 style = MSI_RecordGetInteger( rec, 5 );
217 if( style & msidbTextStyleStyleBitsBold )
218 lf.lfWeight = FW_BOLD;
219 if( style & msidbTextStyleStyleBitsItalic )
220 lf.lfItalic = TRUE;
221 if( style & msidbTextStyleStyleBitsUnderline )
222 lf.lfUnderline = TRUE;
223 if( style & msidbTextStyleStyleBitsStrike )
224 lf.lfStrikeOut = TRUE;
225 lstrcpynW( lf.lfFaceName, face, LF_FACESIZE );
226
227 /* adjust the height */
228 hdc = GetDC( dialog->hwnd );
229 if (hdc)
230 {
231 lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
232 ReleaseDC( dialog->hwnd, hdc );
233 }
234
235 font->hfont = CreateFontIndirectW( &lf );
236
237 TRACE("Adding font style %s\n", debugstr_w(font->name) );
238
239 return ERROR_SUCCESS;
240 }
241
242 static msi_font *msi_dialog_find_font( msi_dialog *dialog, LPCWSTR name )
243 {
244 msi_font *font;
245
246 for( font = dialog->font_list; font; font = font->next )
247 if( !strcmpW( font->name, name ) ) /* FIXME: case sensitive? */
248 break;
249
250 return font;
251 }
252
253 static UINT msi_dialog_set_font( msi_dialog *dialog, HWND hwnd, LPCWSTR name )
254 {
255 msi_font *font;
256
257 font = msi_dialog_find_font( dialog, name );
258 if( font )
259 SendMessageW( hwnd, WM_SETFONT, (WPARAM) font->hfont, TRUE );
260 else
261 ERR("No font entry for %s\n", debugstr_w(name));
262 return ERROR_SUCCESS;
263 }
264
265 static UINT msi_dialog_build_font_list( msi_dialog *dialog )
266 {
267 static const WCHAR query[] = {
268 'S','E','L','E','C','T',' ','*',' ',
269 'F','R','O','M',' ','`','T','e','x','t','S','t','y','l','e','`',' ',0
270 };
271 UINT r;
272 MSIQUERY *view = NULL;
273
274 TRACE("dialog %p\n", dialog );
275
276 r = MSI_OpenQuery( dialog->package->db, &view, query );
277 if( r != ERROR_SUCCESS )
278 return r;
279
280 r = MSI_IterateRecords( view, NULL, msi_dialog_add_font, dialog );
281 msiobj_release( &view->hdr );
282
283 return r;
284 }
285
286 static msi_control *msi_dialog_create_window( msi_dialog *dialog,
287 MSIRECORD *rec, LPCWSTR szCls, LPCWSTR name, LPCWSTR text,
288 DWORD style, HWND parent )
289 {
290 DWORD x, y, width, height;
291 LPWSTR font = NULL, title = NULL;
292 msi_control *control;
293
294 style |= WS_CHILD;
295
296 control = HeapAlloc( GetProcessHeap(), 0,
297 sizeof *control + strlenW(name)*sizeof(WCHAR) );
298 strcpyW( control->name, name );
299 control->next = dialog->control_list;
300 dialog->control_list = control;
301 control->handler = NULL;
302 control->property = NULL;
303 control->value = NULL;
304 control->hBitmap = NULL;
305 control->hIcon = NULL;
306 control->tabnext = strdupW( MSI_RecordGetString( rec, 11) );
307
308 x = MSI_RecordGetInteger( rec, 4 );
309 y = MSI_RecordGetInteger( rec, 5 );
310 width = MSI_RecordGetInteger( rec, 6 );
311 height = MSI_RecordGetInteger( rec, 7 );
312
313 x = msi_dialog_scale_unit( dialog, x );
314 y = msi_dialog_scale_unit( dialog, y );
315 width = msi_dialog_scale_unit( dialog, width );
316 height = msi_dialog_scale_unit( dialog, height );
317
318 if( text )
319 {
320 font = msi_dialog_get_style( &text );
321 deformat_string( dialog->package, text, &title );
322 }
323
324 control->hwnd = CreateWindowW( szCls, title, style,
325 x, y, width, height, parent, NULL, NULL, NULL );
326
327 TRACE("Dialog %s control %s hwnd %p\n",
328 debugstr_w(dialog->name), debugstr_w(text), control->hwnd );
329
330 msi_dialog_set_font( dialog, control->hwnd,
331 font ? font : dialog->default_font );
332
333 HeapFree( GetProcessHeap(), 0, font );
334 HeapFree( GetProcessHeap(), 0, title );
335
336 return control;
337 }
338
339 static MSIRECORD *msi_get_binary_record( MSIDATABASE *db, LPCWSTR name )
340 {
341 const static WCHAR query[] = {
342 's','e','l','e','c','t',' ','*',' ',
343 'f','r','o','m',' ','B','i','n','a','r','y',' ',
344 'w','h','e','r','e',' ',
345 '`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0
346 };
347
348 return MSI_QueryGetRecord( db, query, name );
349 }
350
351 static LPWSTR msi_create_tmp_path(void)
352 {
353 WCHAR tmp[MAX_PATH];
354 LPWSTR path = NULL;
355 static const WCHAR prefix[] = { 'm','s','i',0 };
356 DWORD len, r;
357
358 r = GetTempPathW( MAX_PATH, tmp );
359 if( !r )
360 return path;
361 len = lstrlenW( tmp ) + 20;
362 path = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
363 if( path )
364 {
365 r = GetTempFileNameW( tmp, prefix, 0, path );
366 if (!r)
367 {
368 HeapFree( GetProcessHeap(), 0, path );
369 path = NULL;
370 }
371 }
372 return path;
373 }
374
375
376 static HANDLE msi_load_image( MSIDATABASE *db, LPCWSTR name, UINT type,
377 UINT cx, UINT cy, UINT flags )
378 {
379 MSIRECORD *rec = NULL;
380 HANDLE himage = NULL;
381 LPWSTR tmp;
382 UINT r;
383
384 TRACE("%p %s %u %u %08x\n", db, debugstr_w(name), cx, cy, flags);
385
386 tmp = msi_create_tmp_path();
387 if( !tmp )
388 return himage;
389
390 rec = msi_get_binary_record( db, name );
391 if( rec )
392 {
393 r = MSI_RecordStreamToFile( rec, 2, tmp );
394 if( r == ERROR_SUCCESS )
395 {
396 himage = LoadImageW( 0, tmp, type, cx, cy, flags );
397 DeleteFileW( tmp );
398 }
399 msiobj_release( &rec->hdr );
400 }
401
402 HeapFree( GetProcessHeap(), 0, tmp );
403 return himage;
404 }
405
406 static HICON msi_load_icon( MSIDATABASE *db, LPCWSTR text, UINT attributes )
407 {
408 DWORD cx = 0, cy = 0, flags;
409
410 flags = LR_LOADFROMFILE | LR_DEFAULTSIZE;
411 if( attributes & msidbControlAttributesFixedSize )
412 {
413 flags &= ~LR_DEFAULTSIZE;
414 if( attributes & msidbControlAttributesIconSize16 )
415 {
416 cx += 16;
417 cy += 16;
418 }
419 if( attributes & msidbControlAttributesIconSize32 )
420 {
421 cx += 32;
422 cy += 32;
423 }
424 /* msidbControlAttributesIconSize48 handled by above logic */
425 }
426 return msi_load_image( db, text, IMAGE_ICON, cx, cy, flags );
427 }
428
429
430 /* called from the Control Event subscription code */
431 void msi_dialog_handle_event( msi_dialog* dialog, LPCWSTR control,
432 LPCWSTR attribute, MSIRECORD *rec )
433 {
434 msi_control* ctrl;
435 LPCWSTR text;
436
437 ctrl = msi_dialog_find_control( dialog, control );
438 if (!ctrl)
439 return;
440 if( lstrcmpW(attribute, szText) )
441 return;
442 text = MSI_RecordGetString( rec , 1 );
443 SetWindowTextW( ctrl->hwnd, text );
444 msi_dialog_check_messages( NULL );
445 }
446
447 static void msi_dialog_map_events(msi_dialog* dialog, LPCWSTR control)
448 {
449 static WCHAR Query[] = {
450 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
451 '`','E','v','e','n','t','M','a','p','p','i','n','g','`',' ',
452 'W','H','E','R','E',' ',
453 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ',
454 'A','N','D',' ',
455 '`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',0
456 };
457 MSIRECORD *row;
458 LPCWSTR event, attribute;
459
460 row = MSI_QueryGetRecord( dialog->package->db, Query, dialog->name, control );
461 if (!row)
462 return;
463
464 event = MSI_RecordGetString( row, 3 );
465 attribute = MSI_RecordGetString( row, 4 );
466 ControlEvent_SubscribeToEvent( dialog->package, event, control, attribute );
467 msiobj_release( &row->hdr );
468 }
469
470 /* everything except radio buttons */
471 static msi_control *msi_dialog_add_control( msi_dialog *dialog,
472 MSIRECORD *rec, LPCWSTR szCls, DWORD style )
473 {
474 DWORD attributes;
475 LPCWSTR text, name;
476
477 name = MSI_RecordGetString( rec, 2 );
478 attributes = MSI_RecordGetInteger( rec, 8 );
479 text = MSI_RecordGetString( rec, 10 );
480 if( attributes & msidbControlAttributesVisible )
481 style |= WS_VISIBLE;
482 if( ~attributes & msidbControlAttributesEnabled )
483 style |= WS_DISABLED;
484
485 msi_dialog_map_events(dialog, name);
486
487 return msi_dialog_create_window( dialog, rec, szCls, name, text,
488 style, dialog->hwnd );
489 }
490
491 struct msi_text_info
492 {
493 WNDPROC oldproc;
494 DWORD attributes;
495 };
496
497 /*
498 * we don't erase our own background,
499 * so we have to make sure that the parent window redraws first
500 */
501 static void msi_text_on_settext( HWND hWnd )
502 {
503 HWND hParent;
504 RECT rc;
505
506 hParent = GetParent( hWnd );
507 GetWindowRect( hWnd, &rc );
508 MapWindowPoints( NULL, hParent, (LPPOINT) &rc, 2 );
509 InvalidateRect( hParent, &rc, TRUE );
510 }
511
512 static LRESULT WINAPI
513 MSIText_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
514 {
515 struct msi_text_info *info;
516 LRESULT r = 0;
517
518 TRACE("%p %04x %08x %08lx\n", hWnd, msg, wParam, lParam);
519
520 info = GetPropW(hWnd, szButtonData);
521
522 if( msg == WM_CTLCOLORSTATIC &&
523 ( info->attributes & msidbControlAttributesTransparent ) )
524 {
525 SetBkMode( (HDC)wParam, TRANSPARENT );
526 return (LRESULT) GetStockObject(NULL_BRUSH);
527 }
528
529 r = CallWindowProcW(info->oldproc, hWnd, msg, wParam, lParam);
530
531 switch( msg )
532 {
533 case WM_SETTEXT:
534 msi_text_on_settext( hWnd );
535 break;
536 case WM_NCDESTROY:
537 HeapFree( GetProcessHeap(), 0, info );
538 RemovePropW( hWnd, szButtonData );
539 break;
540 }
541
542 return r;
543 }
544
545 static UINT msi_dialog_text_control( msi_dialog *dialog, MSIRECORD *rec )
546 {
547 msi_control *control;
548 struct msi_text_info *info;
549
550 TRACE("%p %p\n", dialog, rec);
551
552 control = msi_dialog_add_control( dialog, rec, szStatic, SS_LEFT | WS_GROUP );
553 if( !control )
554 return ERROR_FUNCTION_FAILED;
555
556 info = HeapAlloc( GetProcessHeap(), 0, sizeof *info );
557 if( !info )
558 return ERROR_SUCCESS;
559
560 info->attributes = MSI_RecordGetInteger( rec, 8 );
561 if( info->attributes & msidbControlAttributesTransparent )
562 SetWindowLongPtrW( control->hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT );
563
564 info->oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
565 (LONG_PTR)MSIText_WndProc );
566 SetPropW( control->hwnd, szButtonData, info );
567
568 return ERROR_SUCCESS;
569 }
570
571 static UINT msi_dialog_button_control( msi_dialog *dialog, MSIRECORD *rec )
572 {
573 msi_control *control;
574 UINT attributes, style;
575 LPCWSTR text;
576
577 TRACE("%p %p\n", dialog, rec);
578
579 style = WS_TABSTOP;
580 attributes = MSI_RecordGetInteger( rec, 8 );
581 if( attributes & msidbControlAttributesIcon )
582 style |= BS_ICON;
583
584 control = msi_dialog_add_control( dialog, rec, szButton, style );
585 if( !control )
586 return ERROR_FUNCTION_FAILED;
587
588 control->handler = msi_dialog_button_handler;
589
590 /* set the icon */
591 text = MSI_RecordGetString( rec, 10 );
592 control->hIcon = msi_load_icon( dialog->package->db, text, attributes );
593 if( attributes & msidbControlAttributesIcon )
594 SendMessageW( control->hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM) control->hIcon );
595
596 return ERROR_SUCCESS;
597 }
598
599 static LPWSTR msi_get_checkbox_value( msi_dialog *dialog, LPCWSTR prop )
600 {
601 const static WCHAR query[] = {
602 'S','E','L','E','C','T',' ','*',' ',
603 'F','R','O','M',' ','`','C','h','e','c','k','B','o','x',' ','`',
604 'W','H','E','R','E',' ',
605 '`','P','r','o','p','e','r','t','y','`',' ','=',' ',
606 '\'','%','s','\'',0
607 };
608 MSIRECORD *rec = NULL;
609 LPCWSTR val = NULL;
610 LPWSTR ret = NULL;
611
612 /* find if there is a value associated with the checkbox */
613 rec = MSI_QueryGetRecord( dialog->package->db, query, prop );
614 if (!rec)
615 return ret;
616
617 val = MSI_RecordGetString( rec, 2 );
618 if (val)
619 {
620 deformat_string( dialog->package, val, &ret );
621 if( ret && !ret[0] )
622 {
623 HeapFree( GetProcessHeap(), 0, ret );
624 ret = NULL;
625 }
626 }
627 msiobj_release( &rec->hdr );
628 if (ret)
629 return ret;
630
631 ret = load_dynamic_property(dialog->package, prop, NULL);
632 if( ret && !ret[0] )
633 {
634 HeapFree( GetProcessHeap(), 0, ret );
635 ret = NULL;
636 }
637
638 return ret;
639 }
640
641 static UINT msi_dialog_checkbox_control( msi_dialog *dialog, MSIRECORD *rec )
642 {
643 msi_control *control;
644 LPCWSTR prop;
645
646 TRACE("%p %p\n", dialog, rec);
647
648 control = msi_dialog_add_control( dialog, rec, szButton,
649 BS_CHECKBOX | BS_MULTILINE | WS_TABSTOP );
650 control->handler = msi_dialog_checkbox_handler;
651 prop = MSI_RecordGetString( rec, 9 );
652 if( prop )
653 {
654 control->property = strdupW( prop );
655 control->value = msi_get_checkbox_value( dialog, prop );
656 TRACE("control %s value %s\n", debugstr_w(control->property),
657 debugstr_w(control->value));
658 }
659 msi_dialog_checkbox_sync_state( dialog, control );
660
661 return ERROR_SUCCESS;
662 }
663
664 static UINT msi_dialog_line_control( msi_dialog *dialog, MSIRECORD *rec )
665 {
666 TRACE("%p %p\n", dialog, rec);
667
668 msi_dialog_add_control( dialog, rec, szStatic, SS_ETCHEDHORZ | SS_SUNKEN );
669 return ERROR_SUCCESS;
670 }
671
672 struct msi_streamin_info
673 {
674 LPSTR string;
675 DWORD offset;
676 DWORD length;
677 };
678
679 static DWORD CALLBACK
680 msi_richedit_stream_in( DWORD_PTR arg, LPBYTE buffer, LONG count, LONG *pcb )
681 {
682 struct msi_streamin_info *info = (struct msi_streamin_info*) arg;
683
684 if( (count + info->offset) > info->length )
685 count = info->length - info->offset;
686 memcpy( buffer, &info->string[ info->offset ], count );
687 *pcb = count;
688 info->offset += count;
689
690 TRACE("%ld/%ld\n", info->offset, info->length);
691
692 return 0;
693 }
694
695 static UINT msi_dialog_scrolltext_control( msi_dialog *dialog, MSIRECORD *rec )
696 {
697 const static WCHAR szRichEdit20W[] = {
698 'R','i','c','h','E','d','i','t','2','0','W',0
699 };
700 struct msi_streamin_info info;
701 msi_control *control;
702 LPCWSTR text;
703 EDITSTREAM es;
704 DWORD style;
705
706 style = WS_BORDER | ES_MULTILINE | WS_VSCROLL |
707 ES_READONLY | ES_AUTOVSCROLL | WS_TABSTOP;
708 control = msi_dialog_add_control( dialog, rec, szRichEdit20W, style );
709
710 text = MSI_RecordGetString( rec, 10 );
711 info.string = strdupWtoA( text );
712 info.offset = 0;
713 info.length = lstrlenA( info.string ) + 1;
714
715 es.dwCookie = (DWORD_PTR) &info;
716 es.dwError = 0;
717 es.pfnCallback = msi_richedit_stream_in;
718
719 SendMessageW( control->hwnd, EM_STREAMIN, SF_RTF, (LPARAM) &es );
720
721 HeapFree( GetProcessHeap(), 0, info.string );
722
723 return ERROR_SUCCESS;
724 }
725
726 static UINT msi_dialog_bitmap_control( msi_dialog *dialog, MSIRECORD *rec )
727 {
728 UINT cx, cy, flags, style, attributes;
729 msi_control *control;
730 LPCWSTR text;
731
732 flags = LR_LOADFROMFILE;
733 style = SS_BITMAP | SS_LEFT | WS_GROUP;
734
735 attributes = MSI_RecordGetInteger( rec, 8 );
736 if( attributes & msidbControlAttributesFixedSize )
737 {
738 flags |= LR_DEFAULTSIZE;
739 style |= SS_CENTERIMAGE;
740 }
741
742 control = msi_dialog_add_control( dialog, rec, szStatic, style );
743 text = MSI_RecordGetString( rec, 10 );
744 cx = MSI_RecordGetInteger( rec, 6 );
745 cy = MSI_RecordGetInteger( rec, 7 );
746 cx = msi_dialog_scale_unit( dialog, cx );
747 cy = msi_dialog_scale_unit( dialog, cy );
748
749 control->hBitmap = msi_load_image( dialog->package->db, text,
750 IMAGE_BITMAP, cx, cy, flags );
751 if( control->hBitmap )
752 SendMessageW( control->hwnd, STM_SETIMAGE,
753 IMAGE_BITMAP, (LPARAM) control->hBitmap );
754 else
755 ERR("Failed to load bitmap %s\n", debugstr_w(text));
756
757 return ERROR_SUCCESS;
758 }
759
760 static UINT msi_dialog_icon_control( msi_dialog *dialog, MSIRECORD *rec )
761 {
762 msi_control *control;
763 DWORD attributes;
764 LPCWSTR text;
765
766 TRACE("\n");
767
768 control = msi_dialog_add_control( dialog, rec, szStatic,
769 SS_ICON | SS_CENTERIMAGE | WS_GROUP );
770
771 attributes = MSI_RecordGetInteger( rec, 8 );
772 text = MSI_RecordGetString( rec, 10 );
773 control->hIcon = msi_load_icon( dialog->package->db, text, attributes );
774 if( control->hIcon )
775 SendMessageW( control->hwnd, STM_SETICON, (WPARAM) control->hIcon, 0 );
776 else
777 ERR("Failed to load bitmap %s\n", debugstr_w(text));
778 return ERROR_SUCCESS;
779 }
780
781 static UINT msi_dialog_combo_control( msi_dialog *dialog, MSIRECORD *rec )
782 {
783 static const WCHAR szCombo[] = { 'C','O','M','B','O','B','O','X',0 };
784
785 msi_dialog_add_control( dialog, rec, szCombo,
786 SS_BITMAP | SS_LEFT | SS_CENTERIMAGE );
787 return ERROR_SUCCESS;
788 }
789
790 static UINT msi_dialog_edit_control( msi_dialog *dialog, MSIRECORD *rec )
791 {
792 msi_control *control;
793 LPCWSTR prop;
794 LPWSTR val;
795
796 control = msi_dialog_add_control( dialog, rec, szEdit,
797 WS_BORDER | WS_TABSTOP );
798 control->handler = msi_dialog_edit_handler;
799 prop = MSI_RecordGetString( rec, 9 );
800 if( prop )
801 control->property = strdupW( prop );
802 val = load_dynamic_property( dialog->package, control->property, NULL );
803 SetWindowTextW( control->hwnd, val );
804 HeapFree( GetProcessHeap(), 0, val );
805 return ERROR_SUCCESS;
806 }
807
808 /******************** Masked Edit ********************************************/
809
810 #define MASK_MAX_GROUPS 10
811
812 struct msi_mask_group
813 {
814 UINT len;
815 UINT ofs;
816 WCHAR type;
817 HWND hwnd;
818 };
819
820 struct msi_maskedit_info
821 {
822 msi_dialog *dialog;
823 WNDPROC oldproc;
824 HWND hwnd;
825 LPWSTR prop;
826 UINT num_chars;
827 UINT num_groups;
828 struct msi_mask_group group[MASK_MAX_GROUPS];
829 };
830
831 static void msi_mask_control_change( struct msi_maskedit_info *info )
832 {
833 LPWSTR val;
834 UINT i, n, r;
835
836 val = HeapAlloc( GetProcessHeap(), 0, (info->num_chars+1)*sizeof(WCHAR) );
837 for( i=0, n=0; i<info->num_groups; i++ )
838 {
839 if( (info->group[i].len + n) > info->num_chars )
840 {
841 ERR("can't fit control %d text into template\n",i);
842 break;
843 }
844 r = GetWindowTextW( info->group[i].hwnd, &val[n], info->group[i].len+1 );
845 if( r != info->group[i].len )
846 break;
847 n += r;
848 }
849
850 TRACE("%d/%d controls were good\n", i, info->num_groups);
851
852 if( i == info->num_groups )
853 {
854 TRACE("Set property %s to %s\n",
855 debugstr_w(info->prop), debugstr_w(val) );
856 CharUpperBuffW( val, info->num_chars );
857 MSI_SetPropertyW( info->dialog->package, info->prop, val );
858 msi_dialog_evaluate_control_conditions( info->dialog );
859 }
860 HeapFree( GetProcessHeap(), 0, val );
861 }
862
863 /* now move to the next control if necessary */
864 static VOID msi_mask_next_control( struct msi_maskedit_info *info, HWND hWnd )
865 {
866 HWND hWndNext;
867 UINT len, i;
868
869 for( i=0; i<info->num_groups; i++ )
870 if( info->group[i].hwnd == hWnd )
871 break;
872
873 /* don't move from the last control */
874 if( i >= (info->num_groups-1) )
875 return;
876
877 len = SendMessageW( hWnd, WM_GETTEXTLENGTH, 0, 0 );
878 if( len < info->group[i].len )
879 return;
880
881 hWndNext = GetNextDlgTabItem( GetParent( hWnd ), hWnd, FALSE );
882 SetFocus( hWndNext );
883 }
884
885 static LRESULT WINAPI
886 MSIMaskedEdit_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
887 {
888 struct msi_maskedit_info *info;
889 HRESULT r;
890
891 TRACE("%p %04x %08x %08lx\n", hWnd, msg, wParam, lParam);
892
893 info = GetPropW(hWnd, szButtonData);
894
895 r = CallWindowProcW(info->oldproc, hWnd, msg, wParam, lParam);
896
897 switch( msg )
898 {
899 case WM_COMMAND:
900 if (HIWORD(wParam) == EN_CHANGE)
901 {
902 msi_mask_control_change( info );
903 msi_mask_next_control( info, (HWND) lParam );
904 }
905 break;
906 case WM_NCDESTROY:
907 HeapFree( GetProcessHeap(), 0, info->prop );
908 HeapFree( GetProcessHeap(), 0, info );
909 RemovePropW( hWnd, szButtonData );
910 break;
911 }
912
913 return r;
914 }
915
916 /* fish the various bits of the property out and put them in the control */
917 static void
918 msi_maskedit_set_text( struct msi_maskedit_info *info, LPCWSTR text )
919 {
920 LPCWSTR p;
921 UINT i;
922
923 p = text;
924 for( i = 0; i < info->num_groups; i++ )
925 {
926 if( info->group[i].len < lstrlenW( p ) )
927 {
928 LPWSTR chunk = strdupW( p );
929 chunk[ info->group[i].len ] = 0;
930 SetWindowTextW( info->group[i].hwnd, chunk );
931 HeapFree( GetProcessHeap(), 0, chunk );
932 }
933 else
934 {
935 SetWindowTextW( info->group[i].hwnd, p );
936 break;
937 }
938 p += info->group[i].len;
939 }
940 }
941
942 static struct msi_maskedit_info * msi_dialog_parse_groups( LPCWSTR mask )
943 {
944 struct msi_maskedit_info * info = NULL;
945 int i = 0, n = 0, total = 0;
946 LPCWSTR p;
947
948 TRACE("masked control, template %s\n", debugstr_w(mask));
949
950 if( !mask )
951 return info;
952
953 p = strchrW(mask, '<');
954 if( !p )
955 return info;
956
957 info = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof *info );
958 if( !info )
959 return info;
960
961 p++;
962 for( i=0; i<MASK_MAX_GROUPS; i++ )
963 {
964 /* stop at the end of the string */
965 if( p[0] == 0 || p[0] == '>' )
966 break;
967
968 /* count the number of the same identifier */
969 for( n=0; p[n] == p[0]; n++ )
970 ;
971 info->group[i].ofs = total;
972 info->group[i].type = p[0];
973 if( p[n] == '=' )
974 {
975 n++;
976 total++; /* an extra not part of the group */
977 }
978 info->group[i].len = n;
979 total += n;
980 p += n;
981 }
982
983 TRACE("%d characters in %d groups\n", total, info->num_groups );
984 if( i == MASK_MAX_GROUPS )
985 ERR("too many groups in PIDTemplate %s\n", debugstr_w(mask));
986
987 info->num_chars = total;
988 info->num_groups = i;
989
990 return info;
991 }
992
993 static void
994 msi_maskedit_create_children( struct msi_maskedit_info *info )
995 {
996 DWORD width, height, style, wx, ww;
997 LPCWSTR text, font = NULL;
998 RECT rect;
999 HWND hwnd;
1000 UINT i;
1001
1002 style = WS_CHILD | WS_BORDER | WS_VISIBLE | WS_TABSTOP;
1003
1004 GetClientRect( info->hwnd, &rect );
1005
1006 width = rect.right - rect.left;
1007 height = rect.bottom - rect.top;
1008
1009 if( text )
1010 font = msi_dialog_get_style( &text );
1011
1012 for( i = 0; i < info->num_groups; i++ )
1013 {
1014 wx = (info->group[i].ofs * width) / info->num_chars;
1015 ww = (info->group[i].len * width) / info->num_chars;
1016
1017 hwnd = CreateWindowW( szEdit, NULL, style, wx, 0, ww, height,
1018 info->hwnd, NULL, NULL, NULL );
1019 if( !hwnd )
1020 {
1021 ERR("failed to create mask edit sub window\n");
1022 break;
1023 }
1024
1025 SendMessageW( hwnd, EM_LIMITTEXT, info->group[i].len, 0 );
1026
1027 msi_dialog_set_font( info->dialog, hwnd,
1028 font ? font : info->dialog->default_font );
1029 info->group[i].hwnd = hwnd;
1030 }
1031 }
1032
1033 /* office 2003 uses "73931<````=````=````=````=`````>@@@@@" */
1034 static UINT msi_dialog_maskedit_control( msi_dialog *dialog, MSIRECORD *rec )
1035 {
1036 const static WCHAR pidt[] = {'P','I','D','T','e','m','p','l','a','t','e',0};
1037 LPWSTR mask = NULL, title = NULL, val = NULL;
1038 struct msi_maskedit_info *info = NULL;
1039 UINT ret = ERROR_SUCCESS;
1040 msi_control *control;
1041 LPCWSTR prop;
1042
1043 mask = load_dynamic_property( dialog->package, pidt, NULL );
1044 if( !mask )
1045 {
1046 ERR("PIDTemplate is empty\n");
1047 goto end;
1048 }
1049
1050 info = msi_dialog_parse_groups( mask );
1051 if( !info )
1052 {
1053 ERR("template %s is invalid\n", debugstr_w(mask));
1054 goto end;
1055 }
1056
1057 info->dialog = dialog;
1058
1059 control = msi_dialog_add_control( dialog, rec, szStatic,
1060 SS_OWNERDRAW | WS_GROUP | WS_VISIBLE );
1061 if( !control )
1062 {
1063 ERR("Failed to create maskedit container\n");
1064 ret = ERROR_FUNCTION_FAILED;
1065 goto end;
1066 }
1067 SetWindowLongPtrW( control->hwnd, GWL_EXSTYLE, WS_EX_CONTROLPARENT );
1068
1069 info->hwnd = control->hwnd;
1070
1071 /* subclass the static control */
1072 info->oldproc = (WNDPROC) SetWindowLongPtrW( info->hwnd, GWLP_WNDPROC,
1073 (LONG_PTR)MSIMaskedEdit_WndProc );
1074 SetPropW( control->hwnd, szButtonData, info );
1075
1076 prop = MSI_RecordGetString( rec, 9 );
1077 if( prop )
1078 info->prop = strdupW( prop );
1079
1080 msi_maskedit_create_children( info );
1081
1082 if( prop )
1083 {
1084 val = load_dynamic_property( dialog->package, prop, NULL );
1085 if( val )
1086 {
1087 msi_maskedit_set_text( info, val );
1088 HeapFree( GetProcessHeap(), 0, val );
1089 }
1090 }
1091
1092 end:
1093 if( ret != ERROR_SUCCESS )
1094 HeapFree( GetProcessHeap(), 0, info );
1095 HeapFree( GetProcessHeap(), 0, title );
1096 HeapFree( GetProcessHeap(), 0, mask );
1097 return ret;
1098 }
1099
1100 /******************** Path Edit ********************************************/
1101
1102 static UINT msi_dialog_pathedit_control( msi_dialog *dialog, MSIRECORD *rec )
1103 {
1104 FIXME("not implemented properly\n");
1105 return msi_dialog_edit_control( dialog, rec );
1106 }
1107
1108 /* radio buttons are a bit different from normal controls */
1109 static UINT msi_dialog_create_radiobutton( MSIRECORD *rec, LPVOID param )
1110 {
1111 radio_button_group_descr *group = (radio_button_group_descr *)param;
1112 msi_dialog *dialog = group->dialog;
1113 msi_control *control;
1114 LPCWSTR prop, text, name;
1115 DWORD style;
1116 DWORD attributes = group->attributes;
1117
1118 style = WS_CHILD | BS_AUTORADIOBUTTON | BS_MULTILINE | WS_TABSTOP;
1119 name = MSI_RecordGetString( rec, 3 );
1120 text = MSI_RecordGetString( rec, 8 );
1121 if( attributes & 1 )
1122 style |= WS_VISIBLE;
1123 if( ~attributes & 2 )
1124 style |= WS_DISABLED;
1125
1126 control = msi_dialog_create_window( dialog, rec, szButton, name, text,
1127 style, group->parent->hwnd );
1128 control->handler = msi_dialog_radiogroup_handler;
1129
1130 prop = MSI_RecordGetString( rec, 1 );
1131 if( prop )
1132 control->property = strdupW( prop );
1133
1134 return ERROR_SUCCESS;
1135 }
1136
1137 static UINT msi_dialog_radiogroup_control( msi_dialog *dialog, MSIRECORD *rec )
1138 {
1139 static const WCHAR query[] = {
1140 'S','E','L','E','C','T',' ','*',' ',
1141 'F','R','O','M',' ','R','a','d','i','o','B','u','t','t','o','n',' ',
1142 'W','H','E','R','E',' ',
1143 '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
1144 UINT r;
1145 LPCWSTR prop;
1146 msi_control *control;
1147 MSIQUERY *view = NULL;
1148 radio_button_group_descr group;
1149 MSIPACKAGE *package = dialog->package;
1150 WNDPROC oldproc;
1151
1152 prop = MSI_RecordGetString( rec, 9 );
1153
1154 TRACE("%p %p %s\n", dialog, rec, debugstr_w( prop ));
1155
1156 /* Create parent group box to hold radio buttons */
1157 control = msi_dialog_add_control( dialog, rec, szButton, BS_OWNERDRAW|WS_GROUP );
1158 if( !control )
1159 return ERROR_FUNCTION_FAILED;
1160
1161 oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
1162 (LONG_PTR)MSIRadioGroup_WndProc );
1163 SetPropW(control->hwnd, szButtonData, oldproc);
1164 SetWindowLongPtrW( control->hwnd, GWL_EXSTYLE, WS_EX_CONTROLPARENT );
1165
1166 if( prop )
1167 control->property = strdupW( prop );
1168
1169 /* query the Radio Button table for all control in this group */
1170 r = MSI_OpenQuery( package->db, &view, query, prop );
1171 if( r != ERROR_SUCCESS )
1172 {
1173 ERR("query failed for dialog %s radio group %s\n",
1174 debugstr_w(dialog->name), debugstr_w(prop));
1175 return ERROR_INVALID_PARAMETER;
1176 }
1177
1178 group.dialog = dialog;
1179 group.parent = control;
1180 group.attributes = MSI_RecordGetInteger( rec, 8 );
1181
1182 r = MSI_IterateRecords( view, 0, msi_dialog_create_radiobutton, &group );
1183 msiobj_release( &view->hdr );
1184
1185 return r;
1186 }
1187
1188 struct control_handler msi_dialog_handler[] =
1189 {
1190 { szText, msi_dialog_text_control },
1191 { szPushButton, msi_dialog_button_control },
1192 { szLine, msi_dialog_line_control },
1193 { szBitmap, msi_dialog_bitmap_control },
1194 { szCheckBox, msi_dialog_checkbox_control },
1195 { szScrollableText, msi_dialog_scrolltext_control },
1196 { szComboBox, msi_dialog_combo_control },
1197 { szEdit, msi_dialog_edit_control },
1198 { szMaskedEdit, msi_dialog_maskedit_control },
1199 { szPathEdit, msi_dialog_pathedit_control },
1200 { szRadioButtonGroup, msi_dialog_radiogroup_control },
1201 { szIcon, msi_dialog_icon_control },
1202 };
1203
1204 #define NUM_CONTROL_TYPES (sizeof msi_dialog_handler/sizeof msi_dialog_handler[0])
1205
1206 static UINT msi_dialog_create_controls( MSIRECORD *rec, LPVOID param )
1207 {
1208 msi_dialog *dialog = param;
1209 LPCWSTR control_type;
1210 UINT i;
1211
1212 /* find and call the function that can create this type of control */
1213 control_type = MSI_RecordGetString( rec, 3 );
1214 for( i=0; i<NUM_CONTROL_TYPES; i++ )
1215 if (!strcmpiW( msi_dialog_handler[i].control_type, control_type ))
1216 break;
1217 if( i != NUM_CONTROL_TYPES )
1218 msi_dialog_handler[i].func( dialog, rec );
1219 else
1220 ERR("no handler for element type %s\n", debugstr_w(control_type));
1221
1222 return ERROR_SUCCESS;
1223 }
1224
1225 static UINT msi_dialog_fill_controls( msi_dialog *dialog )
1226 {
1227 static const WCHAR query[] = {
1228 'S','E','L','E','C','T',' ','*',' ',
1229 'F','R','O','M',' ','C','o','n','t','r','o','l',' ',
1230 'W','H','E','R','E',' ',
1231 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0};
1232 UINT r;
1233 MSIQUERY *view = NULL;
1234 MSIPACKAGE *package = dialog->package;
1235
1236 TRACE("%p %s\n", dialog, debugstr_w(dialog->name) );
1237
1238 /* query the Control table for all the elements of the control */
1239 r = MSI_OpenQuery( package->db, &view, query, dialog->name );
1240 if( r != ERROR_SUCCESS )
1241 {
1242 ERR("query failed for dialog %s\n", debugstr_w(dialog->name));
1243 return ERROR_INVALID_PARAMETER;
1244 }
1245
1246 r = MSI_IterateRecords( view, 0, msi_dialog_create_controls, dialog );
1247 msiobj_release( &view->hdr );
1248
1249 return r;
1250 }
1251
1252 static UINT msi_dialog_set_control_condition( MSIRECORD *rec, LPVOID param )
1253 {
1254 static const WCHAR szHide[] = { 'H','i','d','e',0 };
1255 static const WCHAR szShow[] = { 'S','h','o','w',0 };
1256 static const WCHAR szDisable[] = { 'D','i','s','a','b','l','e',0 };
1257 static const WCHAR szEnable[] = { 'E','n','a','b','l','e',0 };
1258 msi_dialog *dialog = param;
1259 msi_control *control;
1260 LPCWSTR name, action, condition;
1261 UINT r;
1262
1263 name = MSI_RecordGetString( rec, 2 );
1264 action = MSI_RecordGetString( rec, 3 );
1265 condition = MSI_RecordGetString( rec, 4 );
1266 r = MSI_EvaluateConditionW( dialog->package, condition );
1267 control = msi_dialog_find_control( dialog, name );
1268 if( r && control )
1269 {
1270 TRACE("%s control %s\n", debugstr_w(action), debugstr_w(name));
1271
1272 /* FIXME: case sensitive? */
1273 if(!lstrcmpW(action, szHide))
1274 ShowWindow(control->hwnd, SW_HIDE);
1275 else if(!strcmpW(action, szShow))
1276 ShowWindow(control->hwnd, SW_SHOW);
1277 else if(!strcmpW(action, szDisable))
1278 EnableWindow(control->hwnd, FALSE);
1279 else if(!strcmpW(action, szEnable))
1280 EnableWindow(control->hwnd, TRUE);
1281 else
1282 FIXME("Unhandled action %s\n", debugstr_w(action));
1283 }
1284
1285 return ERROR_SUCCESS;
1286 }
1287
1288 static UINT msi_dialog_evaluate_control_conditions( msi_dialog *dialog )
1289 {
1290 static const WCHAR query[] = {
1291 'S','E','L','E','C','T',' ','*',' ',
1292 'F','R','O','M',' ',
1293 'C','o','n','t','r','o','l','C','o','n','d','i','t','i','o','n',' ',
1294 'W','H','E','R','E',' ',
1295 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0
1296 };
1297 UINT r;
1298 MSIQUERY *view = NULL;
1299 MSIPACKAGE *package = dialog->package;
1300
1301 TRACE("%p %s\n", dialog, debugstr_w(dialog->name) );
1302
1303 /* query the Control table for all the elements of the control */
1304 r = MSI_OpenQuery( package->db, &view, query, dialog->name );
1305 if( r != ERROR_SUCCESS )
1306 {
1307 ERR("query failed for dialog %s\n", debugstr_w(dialog->name));
1308 return ERROR_INVALID_PARAMETER;
1309 }
1310
1311 r = MSI_IterateRecords( view, 0, msi_dialog_set_control_condition, dialog );
1312 msiobj_release( &view->hdr );
1313
1314 return r;
1315 }
1316
1317 /* figure out the height of 10 point MS Sans Serif */
1318 static INT msi_dialog_get_sans_serif_height( HWND hwnd )
1319 {
1320 static const WCHAR szSansSerif[] = {
1321 'M','S',' ','S','a','n','s',' ','S','e','r','i','f',0 };
1322 LOGFONTW lf;
1323 TEXTMETRICW tm;
1324 BOOL r;
1325 LONG height = 0;
1326 HFONT hFont, hOldFont;
1327 HDC hdc;
1328
1329 hdc = GetDC( hwnd );
1330 if (hdc)
1331 {
1332 memset( &lf, 0, sizeof lf );
1333 lf.lfHeight = MulDiv(10, GetDeviceCaps(hdc, LOGPIXELSY), 72);
1334 strcpyW( lf.lfFaceName, szSansSerif );
1335 hFont = CreateFontIndirectW(&lf);
1336 if (hFont)
1337 {
1338 hOldFont = SelectObject( hdc, hFont );
1339 r = GetTextMetricsW( hdc, &tm );
1340 if (r)
1341 height = tm.tmHeight;
1342 SelectObject( hdc, hOldFont );
1343 DeleteObject( hFont );
1344 }
1345 ReleaseDC( hwnd, hdc );
1346 }
1347 return height;
1348 }
1349
1350 /* fetch the associated record from the Dialog table */
1351 static MSIRECORD *msi_get_dialog_record( msi_dialog *dialog )
1352 {
1353 static const WCHAR query[] = {
1354 'S','E','L','E','C','T',' ','*',' ',
1355 'F','R','O','M',' ','D','i','a','l','o','g',' ',
1356 'W','H','E','R','E',' ',
1357 '`','D','i','a','l','o','g','`',' ','=',' ','\'','%','s','\'',0};
1358 MSIPACKAGE *package = dialog->package;
1359 MSIRECORD *rec = NULL;
1360
1361 TRACE("%p %s\n", dialog, debugstr_w(dialog->name) );
1362
1363 rec = MSI_QueryGetRecord( package->db, query, dialog->name );
1364 if( !rec )
1365 ERR("query failed for dialog %s\n", debugstr_w(dialog->name));
1366
1367 return rec;
1368 }
1369
1370 static void msi_dialog_adjust_dialog_size( msi_dialog *dialog, LPSIZE sz )
1371 {
1372 RECT rect;
1373 LONG style;
1374
1375 /* turn the client size into the window rectangle */
1376 rect.left = 0;
1377 rect.top = 0;
1378 rect.right = msi_dialog_scale_unit( dialog, sz->cx );
1379 rect.bottom = msi_dialog_scale_unit( dialog, sz->cy );
1380 style = GetWindowLongPtrW( dialog->hwnd, GWL_STYLE );
1381 AdjustWindowRect( &rect, style, FALSE );
1382 sz->cx = rect.right - rect.left;
1383 sz->cy = rect.bottom - rect.top;
1384 }
1385
1386 static BOOL msi_control_set_next( msi_control *control, msi_control *next )
1387 {
1388 return SetWindowPos( next->hwnd, control->hwnd, 0, 0, 0, 0,
1389 SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW |
1390 SWP_NOREPOSITION | SWP_NOSENDCHANGING | SWP_NOSIZE );
1391 }
1392
1393 static UINT msi_dialog_set_tab_order( msi_dialog *dialog )
1394 {
1395 msi_control *control, *tab_next;
1396
1397 for( control = dialog->control_list; control; control = control->next )
1398 {
1399 tab_next = msi_dialog_find_control( dialog, control->tabnext );
1400 if( !tab_next )
1401 continue;
1402 msi_control_set_next( control, tab_next );
1403 }
1404
1405 return ERROR_SUCCESS;
1406 }
1407
1408 static void msi_dialog_set_first_control( msi_dialog* dialog, LPCWSTR name )
1409 {
1410 msi_control *control;
1411
1412 control = msi_dialog_find_control( dialog, name );
1413 if( control )
1414 dialog->hWndFocus = control->hwnd;
1415 else
1416 dialog->hWndFocus = NULL;
1417 }
1418
1419 static LRESULT msi_dialog_oncreate( HWND hwnd, LPCREATESTRUCTW cs )
1420 {
1421 static const WCHAR df[] = {
1422 'D','e','f','a','u','l','t','U','I','F','o','n','t',0 };
1423 msi_dialog *dialog = (msi_dialog*) cs->lpCreateParams;
1424 MSIRECORD *rec = NULL;
1425 LPCWSTR text;
1426 LPWSTR title = NULL;
1427 SIZE size;
1428
1429 TRACE("%p %p\n", dialog, dialog->package);
1430
1431 dialog->hwnd = hwnd;
1432 SetWindowLongPtrW( hwnd, GWLP_USERDATA, (LONG_PTR) dialog );
1433
1434 rec = msi_get_dialog_record( dialog );
1435 if( !rec )
1436 {
1437 TRACE("No record found for dialog %s\n", debugstr_w(dialog->name));
1438 return -1;
1439 }
1440
1441 dialog->scale = msi_dialog_get_sans_serif_height(dialog->hwnd);
1442
1443 size.cx = MSI_RecordGetInteger( rec, 4 );
1444 size.cy = MSI_RecordGetInteger( rec, 5 );
1445 msi_dialog_adjust_dialog_size( dialog, &size );
1446
1447 dialog->attributes = MSI_RecordGetInteger( rec, 6 );
1448 text = MSI_RecordGetString( rec, 7 );
1449
1450 dialog->default_font = load_dynamic_property( dialog->package, df, NULL );
1451
1452 deformat_string( dialog->package, text, &title );
1453 SetWindowTextW( hwnd, title );
1454 SetWindowPos( hwnd, 0, 0, 0, size.cx, size.cy,
1455 SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW );
1456
1457 HeapFree( GetProcessHeap(), 0, title );
1458
1459 msi_dialog_build_font_list( dialog );
1460 msi_dialog_fill_controls( dialog );
1461 msi_dialog_evaluate_control_conditions( dialog );
1462 msi_dialog_set_tab_order( dialog );
1463 msi_dialog_set_first_control( dialog, MSI_RecordGetString( rec, 8 ) );
1464 msiobj_release( &rec->hdr );
1465
1466 return 0;
1467 }
1468
1469 static UINT msi_dialog_send_event( msi_dialog *dialog, LPCWSTR event, LPCWSTR arg )
1470 {
1471 LPWSTR event_fmt = NULL, arg_fmt = NULL;
1472
1473 TRACE("Sending control event %s %s\n", debugstr_w(event), debugstr_w(arg));
1474
1475 deformat_string( dialog->package, event, &event_fmt );
1476 deformat_string( dialog->package, arg, &arg_fmt );
1477
1478 dialog->event_handler( dialog->package, event_fmt, arg_fmt, dialog );
1479
1480 HeapFree( GetProcessHeap(), 0, event_fmt );
1481 HeapFree( GetProcessHeap(), 0, arg_fmt );
1482
1483 return ERROR_SUCCESS;
1484 }
1485
1486 static UINT msi_dialog_set_property( msi_dialog *dialog, LPCWSTR event, LPCWSTR arg )
1487 {
1488 static const WCHAR szNullArg[] = { '{','}',0 };
1489 LPWSTR p, prop, arg_fmt = NULL;
1490 UINT len;
1491
1492 len = strlenW(event);
1493 prop = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR));
1494 strcpyW( prop, &event[1] );
1495 p = strchrW( prop, ']' );
1496 if( p && p[1] == 0 )
1497 {
1498 *p = 0;
1499 if( strcmpW( szNullArg, arg ) )
1500 deformat_string( dialog->package, arg, &arg_fmt );
1501 MSI_SetPropertyW( dialog->package, prop, arg_fmt );
1502 }
1503 else
1504 ERR("Badly formatted property string - what happens?\n");
1505 HeapFree( GetProcessHeap(), 0, prop );
1506 return ERROR_SUCCESS;
1507 }
1508
1509 static UINT msi_dialog_control_event( MSIRECORD *rec, LPVOID param )
1510 {
1511 msi_dialog *dialog = param;
1512 LPCWSTR condition, event, arg;
1513 UINT r;
1514
1515 condition = MSI_RecordGetString( rec, 5 );
1516 r = MSI_EvaluateConditionW( dialog->package, condition );
1517 if( r )
1518 {
1519 event = MSI_RecordGetString( rec, 3 );
1520 arg = MSI_RecordGetString( rec, 4 );
1521 if( event[0] == '[' )
1522 msi_dialog_set_property( dialog, event, arg );
1523 else
1524 msi_dialog_send_event( dialog, event, arg );
1525 }
1526
1527 return ERROR_SUCCESS;
1528 }
1529
1530 static UINT msi_dialog_button_handler( msi_dialog *dialog,
1531 msi_control *control, WPARAM param )
1532 {
1533 static const WCHAR query[] = {
1534 'S','E','L','E','C','T',' ','*',' ',
1535 'F','R','O','M',' ','C','o','n','t','r','o','l','E','v','e','n','t',' ',
1536 'W','H','E','R','E',' ',
1537 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ',
1538 'A','N','D',' ',
1539 '`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',' ',
1540 'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','i','n','g','`',0
1541 };
1542 MSIQUERY *view = NULL;
1543 UINT r;
1544
1545 if( HIWORD(param) != BN_CLICKED )
1546 return ERROR_SUCCESS;
1547
1548 r = MSI_OpenQuery( dialog->package->db, &view, query,
1549 dialog->name, control->name );
1550 if( r != ERROR_SUCCESS )
1551 {
1552 ERR("query failed\n");
1553 return 0;
1554 }
1555
1556 r = MSI_IterateRecords( view, 0, msi_dialog_control_event, dialog );
1557 msiobj_release( &view->hdr );
1558
1559 return r;
1560 }
1561
1562 static UINT msi_dialog_get_checkbox_state( msi_dialog *dialog,
1563 msi_control *control )
1564 {
1565 WCHAR state[2] = { 0 };
1566 DWORD sz = 2;
1567
1568 MSI_GetPropertyW( dialog->package, control->property, state, &sz );
1569 return state[0] ? 1 : 0;
1570 }
1571
1572 static void msi_dialog_set_checkbox_state( msi_dialog *dialog,
1573 msi_control *control, UINT state )
1574 {
1575 static const WCHAR szState[] = { '1', 0 };
1576 LPCWSTR val;
1577
1578 /* if uncheck then the property is set to NULL */
1579 if (!state)
1580 {
1581 MSI_SetPropertyW( dialog->package, control->property, NULL );
1582 return;
1583 }
1584
1585 /* check for a custom state */
1586 if (control->value && control->value[0])
1587 val = control->value;
1588 else
1589 val = szState;
1590
1591 MSI_SetPropertyW( dialog->package, control->property, val );
1592 }
1593
1594 static void msi_dialog_checkbox_sync_state( msi_dialog *dialog,
1595 msi_control *control )
1596 {
1597 UINT state;
1598
1599 state = msi_dialog_get_checkbox_state( dialog, control );
1600 SendMessageW( control->hwnd, BM_SETCHECK,
1601 state ? BST_CHECKED : BST_UNCHECKED, 0 );
1602 }
1603
1604 static UINT msi_dialog_checkbox_handler( msi_dialog *dialog,
1605 msi_control *control, WPARAM param )
1606 {
1607 UINT state;
1608
1609 if( HIWORD(param) != BN_CLICKED )
1610 return ERROR_SUCCESS;
1611
1612 TRACE("clicked checkbox %s, set %s\n", debugstr_w(control->name),
1613 debugstr_w(control->property));
1614
1615 state = msi_dialog_get_checkbox_state( dialog, control );
1616 state = state ? 0 : 1;
1617 msi_dialog_set_checkbox_state( dialog, control, state );
1618 msi_dialog_checkbox_sync_state( dialog, control );
1619
1620 return msi_dialog_button_handler( dialog, control, param );
1621 }
1622
1623 static UINT msi_dialog_edit_handler( msi_dialog *dialog,
1624 msi_control *control, WPARAM param )
1625 {
1626 UINT sz, r;
1627 LPWSTR buf;
1628
1629 if( HIWORD(param) != EN_CHANGE )
1630 return ERROR_SUCCESS;
1631
1632 TRACE("edit %s contents changed, set %s\n", debugstr_w(control->name),
1633 debugstr_w(control->property));
1634
1635 sz = 0x20;
1636 buf = HeapAlloc( GetProcessHeap(), 0, sz*sizeof(WCHAR) );
1637 while( buf )
1638 {
1639 r = GetWindowTextW( control->hwnd, buf, sz );
1640 if( r < (sz-1) )
1641 break;
1642 sz *= 2;
1643 buf = HeapReAlloc( GetProcessHeap(), 0, buf, sz*sizeof(WCHAR) );
1644 }
1645
1646 MSI_SetPropertyW( dialog->package, control->property, buf );
1647
1648 HeapFree( GetProcessHeap(), 0, buf );
1649
1650 return ERROR_SUCCESS;
1651 }
1652
1653 static UINT msi_dialog_radiogroup_handler( msi_dialog *dialog,
1654 msi_control *control, WPARAM param )
1655 {
1656 if( HIWORD(param) != BN_CLICKED )
1657 return ERROR_SUCCESS;
1658
1659 TRACE("clicked radio button %s, set %s\n", debugstr_w(control->name),
1660 debugstr_w(control->property));
1661
1662 MSI_SetPropertyW( dialog->package, control->property, control->name );
1663
1664 return msi_dialog_button_handler( dialog, control, param );
1665 }
1666
1667 static LRESULT msi_dialog_oncommand( msi_dialog *dialog, WPARAM param, HWND hwnd )
1668 {
1669 msi_control *control;
1670
1671 TRACE("%p %p %08x\n", dialog, hwnd, param);
1672
1673 control = msi_dialog_find_control_by_hwnd( dialog, hwnd );
1674 if( control )
1675 {
1676 if( control->handler )
1677 {
1678 control->handler( dialog, control, param );
1679 msi_dialog_evaluate_control_conditions( dialog );
1680 }
1681 }
1682 else
1683 ERR("button click from nowhere\n");
1684 return 0;
1685 }
1686
1687 static void msi_dialog_setfocus( msi_dialog *dialog )
1688 {
1689 HWND hwnd = dialog->hWndFocus;
1690
1691 hwnd = GetNextDlgTabItem( dialog->hwnd, hwnd, TRUE);
1692 hwnd = GetNextDlgTabItem( dialog->hwnd, hwnd, FALSE);
1693 SetFocus( hwnd );
1694 dialog->hWndFocus = hwnd;
1695 }
1696
1697 static LRESULT WINAPI MSIDialog_WndProc( HWND hwnd, UINT msg,
1698 WPARAM wParam, LPARAM lParam )
1699 {
1700 msi_dialog *dialog = (LPVOID) GetWindowLongPtrW( hwnd, GWLP_USERDATA );
1701
1702 TRACE("0x%04x\n", msg);
1703
1704 switch (msg)
1705 {
1706 case WM_CREATE:
1707 return msi_dialog_oncreate( hwnd, (LPCREATESTRUCTW)lParam );
1708
1709 case WM_COMMAND:
1710 return msi_dialog_oncommand( dialog, wParam, (HWND)lParam );
1711
1712 case WM_ACTIVATE:
1713 if( LOWORD(wParam) == WA_INACTIVE )
1714 dialog->hWndFocus = GetFocus();
1715 else
1716 msi_dialog_setfocus( dialog );
1717 return 0;
1718
1719 case WM_SETFOCUS:
1720 msi_dialog_setfocus( dialog );
1721 return 0;
1722
1723 /* bounce back to our subclassed static control */
1724 case WM_CTLCOLORSTATIC:
1725 return SendMessageW( (HWND) lParam, WM_CTLCOLORSTATIC, wParam, lParam );
1726
1727 case WM_DESTROY:
1728 dialog->hwnd = NULL;
1729 return 0;
1730 }
1731 return DefWindowProcW(hwnd, msg, wParam, lParam);
1732 }
1733
1734 static LRESULT WINAPI MSIRadioGroup_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
1735 {
1736 WNDPROC oldproc = (WNDPROC) GetPropW(hWnd, szButtonData);
1737
1738 TRACE("hWnd %p msg %04x wParam 0x%08x lParam 0x%08lx\n", hWnd, msg, wParam, lParam);
1739
1740 if (msg == WM_COMMAND) /* Forward notifications to dialog */
1741 SendMessageW(GetParent(hWnd), msg, wParam, lParam);
1742
1743 return CallWindowProcW(oldproc, hWnd, msg, wParam, lParam);
1744 }
1745
1746 static LRESULT WINAPI MSIHiddenWindowProc( HWND hwnd, UINT msg,
1747 WPARAM wParam, LPARAM lParam )
1748 {
1749 msi_dialog *dialog = (msi_dialog*) lParam;
1750
1751 TRACE("%d %p\n", msg, dialog);
1752
1753 switch (msg)
1754 {
1755 case WM_MSI_DIALOG_CREATE:
1756 return msi_dialog_run_message_loop( dialog );
1757 case WM_MSI_DIALOG_DESTROY:
1758 msi_dialog_destroy( dialog );
1759 return 0;
1760 }
1761 return DefWindowProcW( hwnd, msg, wParam, lParam );
1762 }
1763
1764 /* functions that interface to other modules within MSI */
1765
1766 msi_dialog *msi_dialog_create( MSIPACKAGE* package, LPCWSTR szDialogName,
1767 msi_dialog_event_handler event_handler )
1768 {
1769 MSIRECORD *rec = NULL;
1770 msi_dialog *dialog;
1771
1772 TRACE("%p %s\n", package, debugstr_w(szDialogName));
1773
1774 /* allocate the structure for the dialog to use */
1775 dialog = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
1776 sizeof *dialog + sizeof(WCHAR)*strlenW(szDialogName) );
1777 if( !dialog )
1778 return NULL;
1779 strcpyW( dialog->name, szDialogName );
1780 msiobj_addref( &package->hdr );
1781 dialog->package = package;
1782 dialog->event_handler = event_handler;
1783 dialog->finished = 0;
1784
1785 /* verify that the dialog exists */
1786 rec = msi_get_dialog_record( dialog );
1787 if( !rec )
1788 {
1789 HeapFree( GetProcessHeap(), 0, dialog );
1790 return NULL;
1791 }
1792 dialog->attributes = MSI_RecordGetInteger( rec, 6 );
1793 msiobj_release( &rec->hdr );
1794
1795 return dialog;
1796 }
1797
1798 static void msi_process_pending_messages( HWND hdlg )
1799 {
1800 MSG msg;
1801
1802 while( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ) )
1803 {
1804 if( hdlg && IsDialogMessageW( hdlg, &msg ))
1805 continue;
1806 TranslateMessage( &msg );
1807 DispatchMessageW( &msg );
1808 }
1809 }
1810
1811 void msi_dialog_end_dialog( msi_dialog *dialog )
1812 {
1813 TRACE("%p\n", dialog);
1814 dialog->finished = 1;
1815 PostMessageW(dialog->hwnd, WM_NULL, 0, 0);
1816 }
1817
1818 void msi_dialog_check_messages( HANDLE handle )
1819 {
1820 DWORD r;
1821
1822 /* in threads other than the UI thread, block */
1823 if( uiThreadId != GetCurrentThreadId() )
1824 {
1825 if( handle )
1826 WaitForSingleObject( handle, INFINITE );
1827 return;
1828 }
1829
1830 /* there's two choices for the UI thread */
1831 while (1)
1832 {
1833 msi_process_pending_messages( NULL );
1834
1835 if( !handle )
1836 break;
1837
1838 /*
1839 * block here until somebody creates a new dialog or
1840 * the handle we're waiting on becomes ready
1841 */
1842 r = MsgWaitForMultipleObjects( 1, &handle, 0, INFINITE, QS_ALLINPUT );
1843 if( r == WAIT_OBJECT_0 )
1844 break;
1845 }
1846 }
1847
1848 UINT msi_dialog_run_message_loop( msi_dialog *dialog )
1849 {
1850 HWND hwnd;
1851
1852 if( !(dialog->attributes & msidbDialogAttributesVisible) )
1853 return ERROR_SUCCESS;
1854
1855 if( uiThreadId != GetCurrentThreadId() )
1856 return SendMessageW( hMsiHiddenWindow, WM_MSI_DIALOG_CREATE, 0, (LPARAM) dialog );
1857
1858 /* create the dialog window, don't show it yet */
1859 hwnd = CreateWindowW( szMsiDialogClass, dialog->name, WS_OVERLAPPEDWINDOW,
1860 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
1861 NULL, NULL, NULL, dialog );
1862 if( !hwnd )
1863 {
1864 ERR("Failed to create dialog %s\n", debugstr_w( dialog->name ));
1865 return ERROR_FUNCTION_FAILED;
1866 }
1867
1868 ShowWindow( hwnd, SW_SHOW );
1869 UpdateWindow( hwnd );
1870
1871 if( dialog->attributes & msidbDialogAttributesModal )
1872 {
1873 while( !dialog->finished )
1874 {
1875 MsgWaitForMultipleObjects( 0, NULL, 0, INFINITE, QS_ALLEVENTS );
1876 msi_process_pending_messages( dialog->hwnd );
1877 }
1878 }
1879 else
1880 return ERROR_IO_PENDING;
1881
1882 return ERROR_SUCCESS;
1883 }
1884
1885 void msi_dialog_do_preview( msi_dialog *dialog )
1886 {
1887 TRACE("\n");
1888 dialog->attributes |= msidbDialogAttributesVisible;
1889 dialog->attributes &= ~msidbDialogAttributesModal;
1890 msi_dialog_run_message_loop( dialog );
1891 }
1892
1893 void msi_dialog_destroy( msi_dialog *dialog )
1894 {
1895 if( uiThreadId != GetCurrentThreadId() )
1896 {
1897 SendMessageW( hMsiHiddenWindow, WM_MSI_DIALOG_DESTROY, 0, (LPARAM) dialog );
1898 return;
1899 }
1900
1901 if( dialog->hwnd )
1902 ShowWindow( dialog->hwnd, SW_HIDE );
1903
1904 /* destroy the list of controls */
1905 while( dialog->control_list )
1906 {
1907 msi_control *t = dialog->control_list;
1908 dialog->control_list = t->next;
1909 /* leave dialog->hwnd - destroying parent destroys child windows */
1910 HeapFree( GetProcessHeap(), 0, t->property );
1911 HeapFree( GetProcessHeap(), 0, t->value );
1912 if( t->hBitmap )
1913 DeleteObject( t->hBitmap );
1914 if( t->hIcon )
1915 DestroyIcon( t->hIcon );
1916 HeapFree( GetProcessHeap(), 0, t->tabnext );
1917 HeapFree( GetProcessHeap(), 0, t );
1918 }
1919
1920 /* destroy the list of fonts */
1921 while( dialog->font_list )
1922 {
1923 msi_font *t = dialog->font_list;
1924 dialog->font_list = t->next;
1925 DeleteObject( t->hfont );
1926 HeapFree( GetProcessHeap(), 0, t );
1927 }
1928 HeapFree( GetProcessHeap(), 0, dialog->default_font );
1929
1930 if( dialog->hwnd )
1931 DestroyWindow( dialog->hwnd );
1932
1933 msiobj_release( &dialog->package->hdr );
1934 dialog->package = NULL;
1935 HeapFree( GetProcessHeap(), 0, dialog );
1936 }
1937
1938 BOOL msi_dialog_register_class( void )
1939 {
1940 WNDCLASSW cls;
1941
1942 ZeroMemory( &cls, sizeof cls );
1943 cls.lpfnWndProc = MSIDialog_WndProc;
1944 cls.hInstance = NULL;
1945 cls.hIcon = LoadIconW(0, (LPWSTR)IDI_APPLICATION);
1946 cls.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
1947 cls.hbrBackground = (HBRUSH)(COLOR_WINDOW);
1948 cls.lpszMenuName = NULL;
1949 cls.lpszClassName = szMsiDialogClass;
1950
1951 if( !RegisterClassW( &cls ) )
1952 return FALSE;
1953
1954 cls.lpfnWndProc = MSIHiddenWindowProc;
1955 cls.lpszClassName = szMsiHiddenWindow;
1956
1957 if( !RegisterClassW( &cls ) )
1958 return FALSE;
1959
1960 uiThreadId = GetCurrentThreadId();
1961
1962 hMsiHiddenWindow = CreateWindowW( szMsiHiddenWindow, NULL, WS_OVERLAPPED,
1963 0, 0, 100, 100, NULL, NULL, NULL, NULL );
1964 if( !hMsiHiddenWindow )
1965 return FALSE;
1966
1967 hRichedit = LoadLibraryA("riched20");
1968
1969 return TRUE;
1970 }
1971
1972 void msi_dialog_unregister_class( void )
1973 {
1974 DestroyWindow( hMsiHiddenWindow );
1975 UnregisterClassW( szMsiDialogClass, NULL );
1976 uiThreadId = 0;
1977 FreeLibrary( hRichedit );
1978 }