2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2005 Mike McCormack for CodeWeavers
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define NONAMELESSUNION
23 #define NONAMELESSSTRUCT
40 #include "wine/debug.h"
41 #include "wine/unicode.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(msi);
48 extern HINSTANCE msi_hInstance;
50 struct msi_control_tag;
51 typedef struct msi_control_tag msi_control;
52 typedef UINT (*msi_handler)( msi_dialog *, msi_control *, WPARAM );
54 struct msi_control_tag
65 float progress_current;
70 typedef struct msi_font_tag
72 struct msi_font_tag *next;
81 msi_dialog_event_handler event_handler;
90 LPWSTR control_default;
91 LPWSTR control_cancel;
95 typedef UINT (*msi_dialog_control_func)( msi_dialog *dialog, MSIRECORD *rec );
96 struct control_handler
99 msi_dialog_control_func func;
108 } radio_button_group_descr;
110 static const WCHAR szMsiDialogClass[] = {
111 'M','s','i','D','i','a','l','o','g','C','l','o','s','e','C','l','a','s','s',0
113 static const WCHAR szMsiHiddenWindow[] = {
114 'M','s','i','H','i','d','d','e','n','W','i','n','d','o','w',0 };
115 static const WCHAR szStatic[] = { 'S','t','a','t','i','c',0 };
116 static const WCHAR szButton[] = { 'B','U','T','T','O','N', 0 };
117 static const WCHAR szButtonData[] = { 'M','S','I','D','A','T','A',0 };
118 static const WCHAR szProgress[] = { 'P','r','o','g','r','e','s','s',0 };
119 static const WCHAR szText[] = { 'T','e','x','t',0 };
120 static const WCHAR szPushButton[] = { 'P','u','s','h','B','u','t','t','o','n',0 };
121 static const WCHAR szLine[] = { 'L','i','n','e',0 };
122 static const WCHAR szBitmap[] = { 'B','i','t','m','a','p',0 };
123 static const WCHAR szCheckBox[] = { 'C','h','e','c','k','B','o','x',0 };
124 static const WCHAR szScrollableText[] = {
125 'S','c','r','o','l','l','a','b','l','e','T','e','x','t',0 };
126 static const WCHAR szComboBox[] = { 'C','o','m','b','o','B','o','x',0 };
127 static const WCHAR szEdit[] = { 'E','d','i','t',0 };
128 static const WCHAR szMaskedEdit[] = { 'M','a','s','k','e','d','E','d','i','t',0 };
129 static const WCHAR szPathEdit[] = { 'P','a','t','h','E','d','i','t',0 };
130 static const WCHAR szProgressBar[] = {
131 'P','r','o','g','r','e','s','s','B','a','r',0 };
132 static const WCHAR szRadioButtonGroup[] = {
133 'R','a','d','i','o','B','u','t','t','o','n','G','r','o','u','p',0 };
134 static const WCHAR szIcon[] = { 'I','c','o','n',0 };
135 static const WCHAR szSelectionTree[] = {
136 'S','e','l','e','c','t','i','o','n','T','r','e','e',0 };
138 static UINT msi_dialog_checkbox_handler( msi_dialog *, msi_control *, WPARAM );
139 static void msi_dialog_checkbox_sync_state( msi_dialog *, msi_control * );
140 static UINT msi_dialog_button_handler( msi_dialog *, msi_control *, WPARAM );
141 static UINT msi_dialog_edit_handler( msi_dialog *, msi_control *, WPARAM );
142 static UINT msi_dialog_radiogroup_handler( msi_dialog *, msi_control *, WPARAM param );
143 static UINT msi_dialog_evaluate_control_conditions( msi_dialog *dialog );
144 static LRESULT WINAPI MSIRadioGroup_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
147 /* dialog sequencing */
149 #define WM_MSI_DIALOG_CREATE (WM_USER+0x100)
150 #define WM_MSI_DIALOG_DESTROY (WM_USER+0x101)
152 static DWORD uiThreadId;
153 static HWND hMsiHiddenWindow;
155 static INT msi_dialog_scale_unit( msi_dialog *dialog, INT val )
157 return (dialog->scale * val + 5) / 10;
160 static msi_control *msi_dialog_find_control( msi_dialog *dialog, LPCWSTR name )
162 msi_control *control;
166 LIST_FOR_EACH_ENTRY( control, &dialog->controls, msi_control, entry )
167 if( !strcmpW( control->name, name ) ) /* FIXME: case sensitive? */
172 static msi_control *msi_dialog_find_control_by_hwnd( msi_dialog *dialog, HWND hwnd )
174 msi_control *control;
176 LIST_FOR_EACH_ENTRY( control, &dialog->controls, msi_control, entry )
177 if( hwnd == control->hwnd )
182 static LPWSTR msi_get_deformatted_field( MSIPACKAGE *package, MSIRECORD *rec, int field )
184 LPCWSTR str = MSI_RecordGetString( rec, field );
188 deformat_string( package, str, &ret );
193 * msi_dialog_get_style
195 * Extract the {\style} string from the front of the text to display and
196 * update the pointer.
198 static LPWSTR msi_dialog_get_style( LPCWSTR p, LPCWSTR *rest )
209 q = strchrW( p, '}' );
212 if( *p == '\\' || *p == '&' )
215 /* little bit of sanity checking to stop us getting confused with RTF */
217 if( *i == '}' || *i == '\\' )
223 ret = msi_alloc( len*sizeof(WCHAR) );
226 memcpy( ret, p, len*sizeof(WCHAR) );
231 static UINT msi_dialog_add_font( MSIRECORD *rec, LPVOID param )
233 msi_dialog *dialog = param;
240 /* create a font and add it to the list */
241 name = MSI_RecordGetString( rec, 1 );
242 font = msi_alloc( sizeof *font + strlenW( name )*sizeof (WCHAR) );
243 strcpyW( font->name, name );
244 font->next = dialog->font_list;
245 dialog->font_list = font;
247 font->color = MSI_RecordGetInteger( rec, 4 );
249 memset( &lf, 0, sizeof lf );
250 face = MSI_RecordGetString( rec, 2 );
251 lf.lfHeight = MSI_RecordGetInteger( rec, 3 );
252 style = MSI_RecordGetInteger( rec, 5 );
253 if( style & msidbTextStyleStyleBitsBold )
254 lf.lfWeight = FW_BOLD;
255 if( style & msidbTextStyleStyleBitsItalic )
257 if( style & msidbTextStyleStyleBitsUnderline )
258 lf.lfUnderline = TRUE;
259 if( style & msidbTextStyleStyleBitsStrike )
260 lf.lfStrikeOut = TRUE;
261 lstrcpynW( lf.lfFaceName, face, LF_FACESIZE );
263 /* adjust the height */
264 hdc = GetDC( dialog->hwnd );
267 lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
268 ReleaseDC( dialog->hwnd, hdc );
271 font->hfont = CreateFontIndirectW( &lf );
273 TRACE("Adding font style %s\n", debugstr_w(font->name) );
275 return ERROR_SUCCESS;
278 static msi_font *msi_dialog_find_font( msi_dialog *dialog, LPCWSTR name )
282 for( font = dialog->font_list; font; font = font->next )
283 if( !strcmpW( font->name, name ) ) /* FIXME: case sensitive? */
289 static UINT msi_dialog_set_font( msi_dialog *dialog, HWND hwnd, LPCWSTR name )
293 font = msi_dialog_find_font( dialog, name );
295 SendMessageW( hwnd, WM_SETFONT, (WPARAM) font->hfont, TRUE );
297 ERR("No font entry for %s\n", debugstr_w(name));
298 return ERROR_SUCCESS;
301 static UINT msi_dialog_build_font_list( msi_dialog *dialog )
303 static const WCHAR query[] = {
304 'S','E','L','E','C','T',' ','*',' ',
305 'F','R','O','M',' ','`','T','e','x','t','S','t','y','l','e','`',' ',0
308 MSIQUERY *view = NULL;
310 TRACE("dialog %p\n", dialog );
312 r = MSI_OpenQuery( dialog->package->db, &view, query );
313 if( r != ERROR_SUCCESS )
316 r = MSI_IterateRecords( view, NULL, msi_dialog_add_font, dialog );
317 msiobj_release( &view->hdr );
322 static msi_control *msi_dialog_create_window( msi_dialog *dialog,
323 MSIRECORD *rec, DWORD exstyle, LPCWSTR szCls, LPCWSTR name, LPCWSTR text,
324 DWORD style, HWND parent )
326 DWORD x, y, width, height;
327 LPWSTR font = NULL, title_font = NULL;
328 LPCWSTR title = NULL;
329 msi_control *control;
333 control = msi_alloc( sizeof *control + strlenW(name)*sizeof(WCHAR) );
334 strcpyW( control->name, name );
335 list_add_head( &dialog->controls, &control->entry );
336 control->handler = NULL;
337 control->property = NULL;
338 control->value = NULL;
339 control->hBitmap = NULL;
340 control->hIcon = NULL;
341 control->hDll = NULL;
342 control->tabnext = strdupW( MSI_RecordGetString( rec, 11) );
343 control->progress_current = 0;
344 control->progress_max = 100;
346 x = MSI_RecordGetInteger( rec, 4 );
347 y = MSI_RecordGetInteger( rec, 5 );
348 width = MSI_RecordGetInteger( rec, 6 );
349 height = MSI_RecordGetInteger( rec, 7 );
351 x = msi_dialog_scale_unit( dialog, x );
352 y = msi_dialog_scale_unit( dialog, y );
353 width = msi_dialog_scale_unit( dialog, width );
354 height = msi_dialog_scale_unit( dialog, height );
358 deformat_string( dialog->package, text, &title_font );
359 font = msi_dialog_get_style( title_font, &title );
362 control->hwnd = CreateWindowExW( exstyle, szCls, title, style,
363 x, y, width, height, parent, NULL, NULL, NULL );
365 TRACE("Dialog %s control %s hwnd %p\n",
366 debugstr_w(dialog->name), debugstr_w(text), control->hwnd );
368 msi_dialog_set_font( dialog, control->hwnd,
369 font ? font : dialog->default_font );
371 msi_free( title_font );
377 static MSIRECORD *msi_get_binary_record( MSIDATABASE *db, LPCWSTR name )
379 static const WCHAR query[] = {
380 's','e','l','e','c','t',' ','*',' ',
381 'f','r','o','m',' ','B','i','n','a','r','y',' ',
382 'w','h','e','r','e',' ',
383 '`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0
386 return MSI_QueryGetRecord( db, query, name );
389 static LPWSTR msi_create_tmp_path(void)
393 static const WCHAR prefix[] = { 'm','s','i',0 };
396 r = GetTempPathW( MAX_PATH, tmp );
399 len = lstrlenW( tmp ) + 20;
400 path = msi_alloc( len * sizeof (WCHAR) );
403 r = GetTempFileNameW( tmp, prefix, 0, path );
414 static HANDLE msi_load_image( MSIDATABASE *db, LPCWSTR name, UINT type,
415 UINT cx, UINT cy, UINT flags )
417 MSIRECORD *rec = NULL;
418 HANDLE himage = NULL;
422 TRACE("%p %s %u %u %08x\n", db, debugstr_w(name), cx, cy, flags);
424 tmp = msi_create_tmp_path();
428 rec = msi_get_binary_record( db, name );
431 r = MSI_RecordStreamToFile( rec, 2, tmp );
432 if( r == ERROR_SUCCESS )
434 himage = LoadImageW( 0, tmp, type, cx, cy, flags );
437 msiobj_release( &rec->hdr );
444 static HICON msi_load_icon( MSIDATABASE *db, LPCWSTR text, UINT attributes )
446 DWORD cx = 0, cy = 0, flags;
448 flags = LR_LOADFROMFILE | LR_DEFAULTSIZE;
449 if( attributes & msidbControlAttributesFixedSize )
451 flags &= ~LR_DEFAULTSIZE;
452 if( attributes & msidbControlAttributesIconSize16 )
457 if( attributes & msidbControlAttributesIconSize32 )
462 /* msidbControlAttributesIconSize48 handled by above logic */
464 return msi_load_image( db, text, IMAGE_ICON, cx, cy, flags );
468 /* called from the Control Event subscription code */
469 void msi_dialog_handle_event( msi_dialog* dialog, LPCWSTR control,
470 LPCWSTR attribute, MSIRECORD *rec )
473 LPCWSTR font_text, text = NULL;
476 ctrl = msi_dialog_find_control( dialog, control );
479 if( !lstrcmpW(attribute, szText) )
481 font_text = MSI_RecordGetString( rec , 1 );
482 font = msi_dialog_get_style( font_text, &text );
483 SetWindowTextW( ctrl->hwnd, text );
485 msi_dialog_check_messages( NULL );
487 else if( !lstrcmpW(attribute, szProgress) )
491 func = MSI_RecordGetInteger( rec , 1 );
492 val = MSI_RecordGetInteger( rec , 2 );
497 ctrl->progress_max = val;
498 ctrl->progress_current = 0;
499 SendMessageW(ctrl->hwnd, PBM_SETRANGE, 0, MAKELPARAM(0,100));
500 SendMessageW(ctrl->hwnd, PBM_SETPOS, 0, 0);
502 case 1: /* FIXME: not sure what this is supposed to do */
505 ctrl->progress_current += val;
506 SendMessageW(ctrl->hwnd, PBM_SETPOS, 100*(ctrl->progress_current/ctrl->progress_max), 0);
509 ERR("Unknown progress message %ld\n", func);
515 FIXME("Attribute %s not being set\n", debugstr_w(attribute));
520 static void msi_dialog_map_events(msi_dialog* dialog, LPCWSTR control)
522 static const WCHAR Query[] = {
523 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
524 '`','E','v','e','n','t','M','a','p','p','i','n','g','`',' ',
525 'W','H','E','R','E',' ',
526 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ',
528 '`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',0
531 LPCWSTR event, attribute;
533 row = MSI_QueryGetRecord( dialog->package->db, Query, dialog->name, control );
537 event = MSI_RecordGetString( row, 3 );
538 attribute = MSI_RecordGetString( row, 4 );
539 ControlEvent_SubscribeToEvent( dialog->package, event, control, attribute );
540 msiobj_release( &row->hdr );
543 /* everything except radio buttons */
544 static msi_control *msi_dialog_add_control( msi_dialog *dialog,
545 MSIRECORD *rec, LPCWSTR szCls, DWORD style )
551 name = MSI_RecordGetString( rec, 2 );
552 attributes = MSI_RecordGetInteger( rec, 8 );
553 text = MSI_RecordGetString( rec, 10 );
554 if( attributes & msidbControlAttributesVisible )
556 if( ~attributes & msidbControlAttributesEnabled )
557 style |= WS_DISABLED;
558 if( attributes & msidbControlAttributesSunken )
559 exstyle |= WS_EX_CLIENTEDGE;
561 msi_dialog_map_events(dialog, name);
563 return msi_dialog_create_window( dialog, rec, exstyle, szCls, name,
564 text, style, dialog->hwnd );
575 * we don't erase our own background,
576 * so we have to make sure that the parent window redraws first
578 static void msi_text_on_settext( HWND hWnd )
583 hParent = GetParent( hWnd );
584 GetWindowRect( hWnd, &rc );
585 MapWindowPoints( NULL, hParent, (LPPOINT) &rc, 2 );
586 InvalidateRect( hParent, &rc, TRUE );
589 static LRESULT WINAPI
590 MSIText_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
592 struct msi_text_info *info;
595 TRACE("%p %04x %08x %08lx\n", hWnd, msg, wParam, lParam);
597 info = GetPropW(hWnd, szButtonData);
600 SetTextColor( (HDC)wParam, info->font->color );
602 if( msg == WM_CTLCOLORSTATIC &&
603 ( info->attributes & msidbControlAttributesTransparent ) )
605 SetBkMode( (HDC)wParam, TRANSPARENT );
606 return (LRESULT) GetStockObject(NULL_BRUSH);
609 r = CallWindowProcW(info->oldproc, hWnd, msg, wParam, lParam);
614 msi_text_on_settext( hWnd );
618 RemovePropW( hWnd, szButtonData );
625 static UINT msi_dialog_text_control( msi_dialog *dialog, MSIRECORD *rec )
627 msi_control *control;
628 struct msi_text_info *info;
632 TRACE("%p %p\n", dialog, rec);
634 control = msi_dialog_add_control( dialog, rec, szStatic, SS_LEFT | WS_GROUP );
636 return ERROR_FUNCTION_FAILED;
638 info = msi_alloc( sizeof *info );
640 return ERROR_SUCCESS;
642 text = MSI_RecordGetString( rec, 10 );
643 font_name = msi_dialog_get_style( text, &ptr );
644 info->font = ( font_name ) ? msi_dialog_find_font( dialog, font_name ) : NULL;
645 msi_free( font_name );
647 info->attributes = MSI_RecordGetInteger( rec, 8 );
648 if( info->attributes & msidbControlAttributesTransparent )
649 SetWindowLongPtrW( control->hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT );
651 info->oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
652 (LONG_PTR)MSIText_WndProc );
653 SetPropW( control->hwnd, szButtonData, info );
655 return ERROR_SUCCESS;
658 static UINT msi_dialog_button_control( msi_dialog *dialog, MSIRECORD *rec )
660 msi_control *control;
661 UINT attributes, style;
664 TRACE("%p %p\n", dialog, rec);
667 attributes = MSI_RecordGetInteger( rec, 8 );
668 if( attributes & msidbControlAttributesIcon )
671 control = msi_dialog_add_control( dialog, rec, szButton, style );
673 return ERROR_FUNCTION_FAILED;
675 control->handler = msi_dialog_button_handler;
678 text = msi_get_deformatted_field( dialog->package, rec, 10 );
679 control->hIcon = msi_load_icon( dialog->package->db, text, attributes );
680 if( attributes & msidbControlAttributesIcon )
681 SendMessageW( control->hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM) control->hIcon );
684 return ERROR_SUCCESS;
687 static LPWSTR msi_get_checkbox_value( msi_dialog *dialog, LPCWSTR prop )
689 static const WCHAR query[] = {
690 'S','E','L','E','C','T',' ','*',' ',
691 'F','R','O','M',' ','`','C','h','e','c','k','B','o','x',' ','`',
692 'W','H','E','R','E',' ',
693 '`','P','r','o','p','e','r','t','y','`',' ','=',' ',
696 MSIRECORD *rec = NULL;
699 /* find if there is a value associated with the checkbox */
700 rec = MSI_QueryGetRecord( dialog->package->db, query, prop );
704 ret = msi_get_deformatted_field( dialog->package, rec, 2 );
710 msiobj_release( &rec->hdr );
714 ret = msi_dup_property( dialog->package, prop );
724 static UINT msi_dialog_checkbox_control( msi_dialog *dialog, MSIRECORD *rec )
726 msi_control *control;
729 TRACE("%p %p\n", dialog, rec);
731 control = msi_dialog_add_control( dialog, rec, szButton,
732 BS_CHECKBOX | BS_MULTILINE | WS_TABSTOP );
733 control->handler = msi_dialog_checkbox_handler;
734 prop = MSI_RecordGetString( rec, 9 );
737 control->property = strdupW( prop );
738 control->value = msi_get_checkbox_value( dialog, prop );
739 TRACE("control %s value %s\n", debugstr_w(control->property),
740 debugstr_w(control->value));
742 msi_dialog_checkbox_sync_state( dialog, control );
744 return ERROR_SUCCESS;
747 static UINT msi_dialog_line_control( msi_dialog *dialog, MSIRECORD *rec )
749 TRACE("%p %p\n", dialog, rec);
751 msi_dialog_add_control( dialog, rec, szStatic, SS_ETCHEDHORZ | SS_SUNKEN );
752 return ERROR_SUCCESS;
755 /******************** Scroll Text ********************************************/
757 struct msi_scrolltext_info
760 msi_control *control;
764 static LRESULT WINAPI
765 MSIScrollText_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
767 struct msi_scrolltext_info *info;
770 TRACE("%p %04x %08x %08lx\n", hWnd, msg, wParam, lParam);
772 info = GetPropW( hWnd, szButtonData );
774 r = CallWindowProcW( info->oldproc, hWnd, msg, wParam, lParam );
780 RemovePropW( hWnd, szButtonData );
783 /* native MSI sets a wait cursor here */
784 msi_dialog_button_handler( info->dialog, info->control, BN_CLICKED );
790 struct msi_streamin_info
797 static DWORD CALLBACK
798 msi_richedit_stream_in( DWORD_PTR arg, LPBYTE buffer, LONG count, LONG *pcb )
800 struct msi_streamin_info *info = (struct msi_streamin_info*) arg;
802 if( (count + info->offset) > info->length )
803 count = info->length - info->offset;
804 memcpy( buffer, &info->string[ info->offset ], count );
806 info->offset += count;
808 TRACE("%ld/%ld\n", info->offset, info->length);
813 static void msi_scrolltext_add_text( msi_control *control, LPCWSTR text )
815 struct msi_streamin_info info;
818 info.string = strdupWtoA( text );
820 info.length = lstrlenA( info.string ) + 1;
822 es.dwCookie = (DWORD_PTR) &info;
824 es.pfnCallback = msi_richedit_stream_in;
826 SendMessageW( control->hwnd, EM_STREAMIN, SF_RTF, (LPARAM) &es );
828 msi_free( info.string );
831 static UINT msi_dialog_scrolltext_control( msi_dialog *dialog, MSIRECORD *rec )
833 static const WCHAR szRichEdit20W[] = {
834 'R','i','c','h','E','d','i','t','2','0','W',0
836 struct msi_scrolltext_info *info;
837 msi_control *control;
841 info = msi_alloc( sizeof *info );
843 return ERROR_FUNCTION_FAILED;
845 hRichedit = LoadLibraryA("riched20");
847 style = WS_BORDER | ES_MULTILINE | WS_VSCROLL |
848 ES_READONLY | ES_AUTOVSCROLL | WS_TABSTOP;
849 control = msi_dialog_add_control( dialog, rec, szRichEdit20W, style );
852 FreeLibrary( hRichedit );
854 return ERROR_FUNCTION_FAILED;
857 control->hDll = hRichedit;
859 info->dialog = dialog;
860 info->control = control;
862 /* subclass the static control */
863 info->oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
864 (LONG_PTR)MSIScrollText_WndProc );
865 SetPropW( control->hwnd, szButtonData, info );
867 /* add the text into the richedit */
868 msi_scrolltext_add_text( control, MSI_RecordGetString( rec, 10 ) );
870 return ERROR_SUCCESS;
873 static HBITMAP msi_load_picture( MSIDATABASE *db, LPCWSTR name,
874 INT cx, INT cy, DWORD flags )
876 HBITMAP hOleBitmap = 0, hBitmap = 0, hOldSrcBitmap, hOldDestBitmap;
877 MSIRECORD *rec = NULL;
879 IPicture *pic = NULL;
884 rec = msi_get_binary_record( db, name );
888 r = MSI_RecordGetIStream( rec, 2, &stm );
889 msiobj_release( &rec->hdr );
890 if( r != ERROR_SUCCESS )
893 r = OleLoadPicture( stm, 0, TRUE, &IID_IPicture, (LPVOID*) &pic );
894 IStream_Release( stm );
897 ERR("failed to load picture\n");
901 r = IPicture_get_Handle( pic, (OLE_HANDLE*) &hOleBitmap );
904 ERR("failed to get bitmap handle\n");
908 /* make the bitmap the desired size */
909 r = GetObjectW( hOleBitmap, sizeof bm, &bm );
912 ERR("failed to get bitmap size\n");
916 if (flags & LR_DEFAULTSIZE)
922 srcdc = CreateCompatibleDC( NULL );
923 hOldSrcBitmap = SelectObject( srcdc, hOleBitmap );
924 destdc = CreateCompatibleDC( NULL );
925 hBitmap = CreateCompatibleBitmap( srcdc, cx, cy );
926 hOldDestBitmap = SelectObject( destdc, hBitmap );
927 StretchBlt( destdc, 0, 0, cx, cy,
928 srcdc, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
929 SelectObject( srcdc, hOldSrcBitmap );
930 SelectObject( destdc, hOldDestBitmap );
936 IPicture_Release( pic );
940 static UINT msi_dialog_bitmap_control( msi_dialog *dialog, MSIRECORD *rec )
942 UINT cx, cy, flags, style, attributes;
943 msi_control *control;
946 flags = LR_LOADFROMFILE;
947 style = SS_BITMAP | SS_LEFT | WS_GROUP;
949 attributes = MSI_RecordGetInteger( rec, 8 );
950 if( attributes & msidbControlAttributesFixedSize )
952 flags |= LR_DEFAULTSIZE;
953 style |= SS_CENTERIMAGE;
956 control = msi_dialog_add_control( dialog, rec, szStatic, style );
957 cx = MSI_RecordGetInteger( rec, 6 );
958 cy = MSI_RecordGetInteger( rec, 7 );
959 cx = msi_dialog_scale_unit( dialog, cx );
960 cy = msi_dialog_scale_unit( dialog, cy );
962 text = msi_get_deformatted_field( dialog->package, rec, 10 );
963 control->hBitmap = msi_load_picture( dialog->package->db, text, cx, cy, flags );
964 if( control->hBitmap )
965 SendMessageW( control->hwnd, STM_SETIMAGE,
966 IMAGE_BITMAP, (LPARAM) control->hBitmap );
968 ERR("Failed to load bitmap %s\n", debugstr_w(text));
972 return ERROR_SUCCESS;
975 static UINT msi_dialog_icon_control( msi_dialog *dialog, MSIRECORD *rec )
977 msi_control *control;
983 control = msi_dialog_add_control( dialog, rec, szStatic,
984 SS_ICON | SS_CENTERIMAGE | WS_GROUP );
986 attributes = MSI_RecordGetInteger( rec, 8 );
987 text = msi_get_deformatted_field( dialog->package, rec, 10 );
988 control->hIcon = msi_load_icon( dialog->package->db, text, attributes );
990 SendMessageW( control->hwnd, STM_SETICON, (WPARAM) control->hIcon, 0 );
992 ERR("Failed to load bitmap %s\n", debugstr_w(text));
994 return ERROR_SUCCESS;
997 static UINT msi_dialog_combo_control( msi_dialog *dialog, MSIRECORD *rec )
999 static const WCHAR szCombo[] = { 'C','O','M','B','O','B','O','X',0 };
1001 msi_dialog_add_control( dialog, rec, szCombo,
1002 SS_BITMAP | SS_LEFT | SS_CENTERIMAGE );
1003 return ERROR_SUCCESS;
1006 static UINT msi_dialog_edit_control( msi_dialog *dialog, MSIRECORD *rec )
1008 msi_control *control;
1012 control = msi_dialog_add_control( dialog, rec, szEdit,
1013 WS_BORDER | WS_TABSTOP );
1014 control->handler = msi_dialog_edit_handler;
1015 prop = MSI_RecordGetString( rec, 9 );
1017 control->property = strdupW( prop );
1018 val = msi_dup_property( dialog->package, control->property );
1019 SetWindowTextW( control->hwnd, val );
1021 return ERROR_SUCCESS;
1024 /******************** Masked Edit ********************************************/
1026 #define MASK_MAX_GROUPS 10
1028 struct msi_mask_group
1036 struct msi_maskedit_info
1044 struct msi_mask_group group[MASK_MAX_GROUPS];
1047 static BOOL msi_mask_editable( WCHAR type )
1062 static void msi_mask_control_change( struct msi_maskedit_info *info )
1067 val = msi_alloc( (info->num_chars+1)*sizeof(WCHAR) );
1068 for( i=0, n=0; i<info->num_groups; i++ )
1070 if( (info->group[i].len + n) > info->num_chars )
1072 ERR("can't fit control %d text into template\n",i);
1075 if (!msi_mask_editable(info->group[i].type))
1077 for(r=0; r<info->group[i].len; r++)
1078 val[n+r] = info->group[i].type;
1083 r = GetWindowTextW( info->group[i].hwnd, &val[n], info->group[i].len+1 );
1084 if( r != info->group[i].len )
1090 TRACE("%d/%d controls were good\n", i, info->num_groups);
1092 if( i == info->num_groups )
1094 TRACE("Set property %s to %s\n",
1095 debugstr_w(info->prop), debugstr_w(val) );
1096 CharUpperBuffW( val, info->num_chars );
1097 MSI_SetPropertyW( info->dialog->package, info->prop, val );
1098 msi_dialog_evaluate_control_conditions( info->dialog );
1103 /* now move to the next control if necessary */
1104 static VOID msi_mask_next_control( struct msi_maskedit_info *info, HWND hWnd )
1109 for( i=0; i<info->num_groups; i++ )
1110 if( info->group[i].hwnd == hWnd )
1113 /* don't move from the last control */
1114 if( i >= (info->num_groups-1) )
1117 len = SendMessageW( hWnd, WM_GETTEXTLENGTH, 0, 0 );
1118 if( len < info->group[i].len )
1121 hWndNext = GetNextDlgTabItem( GetParent( hWnd ), hWnd, FALSE );
1122 SetFocus( hWndNext );
1125 static LRESULT WINAPI
1126 MSIMaskedEdit_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
1128 struct msi_maskedit_info *info;
1131 TRACE("%p %04x %08x %08lx\n", hWnd, msg, wParam, lParam);
1133 info = GetPropW(hWnd, szButtonData);
1135 r = CallWindowProcW(info->oldproc, hWnd, msg, wParam, lParam);
1140 if (HIWORD(wParam) == EN_CHANGE)
1142 msi_mask_control_change( info );
1143 msi_mask_next_control( info, (HWND) lParam );
1147 msi_free( info->prop );
1149 RemovePropW( hWnd, szButtonData );
1156 /* fish the various bits of the property out and put them in the control */
1158 msi_maskedit_set_text( struct msi_maskedit_info *info, LPCWSTR text )
1164 for( i = 0; i < info->num_groups; i++ )
1166 if( info->group[i].len < lstrlenW( p ) )
1168 LPWSTR chunk = strdupW( p );
1169 chunk[ info->group[i].len ] = 0;
1170 SetWindowTextW( info->group[i].hwnd, chunk );
1175 SetWindowTextW( info->group[i].hwnd, p );
1178 p += info->group[i].len;
1182 static struct msi_maskedit_info * msi_dialog_parse_groups( LPCWSTR mask )
1184 struct msi_maskedit_info * info = NULL;
1185 int i = 0, n = 0, total = 0;
1188 TRACE("masked control, template %s\n", debugstr_w(mask));
1193 info = msi_alloc_zero( sizeof *info );
1197 p = strchrW(mask, '<');
1203 for( i=0; i<MASK_MAX_GROUPS; i++ )
1205 /* stop at the end of the string */
1206 if( p[0] == 0 || p[0] == '>' )
1209 /* count the number of the same identifier */
1210 for( n=0; p[n] == p[0]; n++ )
1212 info->group[i].ofs = total;
1213 info->group[i].type = p[0];
1217 total++; /* an extra not part of the group */
1219 info->group[i].len = n;
1224 TRACE("%d characters in %d groups\n", total, i );
1225 if( i == MASK_MAX_GROUPS )
1226 ERR("too many groups in PIDTemplate %s\n", debugstr_w(mask));
1228 info->num_chars = total;
1229 info->num_groups = i;
1235 msi_maskedit_create_children( struct msi_maskedit_info *info, LPCWSTR font )
1237 DWORD width, height, style, wx, ww;
1242 style = WS_CHILD | WS_BORDER | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL;
1244 GetClientRect( info->hwnd, &rect );
1246 width = rect.right - rect.left;
1247 height = rect.bottom - rect.top;
1249 for( i = 0; i < info->num_groups; i++ )
1251 if (!msi_mask_editable( info->group[i].type ))
1253 wx = (info->group[i].ofs * width) / info->num_chars;
1254 ww = (info->group[i].len * width) / info->num_chars;
1256 hwnd = CreateWindowW( szEdit, NULL, style, wx, 0, ww, height,
1257 info->hwnd, NULL, NULL, NULL );
1260 ERR("failed to create mask edit sub window\n");
1264 SendMessageW( hwnd, EM_LIMITTEXT, info->group[i].len, 0 );
1266 msi_dialog_set_font( info->dialog, hwnd,
1267 font?font:info->dialog->default_font );
1268 info->group[i].hwnd = hwnd;
1273 * office 2003 uses "73931<````=````=````=````=`````>@@@@@"
1274 * delphi 7 uses "<????-??????-??????-????>" and "<???-???>"
1275 * filemaker pro 7 uses "<^^^^=^^^^=^^^^=^^^^=^^^^=^^^^=^^^^^>"
1277 static UINT msi_dialog_maskedit_control( msi_dialog *dialog, MSIRECORD *rec )
1279 LPWSTR font_mask, val = NULL, font;
1280 struct msi_maskedit_info *info = NULL;
1281 UINT ret = ERROR_SUCCESS;
1282 msi_control *control;
1287 font_mask = msi_get_deformatted_field( dialog->package, rec, 10 );
1288 font = msi_dialog_get_style( font_mask, &mask );
1291 ERR("mask template is empty\n");
1295 info = msi_dialog_parse_groups( mask );
1298 ERR("template %s is invalid\n", debugstr_w(mask));
1302 info->dialog = dialog;
1304 control = msi_dialog_add_control( dialog, rec, szStatic,
1305 SS_OWNERDRAW | WS_GROUP | WS_VISIBLE );
1308 ERR("Failed to create maskedit container\n");
1309 ret = ERROR_FUNCTION_FAILED;
1312 SetWindowLongPtrW( control->hwnd, GWL_EXSTYLE, WS_EX_CONTROLPARENT );
1314 info->hwnd = control->hwnd;
1316 /* subclass the static control */
1317 info->oldproc = (WNDPROC) SetWindowLongPtrW( info->hwnd, GWLP_WNDPROC,
1318 (LONG_PTR)MSIMaskedEdit_WndProc );
1319 SetPropW( control->hwnd, szButtonData, info );
1321 prop = MSI_RecordGetString( rec, 9 );
1323 info->prop = strdupW( prop );
1325 msi_maskedit_create_children( info, font );
1329 val = msi_dup_property( dialog->package, prop );
1332 msi_maskedit_set_text( info, val );
1338 if( ret != ERROR_SUCCESS )
1340 msi_free( font_mask );
1345 /******************** Progress Bar *****************************************/
1347 static UINT msi_dialog_progress_bar( msi_dialog *dialog, MSIRECORD *rec )
1349 msi_dialog_add_control( dialog, rec, PROGRESS_CLASSW, WS_VISIBLE );
1350 return ERROR_SUCCESS;
1353 /******************** Path Edit ********************************************/
1355 static UINT msi_dialog_pathedit_control( msi_dialog *dialog, MSIRECORD *rec )
1357 FIXME("not implemented properly\n");
1358 return msi_dialog_edit_control( dialog, rec );
1361 /* radio buttons are a bit different from normal controls */
1362 static UINT msi_dialog_create_radiobutton( MSIRECORD *rec, LPVOID param )
1364 radio_button_group_descr *group = (radio_button_group_descr *)param;
1365 msi_dialog *dialog = group->dialog;
1366 msi_control *control;
1367 LPCWSTR prop, text, name;
1368 DWORD style, attributes = group->attributes;
1370 style = WS_CHILD | BS_AUTORADIOBUTTON | BS_MULTILINE | WS_TABSTOP;
1371 name = MSI_RecordGetString( rec, 3 );
1372 text = MSI_RecordGetString( rec, 8 );
1373 if( attributes & 1 )
1374 style |= WS_VISIBLE;
1375 if( ~attributes & 2 )
1376 style |= WS_DISABLED;
1378 control = msi_dialog_create_window( dialog, rec, 0, szButton, name, text,
1379 style, group->parent->hwnd );
1381 return ERROR_FUNCTION_FAILED;
1382 control->handler = msi_dialog_radiogroup_handler;
1384 if (!lstrcmpW(control->name, group->propval))
1385 SendMessageW(control->hwnd, BM_SETCHECK, BST_CHECKED, 0);
1387 prop = MSI_RecordGetString( rec, 1 );
1389 control->property = strdupW( prop );
1391 return ERROR_SUCCESS;
1394 static UINT msi_dialog_radiogroup_control( msi_dialog *dialog, MSIRECORD *rec )
1396 static const WCHAR query[] = {
1397 'S','E','L','E','C','T',' ','*',' ',
1398 'F','R','O','M',' ','R','a','d','i','o','B','u','t','t','o','n',' ',
1399 'W','H','E','R','E',' ',
1400 '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
1403 msi_control *control;
1404 MSIQUERY *view = NULL;
1405 radio_button_group_descr group;
1406 MSIPACKAGE *package = dialog->package;
1409 prop = MSI_RecordGetString( rec, 9 );
1411 TRACE("%p %p %s\n", dialog, rec, debugstr_w( prop ));
1413 /* Create parent group box to hold radio buttons */
1414 control = msi_dialog_add_control( dialog, rec, szButton, BS_OWNERDRAW|WS_GROUP );
1416 return ERROR_FUNCTION_FAILED;
1418 oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
1419 (LONG_PTR)MSIRadioGroup_WndProc );
1420 SetPropW(control->hwnd, szButtonData, oldproc);
1421 SetWindowLongPtrW( control->hwnd, GWL_EXSTYLE, WS_EX_CONTROLPARENT );
1424 control->property = strdupW( prop );
1426 /* query the Radio Button table for all control in this group */
1427 r = MSI_OpenQuery( package->db, &view, query, prop );
1428 if( r != ERROR_SUCCESS )
1430 ERR("query failed for dialog %s radio group %s\n",
1431 debugstr_w(dialog->name), debugstr_w(prop));
1432 return ERROR_INVALID_PARAMETER;
1435 group.dialog = dialog;
1436 group.parent = control;
1437 group.attributes = MSI_RecordGetInteger( rec, 8 );
1438 group.propval = msi_dup_property( dialog->package, control->property );
1440 r = MSI_IterateRecords( view, 0, msi_dialog_create_radiobutton, &group );
1441 msiobj_release( &view->hdr );
1442 msi_free( group.propval );
1447 /******************** Selection Tree ***************************************/
1449 struct msi_selection_tree_info
1457 msi_seltree_sync_item_state( HWND hwnd, MSIFEATURE *feature, HTREEITEM hItem )
1461 TRACE("Feature %s -> %d %d %d\n", debugstr_w(feature->Title),
1462 feature->Installed, feature->Action, feature->ActionRequest);
1464 tvi.mask = TVIF_STATE;
1466 tvi.state = INDEXTOSTATEIMAGEMASK( feature->Action );
1467 tvi.stateMask = TVIS_STATEIMAGEMASK;
1469 SendMessageW( hwnd, TVM_SETITEMW, 0, (LPARAM) &tvi );
1473 msi_seltree_popup_menu( HWND hwnd, INT x, INT y )
1478 /* create a menu to display */
1479 hMenu = CreatePopupMenu();
1481 /* FIXME: load strings from resources */
1482 AppendMenuA( hMenu, MF_ENABLED, INSTALLSTATE_LOCAL, "Install feature locally");
1483 AppendMenuA( hMenu, MF_GRAYED, 0x1000, "Install entire feature");
1484 AppendMenuA( hMenu, MF_ENABLED, INSTALLSTATE_ADVERTISED, "Install on demand");
1485 AppendMenuA( hMenu, MF_ENABLED, INSTALLSTATE_ABSENT, "Don't install");
1486 r = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD,
1487 x, y, 0, hwnd, NULL );
1488 DestroyMenu( hMenu );
1493 msi_seltree_feature_from_item( HWND hwnd, HTREEITEM hItem )
1497 /* get the feature from the item */
1498 memset( &tvi, 0, sizeof tvi );
1500 tvi.mask = TVIF_PARAM | TVIF_HANDLE;
1501 SendMessageW( hwnd, TVM_GETITEMW, 0, (LPARAM) &tvi );
1503 return (MSIFEATURE*) tvi.lParam;
1507 msi_seltree_menu( HWND hwnd, HTREEITEM hItem )
1509 MSIFEATURE *feature;
1517 feature = msi_seltree_feature_from_item( hwnd, hItem );
1520 ERR("item %p feature was NULL\n", hItem);
1524 /* get the item's rectangle to put the menu just below it */
1526 SendMessageW( hwnd, TVM_GETITEMRECT, 0, (LPARAM) &u.rc );
1527 MapWindowPoints( hwnd, NULL, u.pt, 2 );
1529 r = msi_seltree_popup_menu( hwnd, u.rc.left, u.rc.top );
1533 case INSTALLSTATE_LOCAL:
1534 case INSTALLSTATE_ADVERTISED:
1535 case INSTALLSTATE_ABSENT:
1536 feature->ActionRequest = r;
1537 feature->Action = r;
1540 FIXME("select feature and all children\n");
1544 msi_seltree_sync_item_state( hwnd, feature, hItem );
1549 static LRESULT WINAPI
1550 MSISelectionTree_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
1552 struct msi_selection_tree_info *info;
1553 TVHITTESTINFO tvhti;
1556 TRACE("%p %04x %08x %08lx\n", hWnd, msg, wParam, lParam);
1558 info = GetPropW(hWnd, szButtonData);
1562 case WM_LBUTTONDOWN:
1563 tvhti.pt.x = LOWORD( lParam );
1564 tvhti.pt.y = HIWORD( lParam );
1567 r = CallWindowProcW(info->oldproc, hWnd, TVM_HITTEST, 0, (LPARAM) &tvhti );
1568 if (tvhti.flags & TVHT_ONITEMSTATEICON)
1569 return msi_seltree_menu( hWnd, tvhti.hItem );
1573 r = CallWindowProcW(info->oldproc, hWnd, msg, wParam, lParam);
1579 RemovePropW( hWnd, szButtonData );
1586 msi_seltree_add_child_features( MSIPACKAGE *package, HWND hwnd,
1587 LPCWSTR parent, HTREEITEM hParent )
1589 MSIFEATURE *feature;
1590 TVINSERTSTRUCTW tvis;
1593 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
1595 if ( lstrcmpW( parent, feature->Feature_Parent ) )
1598 if ( !feature->Title )
1601 memset( &tvis, 0, sizeof tvis );
1602 tvis.hParent = hParent;
1603 tvis.hInsertAfter = TVI_SORT;
1604 tvis.u.item.mask = TVIF_TEXT | TVIF_PARAM;
1605 tvis.u.item.pszText = feature->Title;
1606 tvis.u.item.lParam = (LPARAM) feature;
1608 hitem = (HTREEITEM) SendMessageW( hwnd, TVM_INSERTITEMW, 0, (LPARAM) &tvis );
1612 msi_seltree_sync_item_state( hwnd, feature, hitem );
1613 msi_seltree_add_child_features( package, hwnd,
1614 feature->Feature, hitem );
1618 static void msi_seltree_create_imagelist( HWND hwnd )
1620 const int bm_width = 32, bm_height = 16, bm_count = 3;
1621 const int bm_resource = 0x1001;
1626 himl = ImageList_Create( bm_width, bm_height, FALSE, 4, 0 );
1629 ERR("failed to create image list\n");
1633 for (i=0; i<bm_count; i++)
1635 hbmp = LoadBitmapW( msi_hInstance, MAKEINTRESOURCEW(i+bm_resource) );
1638 ERR("failed to load bitmap %d\n", i);
1643 * Add a dummy bitmap at offset zero because the treeview
1644 * can't use it as a state mask (zero means no user state).
1647 ImageList_Add( himl, hbmp, NULL );
1649 ImageList_Add( himl, hbmp, NULL );
1652 SendMessageW( hwnd, TVM_SETIMAGELIST, TVSIL_STATE, (LPARAM)himl );
1655 static UINT msi_dialog_selection_tree( msi_dialog *dialog, MSIRECORD *rec )
1657 msi_control *control;
1659 MSIPACKAGE *package = dialog->package;
1661 struct msi_selection_tree_info *info;
1663 info = msi_alloc( sizeof *info );
1665 return ERROR_FUNCTION_FAILED;
1667 /* create the treeview control */
1668 prop = MSI_RecordGetString( rec, 9 );
1669 style = TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT;
1670 style |= WS_GROUP | WS_VSCROLL;
1671 control = msi_dialog_add_control( dialog, rec, WC_TREEVIEWW, style );
1675 return ERROR_FUNCTION_FAILED;
1679 info->dialog = dialog;
1680 info->hwnd = control->hwnd;
1681 info->oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
1682 (LONG_PTR)MSISelectionTree_WndProc );
1683 SetPropW( control->hwnd, szButtonData, info );
1686 msi_seltree_create_imagelist( control->hwnd );
1687 msi_seltree_add_child_features( package, control->hwnd, NULL, NULL );
1689 return ERROR_SUCCESS;
1692 static const struct control_handler msi_dialog_handler[] =
1694 { szText, msi_dialog_text_control },
1695 { szPushButton, msi_dialog_button_control },
1696 { szLine, msi_dialog_line_control },
1697 { szBitmap, msi_dialog_bitmap_control },
1698 { szCheckBox, msi_dialog_checkbox_control },
1699 { szScrollableText, msi_dialog_scrolltext_control },
1700 { szComboBox, msi_dialog_combo_control },
1701 { szEdit, msi_dialog_edit_control },
1702 { szMaskedEdit, msi_dialog_maskedit_control },
1703 { szPathEdit, msi_dialog_pathedit_control },
1704 { szProgressBar, msi_dialog_progress_bar },
1705 { szRadioButtonGroup, msi_dialog_radiogroup_control },
1706 { szIcon, msi_dialog_icon_control },
1707 { szSelectionTree, msi_dialog_selection_tree },
1710 #define NUM_CONTROL_TYPES (sizeof msi_dialog_handler/sizeof msi_dialog_handler[0])
1712 static UINT msi_dialog_create_controls( MSIRECORD *rec, LPVOID param )
1714 msi_dialog *dialog = param;
1715 LPCWSTR control_type;
1718 /* find and call the function that can create this type of control */
1719 control_type = MSI_RecordGetString( rec, 3 );
1720 for( i=0; i<NUM_CONTROL_TYPES; i++ )
1721 if (!strcmpiW( msi_dialog_handler[i].control_type, control_type ))
1723 if( i != NUM_CONTROL_TYPES )
1724 msi_dialog_handler[i].func( dialog, rec );
1726 ERR("no handler for element type %s\n", debugstr_w(control_type));
1728 return ERROR_SUCCESS;
1731 static UINT msi_dialog_fill_controls( msi_dialog *dialog )
1733 static const WCHAR query[] = {
1734 'S','E','L','E','C','T',' ','*',' ',
1735 'F','R','O','M',' ','C','o','n','t','r','o','l',' ',
1736 'W','H','E','R','E',' ',
1737 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0};
1739 MSIQUERY *view = NULL;
1740 MSIPACKAGE *package = dialog->package;
1742 TRACE("%p %s\n", dialog, debugstr_w(dialog->name) );
1744 /* query the Control table for all the elements of the control */
1745 r = MSI_OpenQuery( package->db, &view, query, dialog->name );
1746 if( r != ERROR_SUCCESS )
1748 ERR("query failed for dialog %s\n", debugstr_w(dialog->name));
1749 return ERROR_INVALID_PARAMETER;
1752 r = MSI_IterateRecords( view, 0, msi_dialog_create_controls, dialog );
1753 msiobj_release( &view->hdr );
1758 static UINT msi_dialog_set_control_condition( MSIRECORD *rec, LPVOID param )
1760 static const WCHAR szHide[] = { 'H','i','d','e',0 };
1761 static const WCHAR szShow[] = { 'S','h','o','w',0 };
1762 static const WCHAR szDisable[] = { 'D','i','s','a','b','l','e',0 };
1763 static const WCHAR szEnable[] = { 'E','n','a','b','l','e',0 };
1764 msi_dialog *dialog = param;
1765 msi_control *control;
1766 LPCWSTR name, action, condition;
1769 name = MSI_RecordGetString( rec, 2 );
1770 action = MSI_RecordGetString( rec, 3 );
1771 condition = MSI_RecordGetString( rec, 4 );
1772 r = MSI_EvaluateConditionW( dialog->package, condition );
1773 control = msi_dialog_find_control( dialog, name );
1774 if( r == MSICONDITION_TRUE && control )
1776 TRACE("%s control %s\n", debugstr_w(action), debugstr_w(name));
1778 /* FIXME: case sensitive? */
1779 if(!lstrcmpW(action, szHide))
1780 ShowWindow(control->hwnd, SW_HIDE);
1781 else if(!strcmpW(action, szShow))
1782 ShowWindow(control->hwnd, SW_SHOW);
1783 else if(!strcmpW(action, szDisable))
1784 EnableWindow(control->hwnd, FALSE);
1785 else if(!strcmpW(action, szEnable))
1786 EnableWindow(control->hwnd, TRUE);
1788 FIXME("Unhandled action %s\n", debugstr_w(action));
1791 return ERROR_SUCCESS;
1794 static UINT msi_dialog_evaluate_control_conditions( msi_dialog *dialog )
1796 static const WCHAR query[] = {
1797 'S','E','L','E','C','T',' ','*',' ',
1798 'F','R','O','M',' ',
1799 'C','o','n','t','r','o','l','C','o','n','d','i','t','i','o','n',' ',
1800 'W','H','E','R','E',' ',
1801 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0
1804 MSIQUERY *view = NULL;
1805 MSIPACKAGE *package = dialog->package;
1807 TRACE("%p %s\n", dialog, debugstr_w(dialog->name) );
1809 /* query the Control table for all the elements of the control */
1810 r = MSI_OpenQuery( package->db, &view, query, dialog->name );
1811 if( r != ERROR_SUCCESS )
1813 ERR("query failed for dialog %s\n", debugstr_w(dialog->name));
1814 return ERROR_INVALID_PARAMETER;
1817 r = MSI_IterateRecords( view, 0, msi_dialog_set_control_condition, dialog );
1818 msiobj_release( &view->hdr );
1823 UINT msi_dialog_reset( msi_dialog *dialog )
1825 /* FIXME: should restore the original values of any properties we changed */
1826 return msi_dialog_evaluate_control_conditions( dialog );
1829 /* figure out the height of 10 point MS Sans Serif */
1830 static INT msi_dialog_get_sans_serif_height( HWND hwnd )
1832 static const WCHAR szSansSerif[] = {
1833 'M','S',' ','S','a','n','s',' ','S','e','r','i','f',0 };
1838 HFONT hFont, hOldFont;
1841 hdc = GetDC( hwnd );
1844 memset( &lf, 0, sizeof lf );
1845 lf.lfHeight = MulDiv(10, GetDeviceCaps(hdc, LOGPIXELSY), 72);
1846 strcpyW( lf.lfFaceName, szSansSerif );
1847 hFont = CreateFontIndirectW(&lf);
1850 hOldFont = SelectObject( hdc, hFont );
1851 r = GetTextMetricsW( hdc, &tm );
1853 height = tm.tmHeight;
1854 SelectObject( hdc, hOldFont );
1855 DeleteObject( hFont );
1857 ReleaseDC( hwnd, hdc );
1862 /* fetch the associated record from the Dialog table */
1863 static MSIRECORD *msi_get_dialog_record( msi_dialog *dialog )
1865 static const WCHAR query[] = {
1866 'S','E','L','E','C','T',' ','*',' ',
1867 'F','R','O','M',' ','D','i','a','l','o','g',' ',
1868 'W','H','E','R','E',' ',
1869 '`','D','i','a','l','o','g','`',' ','=',' ','\'','%','s','\'',0};
1870 MSIPACKAGE *package = dialog->package;
1871 MSIRECORD *rec = NULL;
1873 TRACE("%p %s\n", dialog, debugstr_w(dialog->name) );
1875 rec = MSI_QueryGetRecord( package->db, query, dialog->name );
1877 ERR("query failed for dialog %s\n", debugstr_w(dialog->name));
1882 static void msi_dialog_adjust_dialog_size( msi_dialog *dialog, LPSIZE sz )
1887 /* turn the client size into the window rectangle */
1890 rect.right = msi_dialog_scale_unit( dialog, sz->cx );
1891 rect.bottom = msi_dialog_scale_unit( dialog, sz->cy );
1892 style = GetWindowLongPtrW( dialog->hwnd, GWL_STYLE );
1893 AdjustWindowRect( &rect, style, FALSE );
1894 sz->cx = rect.right - rect.left;
1895 sz->cy = rect.bottom - rect.top;
1898 static BOOL msi_control_set_next( msi_control *control, msi_control *next )
1900 return SetWindowPos( next->hwnd, control->hwnd, 0, 0, 0, 0,
1901 SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW |
1902 SWP_NOREPOSITION | SWP_NOSENDCHANGING | SWP_NOSIZE );
1905 static UINT msi_dialog_set_tab_order( msi_dialog *dialog )
1907 msi_control *control, *tab_next;
1909 LIST_FOR_EACH_ENTRY( control, &dialog->controls, msi_control, entry )
1911 tab_next = msi_dialog_find_control( dialog, control->tabnext );
1914 msi_control_set_next( control, tab_next );
1917 return ERROR_SUCCESS;
1920 static void msi_dialog_set_first_control( msi_dialog* dialog, LPCWSTR name )
1922 msi_control *control;
1924 control = msi_dialog_find_control( dialog, name );
1926 dialog->hWndFocus = control->hwnd;
1928 dialog->hWndFocus = NULL;
1931 static LRESULT msi_dialog_oncreate( HWND hwnd, LPCREATESTRUCTW cs )
1933 static const WCHAR df[] = {
1934 'D','e','f','a','u','l','t','U','I','F','o','n','t',0 };
1935 static const WCHAR dfv[] = {
1936 'M','S',' ','S','h','e','l','l',' ','D','l','g',0 };
1937 msi_dialog *dialog = (msi_dialog*) cs->lpCreateParams;
1938 MSIRECORD *rec = NULL;
1939 LPWSTR title = NULL;
1942 TRACE("%p %p\n", dialog, dialog->package);
1944 dialog->hwnd = hwnd;
1945 SetWindowLongPtrW( hwnd, GWLP_USERDATA, (LONG_PTR) dialog );
1947 rec = msi_get_dialog_record( dialog );
1950 TRACE("No record found for dialog %s\n", debugstr_w(dialog->name));
1954 dialog->scale = msi_dialog_get_sans_serif_height(dialog->hwnd);
1956 size.cx = MSI_RecordGetInteger( rec, 4 );
1957 size.cy = MSI_RecordGetInteger( rec, 5 );
1958 msi_dialog_adjust_dialog_size( dialog, &size );
1960 dialog->attributes = MSI_RecordGetInteger( rec, 6 );
1962 dialog->default_font = msi_dup_property( dialog->package, df );
1963 if (!dialog->default_font)
1965 dialog->default_font = strdupW(dfv);
1966 if (!dialog->default_font) return -1;
1969 title = msi_get_deformatted_field( dialog->package, rec, 7 );
1970 SetWindowTextW( hwnd, title );
1973 SetWindowPos( hwnd, 0, 0, 0, size.cx, size.cy,
1974 SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW );
1976 msi_dialog_build_font_list( dialog );
1977 msi_dialog_fill_controls( dialog );
1978 msi_dialog_evaluate_control_conditions( dialog );
1979 msi_dialog_set_tab_order( dialog );
1980 msi_dialog_set_first_control( dialog, MSI_RecordGetString( rec, 8 ) );
1981 msiobj_release( &rec->hdr );
1986 static UINT msi_dialog_send_event( msi_dialog *dialog, LPCWSTR event, LPCWSTR arg )
1988 LPWSTR event_fmt = NULL, arg_fmt = NULL;
1990 TRACE("Sending control event %s %s\n", debugstr_w(event), debugstr_w(arg));
1992 deformat_string( dialog->package, event, &event_fmt );
1993 deformat_string( dialog->package, arg, &arg_fmt );
1995 dialog->event_handler( dialog->package, event_fmt, arg_fmt, dialog );
1997 msi_free( event_fmt );
1998 msi_free( arg_fmt );
2000 return ERROR_SUCCESS;
2003 static UINT msi_dialog_set_property( msi_dialog *dialog, LPCWSTR event, LPCWSTR arg )
2005 static const WCHAR szNullArg[] = { '{','}',0 };
2006 LPWSTR p, prop, arg_fmt = NULL;
2009 len = strlenW(event);
2010 prop = msi_alloc( len*sizeof(WCHAR));
2011 strcpyW( prop, &event[1] );
2012 p = strchrW( prop, ']' );
2013 if( p && p[1] == 0 )
2016 if( strcmpW( szNullArg, arg ) )
2017 deformat_string( dialog->package, arg, &arg_fmt );
2018 MSI_SetPropertyW( dialog->package, prop, arg_fmt );
2019 msi_free( arg_fmt );
2022 ERR("Badly formatted property string - what happens?\n");
2024 return ERROR_SUCCESS;
2027 static UINT msi_dialog_control_event( MSIRECORD *rec, LPVOID param )
2029 msi_dialog *dialog = param;
2030 LPCWSTR condition, event, arg;
2033 condition = MSI_RecordGetString( rec, 5 );
2034 r = MSI_EvaluateConditionW( dialog->package, condition );
2035 if( r == MSICONDITION_TRUE || r == MSICONDITION_NONE )
2037 event = MSI_RecordGetString( rec, 3 );
2038 arg = MSI_RecordGetString( rec, 4 );
2039 if( event[0] == '[' )
2040 msi_dialog_set_property( dialog, event, arg );
2042 msi_dialog_send_event( dialog, event, arg );
2045 return ERROR_SUCCESS;
2048 static UINT msi_dialog_button_handler( msi_dialog *dialog,
2049 msi_control *control, WPARAM param )
2051 static const WCHAR query[] = {
2052 'S','E','L','E','C','T',' ','*',' ',
2053 'F','R','O','M',' ','C','o','n','t','r','o','l','E','v','e','n','t',' ',
2054 'W','H','E','R','E',' ',
2055 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ',
2057 '`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',' ',
2058 'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','i','n','g','`',0
2060 MSIQUERY *view = NULL;
2063 if( HIWORD(param) != BN_CLICKED )
2064 return ERROR_SUCCESS;
2066 r = MSI_OpenQuery( dialog->package->db, &view, query,
2067 dialog->name, control->name );
2068 if( r != ERROR_SUCCESS )
2070 ERR("query failed\n");
2074 r = MSI_IterateRecords( view, 0, msi_dialog_control_event, dialog );
2075 msiobj_release( &view->hdr );
2080 static UINT msi_dialog_get_checkbox_state( msi_dialog *dialog,
2081 msi_control *control )
2083 WCHAR state[2] = { 0 };
2086 MSI_GetPropertyW( dialog->package, control->property, state, &sz );
2087 return state[0] ? 1 : 0;
2090 static void msi_dialog_set_checkbox_state( msi_dialog *dialog,
2091 msi_control *control, UINT state )
2093 static const WCHAR szState[] = { '1', 0 };
2096 /* if uncheck then the property is set to NULL */
2099 MSI_SetPropertyW( dialog->package, control->property, NULL );
2103 /* check for a custom state */
2104 if (control->value && control->value[0])
2105 val = control->value;
2109 MSI_SetPropertyW( dialog->package, control->property, val );
2112 static void msi_dialog_checkbox_sync_state( msi_dialog *dialog,
2113 msi_control *control )
2117 state = msi_dialog_get_checkbox_state( dialog, control );
2118 SendMessageW( control->hwnd, BM_SETCHECK,
2119 state ? BST_CHECKED : BST_UNCHECKED, 0 );
2122 static UINT msi_dialog_checkbox_handler( msi_dialog *dialog,
2123 msi_control *control, WPARAM param )
2127 if( HIWORD(param) != BN_CLICKED )
2128 return ERROR_SUCCESS;
2130 TRACE("clicked checkbox %s, set %s\n", debugstr_w(control->name),
2131 debugstr_w(control->property));
2133 state = msi_dialog_get_checkbox_state( dialog, control );
2134 state = state ? 0 : 1;
2135 msi_dialog_set_checkbox_state( dialog, control, state );
2136 msi_dialog_checkbox_sync_state( dialog, control );
2138 return msi_dialog_button_handler( dialog, control, param );
2141 static UINT msi_dialog_edit_handler( msi_dialog *dialog,
2142 msi_control *control, WPARAM param )
2147 if( HIWORD(param) != EN_CHANGE )
2148 return ERROR_SUCCESS;
2150 TRACE("edit %s contents changed, set %s\n", debugstr_w(control->name),
2151 debugstr_w(control->property));
2154 buf = msi_alloc( sz*sizeof(WCHAR) );
2157 r = GetWindowTextW( control->hwnd, buf, sz );
2161 buf = msi_realloc( buf, sz*sizeof(WCHAR) );
2164 MSI_SetPropertyW( dialog->package, control->property, buf );
2168 return ERROR_SUCCESS;
2171 static UINT msi_dialog_radiogroup_handler( msi_dialog *dialog,
2172 msi_control *control, WPARAM param )
2174 if( HIWORD(param) != BN_CLICKED )
2175 return ERROR_SUCCESS;
2177 TRACE("clicked radio button %s, set %s\n", debugstr_w(control->name),
2178 debugstr_w(control->property));
2180 MSI_SetPropertyW( dialog->package, control->property, control->name );
2182 return msi_dialog_button_handler( dialog, control, param );
2185 static LRESULT msi_dialog_oncommand( msi_dialog *dialog, WPARAM param, HWND hwnd )
2187 msi_control *control = NULL;
2189 TRACE("%p %p %08x\n", dialog, hwnd, param);
2194 control = msi_dialog_find_control( dialog, dialog->control_default );
2196 case 2: /* escape */
2197 control = msi_dialog_find_control( dialog, dialog->control_cancel );
2200 control = msi_dialog_find_control_by_hwnd( dialog, hwnd );
2205 if( control->handler )
2207 control->handler( dialog, control, param );
2208 msi_dialog_evaluate_control_conditions( dialog );
2212 ERR("button click from nowhere %p %d %p\n", dialog, param, hwnd);
2216 static void msi_dialog_setfocus( msi_dialog *dialog )
2218 HWND hwnd = dialog->hWndFocus;
2220 hwnd = GetNextDlgTabItem( dialog->hwnd, hwnd, TRUE);
2221 hwnd = GetNextDlgTabItem( dialog->hwnd, hwnd, FALSE);
2223 dialog->hWndFocus = hwnd;
2226 static LRESULT WINAPI MSIDialog_WndProc( HWND hwnd, UINT msg,
2227 WPARAM wParam, LPARAM lParam )
2229 msi_dialog *dialog = (LPVOID) GetWindowLongPtrW( hwnd, GWLP_USERDATA );
2231 TRACE("0x%04x\n", msg);
2236 return msi_dialog_oncreate( hwnd, (LPCREATESTRUCTW)lParam );
2239 return msi_dialog_oncommand( dialog, wParam, (HWND)lParam );
2242 if( LOWORD(wParam) == WA_INACTIVE )
2243 dialog->hWndFocus = GetFocus();
2245 msi_dialog_setfocus( dialog );
2249 msi_dialog_setfocus( dialog );
2252 /* bounce back to our subclassed static control */
2253 case WM_CTLCOLORSTATIC:
2254 return SendMessageW( (HWND) lParam, WM_CTLCOLORSTATIC, wParam, lParam );
2257 dialog->hwnd = NULL;
2260 return DefWindowProcW(hwnd, msg, wParam, lParam);
2263 static BOOL CALLBACK msi_radioground_child_enum( HWND hWnd, LPARAM lParam )
2265 EnableWindow( hWnd, lParam );
2269 static LRESULT WINAPI MSIRadioGroup_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
2271 WNDPROC oldproc = (WNDPROC) GetPropW(hWnd, szButtonData);
2274 TRACE("hWnd %p msg %04x wParam 0x%08x lParam 0x%08lx\n", hWnd, msg, wParam, lParam);
2276 if (msg == WM_COMMAND) /* Forward notifications to dialog */
2277 SendMessageW(GetParent(hWnd), msg, wParam, lParam);
2279 r = CallWindowProcW(oldproc, hWnd, msg, wParam, lParam);
2281 /* make sure the radio buttons show as disabled if the parent is disabled */
2282 if (msg == WM_ENABLE)
2283 EnumChildWindows( hWnd, msi_radioground_child_enum, wParam );
2288 static LRESULT WINAPI MSIHiddenWindowProc( HWND hwnd, UINT msg,
2289 WPARAM wParam, LPARAM lParam )
2291 msi_dialog *dialog = (msi_dialog*) lParam;
2293 TRACE("%d %p\n", msg, dialog);
2297 case WM_MSI_DIALOG_CREATE:
2298 return msi_dialog_run_message_loop( dialog );
2299 case WM_MSI_DIALOG_DESTROY:
2300 msi_dialog_destroy( dialog );
2303 return DefWindowProcW( hwnd, msg, wParam, lParam );
2306 /* functions that interface to other modules within MSI */
2308 msi_dialog *msi_dialog_create( MSIPACKAGE* package, LPCWSTR szDialogName,
2309 msi_dialog_event_handler event_handler )
2311 MSIRECORD *rec = NULL;
2314 TRACE("%p %s\n", package, debugstr_w(szDialogName));
2316 /* allocate the structure for the dialog to use */
2317 dialog = msi_alloc_zero( sizeof *dialog + sizeof(WCHAR)*strlenW(szDialogName) );
2320 strcpyW( dialog->name, szDialogName );
2321 msiobj_addref( &package->hdr );
2322 dialog->package = package;
2323 dialog->event_handler = event_handler;
2324 dialog->finished = 0;
2325 list_init( &dialog->controls );
2327 /* verify that the dialog exists */
2328 rec = msi_get_dialog_record( dialog );
2331 msiobj_release( &package->hdr );
2335 dialog->attributes = MSI_RecordGetInteger( rec, 6 );
2336 dialog->control_default = strdupW( MSI_RecordGetString( rec, 9 ) );
2337 dialog->control_cancel = strdupW( MSI_RecordGetString( rec, 10 ) );
2338 msiobj_release( &rec->hdr );
2343 static void msi_process_pending_messages( HWND hdlg )
2347 while( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ) )
2349 if( hdlg && IsDialogMessageW( hdlg, &msg ))
2351 TranslateMessage( &msg );
2352 DispatchMessageW( &msg );
2356 void msi_dialog_end_dialog( msi_dialog *dialog )
2358 TRACE("%p\n", dialog);
2359 dialog->finished = 1;
2360 PostMessageW(dialog->hwnd, WM_NULL, 0, 0);
2363 void msi_dialog_check_messages( HANDLE handle )
2367 /* in threads other than the UI thread, block */
2368 if( uiThreadId != GetCurrentThreadId() )
2371 WaitForSingleObject( handle, INFINITE );
2375 /* there's two choices for the UI thread */
2378 msi_process_pending_messages( NULL );
2384 * block here until somebody creates a new dialog or
2385 * the handle we're waiting on becomes ready
2387 r = MsgWaitForMultipleObjects( 1, &handle, 0, INFINITE, QS_ALLINPUT );
2388 if( r == WAIT_OBJECT_0 )
2393 UINT msi_dialog_run_message_loop( msi_dialog *dialog )
2398 if( uiThreadId != GetCurrentThreadId() )
2399 return SendMessageW( hMsiHiddenWindow, WM_MSI_DIALOG_CREATE, 0, (LPARAM) dialog );
2401 /* create the dialog window, don't show it yet */
2402 style = WS_OVERLAPPED;
2403 if( dialog->attributes & msidbDialogAttributesVisible )
2404 style |= WS_VISIBLE;
2406 hwnd = CreateWindowW( szMsiDialogClass, dialog->name, style,
2407 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
2408 NULL, NULL, NULL, dialog );
2411 ERR("Failed to create dialog %s\n", debugstr_w( dialog->name ));
2412 return ERROR_FUNCTION_FAILED;
2415 ShowWindow( hwnd, SW_SHOW );
2416 /* UpdateWindow( hwnd ); - and causes the transparent static controls not to paint */
2418 if( dialog->attributes & msidbDialogAttributesModal )
2420 while( !dialog->finished )
2422 MsgWaitForMultipleObjects( 0, NULL, 0, INFINITE, QS_ALLEVENTS );
2423 msi_process_pending_messages( dialog->hwnd );
2427 return ERROR_IO_PENDING;
2429 return ERROR_SUCCESS;
2432 void msi_dialog_do_preview( msi_dialog *dialog )
2435 dialog->attributes |= msidbDialogAttributesVisible;
2436 dialog->attributes &= ~msidbDialogAttributesModal;
2437 msi_dialog_run_message_loop( dialog );
2440 void msi_dialog_destroy( msi_dialog *dialog )
2442 if( uiThreadId != GetCurrentThreadId() )
2444 SendMessageW( hMsiHiddenWindow, WM_MSI_DIALOG_DESTROY, 0, (LPARAM) dialog );
2449 ShowWindow( dialog->hwnd, SW_HIDE );
2452 DestroyWindow( dialog->hwnd );
2454 /* destroy the list of controls */
2455 while( !list_empty( &dialog->controls ) )
2457 msi_control *t = LIST_ENTRY( list_head( &dialog->controls ),
2458 msi_control, entry );
2459 list_remove( &t->entry );
2460 /* leave dialog->hwnd - destroying parent destroys child windows */
2461 msi_free( t->property );
2462 msi_free( t->value );
2464 DeleteObject( t->hBitmap );
2466 DestroyIcon( t->hIcon );
2467 msi_free( t->tabnext );
2470 FreeLibrary( t->hDll );
2473 /* destroy the list of fonts */
2474 while( dialog->font_list )
2476 msi_font *t = dialog->font_list;
2477 dialog->font_list = t->next;
2478 DeleteObject( t->hfont );
2481 msi_free( dialog->default_font );
2483 msi_free( dialog->control_default );
2484 msi_free( dialog->control_cancel );
2485 msiobj_release( &dialog->package->hdr );
2486 dialog->package = NULL;
2490 BOOL msi_dialog_register_class( void )
2494 ZeroMemory( &cls, sizeof cls );
2495 cls.lpfnWndProc = MSIDialog_WndProc;
2496 cls.hInstance = NULL;
2497 cls.hIcon = LoadIconW(0, (LPWSTR)IDI_APPLICATION);
2498 cls.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
2499 cls.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
2500 cls.lpszMenuName = NULL;
2501 cls.lpszClassName = szMsiDialogClass;
2503 if( !RegisterClassW( &cls ) )
2506 cls.lpfnWndProc = MSIHiddenWindowProc;
2507 cls.lpszClassName = szMsiHiddenWindow;
2509 if( !RegisterClassW( &cls ) )
2512 uiThreadId = GetCurrentThreadId();
2514 hMsiHiddenWindow = CreateWindowW( szMsiHiddenWindow, NULL, WS_OVERLAPPED,
2515 0, 0, 100, 100, NULL, NULL, NULL, NULL );
2516 if( !hMsiHiddenWindow )
2522 void msi_dialog_unregister_class( void )
2524 DestroyWindow( hMsiHiddenWindow );
2525 hMsiHiddenWindow = NULL;
2526 UnregisterClassW( szMsiDialogClass, NULL );
2527 UnregisterClassW( szMsiHiddenWindow, NULL );