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
42 #include "wine/debug.h"
43 #include "wine/unicode.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(msi);
47 extern HINSTANCE msi_hInstance;
49 struct msi_control_tag;
50 typedef struct msi_control_tag msi_control;
51 typedef UINT (*msi_handler)( msi_dialog *, msi_control *, WPARAM );
52 typedef void (*msi_update)( msi_dialog *, msi_control * );
54 struct msi_control_tag
67 float progress_current;
73 typedef struct msi_font_tag
85 msi_dialog_event_handler event_handler;
95 LPWSTR control_default;
96 LPWSTR control_cancel;
100 typedef UINT (*msi_dialog_control_func)( msi_dialog *dialog, MSIRECORD *rec );
101 struct control_handler
103 LPCWSTR control_type;
104 msi_dialog_control_func func;
113 } radio_button_group_descr;
115 static const WCHAR szMsiDialogClass[] = { 'M','s','i','D','i','a','l','o','g','C','l','o','s','e','C','l','a','s','s',0 };
116 static const WCHAR szMsiHiddenWindow[] = { 'M','s','i','H','i','d','d','e','n','W','i','n','d','o','w',0 };
117 static const WCHAR szStatic[] = { 'S','t','a','t','i','c',0 };
118 static const WCHAR szButton[] = { 'B','U','T','T','O','N', 0 };
119 static const WCHAR szButtonData[] = { 'M','S','I','D','A','T','A',0 };
120 static const WCHAR szProgress[] = { 'P','r','o','g','r','e','s','s',0 };
121 static const WCHAR szText[] = { 'T','e','x','t',0 };
122 static const WCHAR szPushButton[] = { 'P','u','s','h','B','u','t','t','o','n',0 };
123 static const WCHAR szLine[] = { 'L','i','n','e',0 };
124 static const WCHAR szBitmap[] = { 'B','i','t','m','a','p',0 };
125 static const WCHAR szCheckBox[] = { 'C','h','e','c','k','B','o','x',0 };
126 static const WCHAR szScrollableText[] = { 'S','c','r','o','l','l','a','b','l','e','T','e','x','t',0 };
127 static const WCHAR szComboBox[] = { 'C','o','m','b','o','B','o','x',0 };
128 static const WCHAR szEdit[] = { 'E','d','i','t',0 };
129 static const WCHAR szMaskedEdit[] = { 'M','a','s','k','e','d','E','d','i','t',0 };
130 static const WCHAR szPathEdit[] = { 'P','a','t','h','E','d','i','t',0 };
131 static const WCHAR szProgressBar[] = { 'P','r','o','g','r','e','s','s','B','a','r',0 };
132 static const WCHAR szSetProgress[] = { 'S','e','t','P','r','o','g','r','e','s','s',0 };
133 static const WCHAR szRadioButtonGroup[] = { '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[] = { 'S','e','l','e','c','t','i','o','n','T','r','e','e',0 };
136 static const WCHAR szGroupBox[] = { 'G','r','o','u','p','B','o','x',0 };
137 static const WCHAR szListBox[] = { 'L','i','s','t','B','o','x',0 };
138 static const WCHAR szDirectoryCombo[] = { 'D','i','r','e','c','t','o','r','y','C','o','m','b','o',0 };
139 static const WCHAR szDirectoryList[] = { 'D','i','r','e','c','t','o','r','y','L','i','s','t',0 };
140 static const WCHAR szVolumeCostList[] = { 'V','o','l','u','m','e','C','o','s','t','L','i','s','t',0 };
141 static const WCHAR szVolumeSelectCombo[] = { 'V','o','l','u','m','e','S','e','l','e','c','t','C','o','m','b','o',0 };
142 static const WCHAR szSelectionDescription[] = {'S','e','l','e','c','t','i','o','n','D','e','s','c','r','i','p','t','i','o','n',0};
143 static const WCHAR szSelectionPath[] = {'S','e','l','e','c','t','i','o','n','P','a','t','h',0};
144 static const WCHAR szProperty[] = {'P','r','o','p','e','r','t','y',0};
146 /* dialog sequencing */
148 #define WM_MSI_DIALOG_CREATE (WM_USER+0x100)
149 #define WM_MSI_DIALOG_DESTROY (WM_USER+0x101)
151 #define USER_INSTALLSTATE_ALL 0x1000
153 static DWORD uiThreadId;
154 static HWND hMsiHiddenWindow;
156 static LPWSTR msi_get_window_text( HWND hwnd )
162 buf = msi_alloc( sz*sizeof(WCHAR) );
165 r = GetWindowTextW( hwnd, buf, sz );
169 buf = msi_realloc( buf, sz*sizeof(WCHAR) );
175 static INT msi_dialog_scale_unit( msi_dialog *dialog, INT val )
177 return MulDiv( val, dialog->scale, 12 );
180 static msi_control *msi_dialog_find_control( msi_dialog *dialog, LPCWSTR name )
182 msi_control *control;
188 LIST_FOR_EACH_ENTRY( control, &dialog->controls, msi_control, entry )
189 if( !strcmpW( control->name, name ) ) /* FIXME: case sensitive? */
194 static msi_control *msi_dialog_find_control_by_type( msi_dialog *dialog, LPCWSTR type )
196 msi_control *control;
202 LIST_FOR_EACH_ENTRY( control, &dialog->controls, msi_control, entry )
203 if( !strcmpW( control->type, type ) ) /* FIXME: case sensitive? */
208 static msi_control *msi_dialog_find_control_by_hwnd( msi_dialog *dialog, HWND hwnd )
210 msi_control *control;
214 LIST_FOR_EACH_ENTRY( control, &dialog->controls, msi_control, entry )
215 if( hwnd == control->hwnd )
220 static LPWSTR msi_get_deformatted_field( MSIPACKAGE *package, MSIRECORD *rec, int field )
222 LPCWSTR str = MSI_RecordGetString( rec, field );
226 deformat_string( package, str, &ret );
230 static LPWSTR msi_dialog_dup_property( msi_dialog *dialog, LPCWSTR property, BOOL indirect )
238 prop = msi_dup_property( dialog->package->db, property );
241 prop = strdupW( property );
246 msi_dialog *msi_dialog_get_parent( msi_dialog *dialog )
248 return dialog->parent;
251 LPWSTR msi_dialog_get_name( msi_dialog *dialog )
257 * msi_dialog_get_style
259 * Extract the {\style} string from the front of the text to display and
260 * update the pointer. Only the last style in a list is applied.
262 static LPWSTR msi_dialog_get_style( LPCWSTR p, LPCWSTR *rest )
273 while ((first = strchrW( p, '{' )) && (q = strchrW( first + 1, '}' )))
276 if( *p != '\\' && *p != '&' )
279 /* little bit of sanity checking to stop us getting confused with RTF */
280 for( i=++p; i<q; i++ )
281 if( *i == '}' || *i == '\\' )
291 ret = msi_alloc( len*sizeof(WCHAR) );
294 memcpy( ret, p, len*sizeof(WCHAR) );
299 static UINT msi_dialog_add_font( MSIRECORD *rec, LPVOID param )
301 msi_dialog *dialog = param;
308 /* create a font and add it to the list */
309 name = MSI_RecordGetString( rec, 1 );
310 font = msi_alloc( sizeof *font + strlenW( name )*sizeof (WCHAR) );
311 strcpyW( font->name, name );
312 list_add_head( &dialog->fonts, &font->entry );
314 font->color = MSI_RecordGetInteger( rec, 4 );
316 memset( &lf, 0, sizeof lf );
317 face = MSI_RecordGetString( rec, 2 );
318 lf.lfHeight = MSI_RecordGetInteger( rec, 3 );
319 style = MSI_RecordGetInteger( rec, 5 );
320 if( style & msidbTextStyleStyleBitsBold )
321 lf.lfWeight = FW_BOLD;
322 if( style & msidbTextStyleStyleBitsItalic )
324 if( style & msidbTextStyleStyleBitsUnderline )
325 lf.lfUnderline = TRUE;
326 if( style & msidbTextStyleStyleBitsStrike )
327 lf.lfStrikeOut = TRUE;
328 lstrcpynW( lf.lfFaceName, face, LF_FACESIZE );
330 /* adjust the height */
331 hdc = GetDC( dialog->hwnd );
334 lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
335 ReleaseDC( dialog->hwnd, hdc );
338 font->hfont = CreateFontIndirectW( &lf );
340 TRACE("Adding font style %s\n", debugstr_w(font->name) );
342 return ERROR_SUCCESS;
345 static msi_font *msi_dialog_find_font( msi_dialog *dialog, LPCWSTR name )
347 msi_font *font = NULL;
349 LIST_FOR_EACH_ENTRY( font, &dialog->fonts, msi_font, entry )
350 if( !strcmpW( font->name, name ) ) /* FIXME: case sensitive? */
356 static UINT msi_dialog_set_font( msi_dialog *dialog, HWND hwnd, LPCWSTR name )
360 font = msi_dialog_find_font( dialog, name );
362 SendMessageW( hwnd, WM_SETFONT, (WPARAM) font->hfont, TRUE );
364 ERR("No font entry for %s\n", debugstr_w(name));
365 return ERROR_SUCCESS;
368 static UINT msi_dialog_build_font_list( msi_dialog *dialog )
370 static const WCHAR query[] = {
371 'S','E','L','E','C','T',' ','*',' ',
372 'F','R','O','M',' ','`','T','e','x','t','S','t','y','l','e','`',' ',0
375 MSIQUERY *view = NULL;
377 TRACE("dialog %p\n", dialog );
379 r = MSI_OpenQuery( dialog->package->db, &view, query );
380 if( r != ERROR_SUCCESS )
383 r = MSI_IterateRecords( view, NULL, msi_dialog_add_font, dialog );
384 msiobj_release( &view->hdr );
389 static void msi_destroy_control( msi_control *t )
391 list_remove( &t->entry );
392 /* leave dialog->hwnd - destroying parent destroys child windows */
393 msi_free( t->property );
394 msi_free( t->value );
396 DeleteObject( t->hBitmap );
398 DestroyIcon( t->hIcon );
399 msi_free( t->tabnext );
402 FreeLibrary( t->hDll );
406 static msi_control *msi_dialog_create_window( msi_dialog *dialog,
407 MSIRECORD *rec, DWORD exstyle, LPCWSTR szCls, LPCWSTR name, LPCWSTR text,
408 DWORD style, HWND parent )
410 DWORD x, y, width, height;
411 LPWSTR font = NULL, title_font = NULL;
412 LPCWSTR title = NULL;
413 msi_control *control;
417 control = msi_alloc( sizeof *control + strlenW(name)*sizeof(WCHAR) );
421 strcpyW( control->name, name );
422 list_add_tail( &dialog->controls, &control->entry );
423 control->handler = NULL;
424 control->update = NULL;
425 control->property = NULL;
426 control->value = NULL;
427 control->hBitmap = NULL;
428 control->hIcon = NULL;
429 control->hDll = NULL;
430 control->tabnext = strdupW( MSI_RecordGetString( rec, 11) );
431 control->type = strdupW( MSI_RecordGetString( rec, 3 ) );
432 control->progress_current = 0;
433 control->progress_max = 100;
435 x = MSI_RecordGetInteger( rec, 4 );
436 y = MSI_RecordGetInteger( rec, 5 );
437 width = MSI_RecordGetInteger( rec, 6 );
438 height = MSI_RecordGetInteger( rec, 7 );
440 x = msi_dialog_scale_unit( dialog, x );
441 y = msi_dialog_scale_unit( dialog, y );
442 width = msi_dialog_scale_unit( dialog, width );
443 height = msi_dialog_scale_unit( dialog, height );
447 deformat_string( dialog->package, text, &title_font );
448 font = msi_dialog_get_style( title_font, &title );
451 control->hwnd = CreateWindowExW( exstyle, szCls, title, style,
452 x, y, width, height, parent, NULL, NULL, NULL );
454 TRACE("Dialog %s control %s hwnd %p\n",
455 debugstr_w(dialog->name), debugstr_w(text), control->hwnd );
457 msi_dialog_set_font( dialog, control->hwnd,
458 font ? font : dialog->default_font );
460 msi_free( title_font );
466 static LPWSTR msi_dialog_get_uitext( msi_dialog *dialog, LPCWSTR key )
471 static const WCHAR query[] = {
472 's','e','l','e','c','t',' ','*',' ',
473 'f','r','o','m',' ','`','U','I','T','e','x','t','`',' ',
474 'w','h','e','r','e',' ','`','K','e','y','`',' ','=',' ','\'','%','s','\'',0
477 rec = MSI_QueryGetRecord( dialog->package->db, query, key );
478 if (!rec) return NULL;
479 text = strdupW( MSI_RecordGetString( rec, 2 ) );
480 msiobj_release( &rec->hdr );
484 static MSIRECORD *msi_get_binary_record( MSIDATABASE *db, LPCWSTR name )
486 static const WCHAR query[] = {
487 's','e','l','e','c','t',' ','*',' ',
488 'f','r','o','m',' ','B','i','n','a','r','y',' ',
489 'w','h','e','r','e',' ',
490 '`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0
493 return MSI_QueryGetRecord( db, query, name );
496 static LPWSTR msi_create_tmp_path(void)
502 r = GetTempPathW( MAX_PATH, tmp );
505 len = lstrlenW( tmp ) + 20;
506 path = msi_alloc( len * sizeof (WCHAR) );
509 r = GetTempFileNameW( tmp, szMsi, 0, path );
519 static HANDLE msi_load_image( MSIDATABASE *db, LPCWSTR name, UINT type,
520 UINT cx, UINT cy, UINT flags )
522 MSIRECORD *rec = NULL;
523 HANDLE himage = NULL;
527 TRACE("%p %s %u %u %08x\n", db, debugstr_w(name), cx, cy, flags);
529 tmp = msi_create_tmp_path();
533 rec = msi_get_binary_record( db, name );
536 r = MSI_RecordStreamToFile( rec, 2, tmp );
537 if( r == ERROR_SUCCESS )
539 himage = LoadImageW( 0, tmp, type, cx, cy, flags );
541 msiobj_release( &rec->hdr );
549 static HICON msi_load_icon( MSIDATABASE *db, LPCWSTR text, UINT attributes )
551 DWORD cx = 0, cy = 0, flags;
553 flags = LR_LOADFROMFILE | LR_DEFAULTSIZE;
554 if( attributes & msidbControlAttributesFixedSize )
556 flags &= ~LR_DEFAULTSIZE;
557 if( attributes & msidbControlAttributesIconSize16 )
562 if( attributes & msidbControlAttributesIconSize32 )
567 /* msidbControlAttributesIconSize48 handled by above logic */
569 return msi_load_image( db, text, IMAGE_ICON, cx, cy, flags );
572 static void msi_dialog_update_controls( msi_dialog *dialog, LPCWSTR property )
574 msi_control *control;
576 LIST_FOR_EACH_ENTRY( control, &dialog->controls, msi_control, entry )
578 if ( control->property && !strcmpW( control->property, property ) && control->update )
579 control->update( dialog, control );
583 static void msi_dialog_set_property( MSIPACKAGE *package, LPCWSTR property, LPCWSTR value )
585 UINT r = msi_set_property( package->db, property, value );
586 if (r == ERROR_SUCCESS && !strcmpW( property, szSourceDir ))
587 msi_reset_folders( package, TRUE );
590 static MSIFEATURE *msi_seltree_feature_from_item( HWND hwnd, HTREEITEM hItem )
594 /* get the feature from the item */
595 memset( &tvi, 0, sizeof tvi );
597 tvi.mask = TVIF_PARAM | TVIF_HANDLE;
598 SendMessageW( hwnd, TVM_GETITEMW, 0, (LPARAM)&tvi );
599 return (MSIFEATURE *)tvi.lParam;
602 struct msi_selection_tree_info
610 static MSIFEATURE *msi_seltree_get_selected_feature( msi_control *control )
612 struct msi_selection_tree_info *info = GetPropW( control->hwnd, szButtonData );
613 return msi_seltree_feature_from_item( control->hwnd, info->selected );
616 /* called from the Control Event subscription code */
617 void msi_dialog_handle_event( msi_dialog* dialog, LPCWSTR control,
618 LPCWSTR attribute, MSIRECORD *rec )
621 LPCWSTR font_text, text = NULL;
624 ctrl = msi_dialog_find_control( dialog, control );
627 if( !strcmpW( attribute, szText ) )
629 font_text = MSI_RecordGetString( rec , 1 );
630 font = msi_dialog_get_style( font_text, &text );
631 if (!text) text = szEmpty;
632 SetWindowTextW( ctrl->hwnd, text );
634 msi_dialog_check_messages( NULL );
636 else if( !strcmpW( attribute, szProgress ) )
640 func = MSI_RecordGetInteger( rec , 1 );
641 val = MSI_RecordGetInteger( rec , 2 );
643 TRACE("progress: func %u, val %u\n", func, val);
648 ctrl->progress_max = val;
649 ctrl->progress_current = 0;
650 SendMessageW(ctrl->hwnd, PBM_SETRANGE, 0, MAKELPARAM(0,100));
651 SendMessageW(ctrl->hwnd, PBM_SETPOS, 0, 0);
653 case 1: /* FIXME: not sure what this is supposed to do */
656 ctrl->progress_current += val;
657 if (ctrl->progress_current > ctrl->progress_max)
658 ctrl->progress_current = ctrl->progress_max;
659 SendMessageW(ctrl->hwnd, PBM_SETPOS, MulDiv(100, ctrl->progress_current, ctrl->progress_max), 0);
662 FIXME("Unknown progress message %u\n", func);
666 else if ( !strcmpW( attribute, szProperty ) )
668 MSIFEATURE *feature = msi_seltree_get_selected_feature( ctrl );
669 msi_dialog_set_property( dialog->package, ctrl->property, feature->Directory );
671 else if ( !strcmpW( attribute, szSelectionPath ) )
673 LPWSTR prop = msi_dialog_dup_property( dialog, ctrl->property, TRUE );
676 path = msi_dup_property( dialog->package->db, prop );
677 SetWindowTextW( ctrl->hwnd, path );
683 FIXME("Attribute %s not being set\n", debugstr_w(attribute));
688 static void msi_dialog_map_events(msi_dialog* dialog, LPCWSTR control)
690 static const WCHAR Query[] = {
691 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
692 '`','E','v','e','n','t','M','a','p','p','i','n','g','`',' ',
693 'W','H','E','R','E',' ',
694 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ',
696 '`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',0
699 LPCWSTR event, attribute;
701 row = MSI_QueryGetRecord( dialog->package->db, Query, dialog->name, control );
705 event = MSI_RecordGetString( row, 3 );
706 attribute = MSI_RecordGetString( row, 4 );
707 ControlEvent_SubscribeToEvent( dialog->package, dialog, event, control, attribute );
708 msiobj_release( &row->hdr );
711 /* everything except radio buttons */
712 static msi_control *msi_dialog_add_control( msi_dialog *dialog,
713 MSIRECORD *rec, LPCWSTR szCls, DWORD style )
719 name = MSI_RecordGetString( rec, 2 );
720 attributes = MSI_RecordGetInteger( rec, 8 );
721 text = MSI_RecordGetString( rec, 10 );
723 TRACE("%s, %s, %08x, %s, %08x\n", debugstr_w(szCls), debugstr_w(name),
724 attributes, debugstr_w(text), style);
726 if( attributes & msidbControlAttributesVisible )
728 if( ~attributes & msidbControlAttributesEnabled )
729 style |= WS_DISABLED;
730 if( attributes & msidbControlAttributesSunken )
731 exstyle |= WS_EX_CLIENTEDGE;
733 msi_dialog_map_events(dialog, name);
735 return msi_dialog_create_window( dialog, rec, exstyle, szCls, name,
736 text, style, dialog->hwnd );
747 * we don't erase our own background,
748 * so we have to make sure that the parent window redraws first
750 static void msi_text_on_settext( HWND hWnd )
755 hParent = GetParent( hWnd );
756 GetWindowRect( hWnd, &rc );
757 MapWindowPoints( NULL, hParent, (LPPOINT) &rc, 2 );
758 InvalidateRect( hParent, &rc, TRUE );
761 static LRESULT WINAPI
762 MSIText_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
764 struct msi_text_info *info;
767 TRACE("%p %04x %08lx %08lx\n", hWnd, msg, wParam, lParam);
769 info = GetPropW(hWnd, szButtonData);
771 if( msg == WM_CTLCOLORSTATIC &&
772 ( info->attributes & msidbControlAttributesTransparent ) )
774 SetBkMode( (HDC)wParam, TRANSPARENT );
775 return (LRESULT) GetStockObject(NULL_BRUSH);
778 r = CallWindowProcW(info->oldproc, hWnd, msg, wParam, lParam);
780 SetTextColor( (HDC)wParam, info->font->color );
785 msi_text_on_settext( hWnd );
789 RemovePropW( hWnd, szButtonData );
796 static UINT msi_dialog_text_control( msi_dialog *dialog, MSIRECORD *rec )
798 msi_control *control;
799 struct msi_text_info *info;
800 LPCWSTR text, ptr, prop, control_name;
803 TRACE("%p %p\n", dialog, rec);
805 control = msi_dialog_add_control( dialog, rec, szStatic, SS_LEFT | WS_GROUP );
807 return ERROR_FUNCTION_FAILED;
809 info = msi_alloc( sizeof *info );
811 return ERROR_SUCCESS;
813 control_name = MSI_RecordGetString( rec, 2 );
814 control->attributes = MSI_RecordGetInteger( rec, 8 );
815 prop = MSI_RecordGetString( rec, 9 );
816 control->property = msi_dialog_dup_property( dialog, prop, FALSE );
818 text = MSI_RecordGetString( rec, 10 );
819 font_name = msi_dialog_get_style( text, &ptr );
820 info->font = ( font_name ) ? msi_dialog_find_font( dialog, font_name ) : NULL;
821 msi_free( font_name );
823 info->attributes = MSI_RecordGetInteger( rec, 8 );
824 if( info->attributes & msidbControlAttributesTransparent )
825 SetWindowLongPtrW( control->hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT );
827 info->oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
828 (LONG_PTR)MSIText_WndProc );
829 SetPropW( control->hwnd, szButtonData, info );
831 ControlEvent_SubscribeToEvent( dialog->package, dialog,
832 szSelectionPath, control_name, szSelectionPath );
834 return ERROR_SUCCESS;
837 /* strip any leading text style label from text field */
838 static WCHAR *msi_get_binary_name( MSIPACKAGE *package, MSIRECORD *rec )
842 text = msi_get_deformatted_field( package, rec, 10 );
847 while (*p && *p != '{') p++;
848 if (!*p++) return text;
850 while (*p && *p != '}') p++;
851 if (!*p++) return text;
858 static UINT msi_dialog_set_property_event( msi_dialog *dialog, LPCWSTR event, LPCWSTR arg )
860 static const WCHAR szNullArg[] = {'{','}',0};
861 LPWSTR p, prop, arg_fmt = NULL;
864 len = strlenW( event );
865 prop = msi_alloc( len * sizeof(WCHAR) );
866 strcpyW( prop, &event[1] );
867 p = strchrW( prop, ']' );
868 if (p && (p[1] == 0 || p[1] == ' '))
871 if (strcmpW( szNullArg, arg ))
872 deformat_string( dialog->package, arg, &arg_fmt );
873 msi_dialog_set_property( dialog->package, prop, arg_fmt );
874 msi_dialog_update_controls( dialog, prop );
877 else ERR("Badly formatted property string - what happens?\n");
879 return ERROR_SUCCESS;
882 static UINT msi_dialog_send_event( msi_dialog *dialog, LPCWSTR event, LPCWSTR arg )
884 LPWSTR event_fmt = NULL, arg_fmt = NULL;
886 TRACE("Sending control event %s %s\n", debugstr_w(event), debugstr_w(arg));
888 deformat_string( dialog->package, event, &event_fmt );
889 deformat_string( dialog->package, arg, &arg_fmt );
891 dialog->event_handler( dialog->package, event_fmt, arg_fmt, dialog );
893 msi_free( event_fmt );
896 return ERROR_SUCCESS;
899 static UINT msi_dialog_control_event( MSIRECORD *rec, LPVOID param )
901 msi_dialog *dialog = param;
902 LPCWSTR condition, event, arg;
905 condition = MSI_RecordGetString( rec, 5 );
906 r = MSI_EvaluateConditionW( dialog->package, condition );
907 if (r == MSICONDITION_TRUE || r == MSICONDITION_NONE)
909 event = MSI_RecordGetString( rec, 3 );
910 arg = MSI_RecordGetString( rec, 4 );
912 msi_dialog_set_property_event( dialog, event, arg );
914 msi_dialog_send_event( dialog, event, arg );
916 return ERROR_SUCCESS;
919 static UINT msi_dialog_button_handler( msi_dialog *dialog, msi_control *control, WPARAM param )
921 static const WCHAR query[] = {
922 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
923 'C','o','n','t','r','o','l','E','v','e','n','t',' ','W','H','E','R','E',' ',
924 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ','A','N','D',' ',
925 '`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',' ',
926 'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','i','n','g','`',0};
927 MSIQUERY *view = NULL;
930 if (HIWORD(param) != BN_CLICKED)
931 return ERROR_SUCCESS;
933 r = MSI_OpenQuery( dialog->package->db, &view, query, dialog->name, control->name );
934 if (r != ERROR_SUCCESS)
936 ERR("query failed\n");
940 r = MSI_IterateRecords( view, 0, msi_dialog_control_event, dialog );
941 msiobj_release( &view->hdr );
945 static UINT msi_dialog_button_control( msi_dialog *dialog, MSIRECORD *rec )
947 msi_control *control;
948 UINT attributes, style;
950 TRACE("%p %p\n", dialog, rec);
953 attributes = MSI_RecordGetInteger( rec, 8 );
954 if( attributes & msidbControlAttributesIcon )
957 control = msi_dialog_add_control( dialog, rec, szButton, style );
959 return ERROR_FUNCTION_FAILED;
961 control->handler = msi_dialog_button_handler;
963 if (attributes & msidbControlAttributesIcon)
966 LPWSTR name = msi_get_binary_name( dialog->package, rec );
967 control->hIcon = msi_load_icon( dialog->package->db, name, attributes );
970 SendMessageW( control->hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM) control->hIcon );
973 ERR("Failed to load icon %s\n", debugstr_w(name));
977 return ERROR_SUCCESS;
980 static LPWSTR msi_get_checkbox_value( msi_dialog *dialog, LPCWSTR prop )
982 static const WCHAR query[] = {
983 'S','E','L','E','C','T',' ','*',' ',
984 'F','R','O','M',' ','`','C','h','e','c','k','B','o','x','`',' ',
985 'W','H','E','R','E',' ',
986 '`','P','r','o','p','e','r','t','y','`',' ','=',' ',
989 MSIRECORD *rec = NULL;
992 /* find if there is a value associated with the checkbox */
993 rec = MSI_QueryGetRecord( dialog->package->db, query, prop );
997 ret = msi_get_deformatted_field( dialog->package, rec, 2 );
1003 msiobj_release( &rec->hdr );
1007 ret = msi_dup_property( dialog->package->db, prop );
1008 if( ret && !ret[0] )
1017 static UINT msi_dialog_get_checkbox_state( msi_dialog *dialog, msi_control *control )
1019 WCHAR state[2] = {0};
1022 msi_get_property( dialog->package->db, control->property, state, &sz );
1023 return state[0] ? 1 : 0;
1026 static void msi_dialog_set_checkbox_state( msi_dialog *dialog, msi_control *control, UINT state )
1028 static const WCHAR szState[] = {'1',0};
1031 /* if uncheck then the property is set to NULL */
1034 msi_dialog_set_property( dialog->package, control->property, NULL );
1038 /* check for a custom state */
1039 if (control->value && control->value[0])
1040 val = control->value;
1044 msi_dialog_set_property( dialog->package, control->property, val );
1047 static void msi_dialog_checkbox_sync_state( msi_dialog *dialog, msi_control *control )
1049 UINT state = msi_dialog_get_checkbox_state( dialog, control );
1050 SendMessageW( control->hwnd, BM_SETCHECK, state ? BST_CHECKED : BST_UNCHECKED, 0 );
1053 static UINT msi_dialog_checkbox_handler( msi_dialog *dialog, msi_control *control, WPARAM param )
1057 if (HIWORD(param) != BN_CLICKED)
1058 return ERROR_SUCCESS;
1060 TRACE("clicked checkbox %s, set %s\n", debugstr_w(control->name), debugstr_w(control->property));
1062 state = msi_dialog_get_checkbox_state( dialog, control );
1063 state = state ? 0 : 1;
1064 msi_dialog_set_checkbox_state( dialog, control, state );
1065 msi_dialog_checkbox_sync_state( dialog, control );
1067 return msi_dialog_button_handler( dialog, control, param );
1070 static UINT msi_dialog_checkbox_control( msi_dialog *dialog, MSIRECORD *rec )
1072 msi_control *control;
1075 TRACE("%p %p\n", dialog, rec);
1077 control = msi_dialog_add_control( dialog, rec, szButton, BS_CHECKBOX | BS_MULTILINE | WS_TABSTOP );
1078 control->handler = msi_dialog_checkbox_handler;
1079 control->update = msi_dialog_checkbox_sync_state;
1080 prop = MSI_RecordGetString( rec, 9 );
1083 control->property = strdupW( prop );
1084 control->value = msi_get_checkbox_value( dialog, prop );
1085 TRACE("control %s value %s\n", debugstr_w(control->property), debugstr_w(control->value));
1087 msi_dialog_checkbox_sync_state( dialog, control );
1088 return ERROR_SUCCESS;
1091 static UINT msi_dialog_line_control( msi_dialog *dialog, MSIRECORD *rec )
1095 DWORD style, exstyle = 0;
1096 DWORD x, y, width, height;
1097 msi_control *control;
1099 TRACE("%p %p\n", dialog, rec);
1101 style = WS_CHILD | SS_ETCHEDHORZ | SS_SUNKEN;
1103 name = MSI_RecordGetString( rec, 2 );
1104 attributes = MSI_RecordGetInteger( rec, 8 );
1106 if( attributes & msidbControlAttributesVisible )
1107 style |= WS_VISIBLE;
1108 if( ~attributes & msidbControlAttributesEnabled )
1109 style |= WS_DISABLED;
1110 if( attributes & msidbControlAttributesSunken )
1111 exstyle |= WS_EX_CLIENTEDGE;
1113 msi_dialog_map_events(dialog, name);
1115 control = msi_alloc( sizeof(*control) + strlenW(name) * sizeof(WCHAR) );
1117 return ERROR_OUTOFMEMORY;
1119 strcpyW( control->name, name );
1120 list_add_head( &dialog->controls, &control->entry );
1121 control->handler = NULL;
1122 control->property = NULL;
1123 control->value = NULL;
1124 control->hBitmap = NULL;
1125 control->hIcon = NULL;
1126 control->hDll = NULL;
1127 control->tabnext = strdupW( MSI_RecordGetString( rec, 11) );
1128 control->type = strdupW( MSI_RecordGetString( rec, 3 ) );
1129 control->progress_current = 0;
1130 control->progress_max = 100;
1132 x = MSI_RecordGetInteger( rec, 4 );
1133 y = MSI_RecordGetInteger( rec, 5 );
1134 width = MSI_RecordGetInteger( rec, 6 );
1136 x = msi_dialog_scale_unit( dialog, x );
1137 y = msi_dialog_scale_unit( dialog, y );
1138 width = msi_dialog_scale_unit( dialog, width );
1139 height = 2; /* line is exactly 2 units in height */
1141 control->hwnd = CreateWindowExW( exstyle, szStatic, NULL, style,
1142 x, y, width, height, dialog->hwnd, NULL, NULL, NULL );
1144 TRACE("Dialog %s control %s hwnd %p\n",
1145 debugstr_w(dialog->name), debugstr_w(name), control->hwnd );
1147 return ERROR_SUCCESS;
1150 /******************** Scroll Text ********************************************/
1152 struct msi_scrolltext_info
1155 msi_control *control;
1159 static LRESULT WINAPI
1160 MSIScrollText_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
1162 struct msi_scrolltext_info *info;
1165 TRACE("%p %04x %08lx %08lx\n", hWnd, msg, wParam, lParam);
1167 info = GetPropW( hWnd, szButtonData );
1169 r = CallWindowProcW( info->oldproc, hWnd, msg, wParam, lParam );
1174 return DLGC_WANTARROWS;
1177 RemovePropW( hWnd, szButtonData );
1180 /* native MSI sets a wait cursor here */
1181 msi_dialog_button_handler( info->dialog, info->control, BN_CLICKED );
1187 struct msi_streamin_info
1194 static DWORD CALLBACK
1195 msi_richedit_stream_in( DWORD_PTR arg, LPBYTE buffer, LONG count, LONG *pcb )
1197 struct msi_streamin_info *info = (struct msi_streamin_info*) arg;
1199 if( (count + info->offset) > info->length )
1200 count = info->length - info->offset;
1201 memcpy( buffer, &info->string[ info->offset ], count );
1203 info->offset += count;
1205 TRACE("%d/%d\n", info->offset, info->length);
1210 static void msi_scrolltext_add_text( msi_control *control, LPCWSTR text )
1212 struct msi_streamin_info info;
1215 info.string = strdupWtoA( text );
1217 info.length = lstrlenA( info.string ) + 1;
1219 es.dwCookie = (DWORD_PTR) &info;
1221 es.pfnCallback = msi_richedit_stream_in;
1223 SendMessageW( control->hwnd, EM_STREAMIN, SF_RTF, (LPARAM) &es );
1225 msi_free( info.string );
1228 static UINT msi_dialog_scrolltext_control( msi_dialog *dialog, MSIRECORD *rec )
1230 static const WCHAR szRichEdit20W[] = {
1231 'R','i','c','h','E','d','i','t','2','0','W',0
1233 struct msi_scrolltext_info *info;
1234 msi_control *control;
1239 info = msi_alloc( sizeof *info );
1241 return ERROR_FUNCTION_FAILED;
1243 hRichedit = LoadLibraryA("riched20");
1245 style = WS_BORDER | ES_MULTILINE | WS_VSCROLL |
1246 ES_READONLY | ES_AUTOVSCROLL | WS_TABSTOP;
1247 control = msi_dialog_add_control( dialog, rec, szRichEdit20W, style );
1250 FreeLibrary( hRichedit );
1252 return ERROR_FUNCTION_FAILED;
1255 control->hDll = hRichedit;
1257 info->dialog = dialog;
1258 info->control = control;
1260 /* subclass the static control */
1261 info->oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
1262 (LONG_PTR)MSIScrollText_WndProc );
1263 SetPropW( control->hwnd, szButtonData, info );
1265 /* add the text into the richedit */
1266 text = MSI_RecordGetString( rec, 10 );
1268 msi_scrolltext_add_text( control, text );
1270 return ERROR_SUCCESS;
1273 static HBITMAP msi_load_picture( MSIDATABASE *db, LPCWSTR name,
1274 INT cx, INT cy, DWORD flags )
1276 HBITMAP hOleBitmap = 0, hBitmap = 0, hOldSrcBitmap, hOldDestBitmap;
1277 MSIRECORD *rec = NULL;
1278 IStream *stm = NULL;
1279 IPicture *pic = NULL;
1284 rec = msi_get_binary_record( db, name );
1288 r = MSI_RecordGetIStream( rec, 2, &stm );
1289 msiobj_release( &rec->hdr );
1290 if( r != ERROR_SUCCESS )
1293 r = OleLoadPicture( stm, 0, TRUE, &IID_IPicture, (LPVOID*) &pic );
1294 IStream_Release( stm );
1297 ERR("failed to load picture\n");
1301 r = IPicture_get_Handle( pic, (OLE_HANDLE*) &hOleBitmap );
1304 ERR("failed to get bitmap handle\n");
1308 /* make the bitmap the desired size */
1309 r = GetObjectW( hOleBitmap, sizeof bm, &bm );
1310 if (r != sizeof bm )
1312 ERR("failed to get bitmap size\n");
1316 if (flags & LR_DEFAULTSIZE)
1322 srcdc = CreateCompatibleDC( NULL );
1323 hOldSrcBitmap = SelectObject( srcdc, hOleBitmap );
1324 destdc = CreateCompatibleDC( NULL );
1325 hBitmap = CreateCompatibleBitmap( srcdc, cx, cy );
1326 hOldDestBitmap = SelectObject( destdc, hBitmap );
1327 StretchBlt( destdc, 0, 0, cx, cy,
1328 srcdc, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
1329 SelectObject( srcdc, hOldSrcBitmap );
1330 SelectObject( destdc, hOldDestBitmap );
1336 IPicture_Release( pic );
1340 static UINT msi_dialog_bitmap_control( msi_dialog *dialog, MSIRECORD *rec )
1342 UINT cx, cy, flags, style, attributes;
1343 msi_control *control;
1346 flags = LR_LOADFROMFILE;
1347 style = SS_BITMAP | SS_LEFT | WS_GROUP;
1349 attributes = MSI_RecordGetInteger( rec, 8 );
1350 if( attributes & msidbControlAttributesFixedSize )
1352 flags |= LR_DEFAULTSIZE;
1353 style |= SS_CENTERIMAGE;
1356 control = msi_dialog_add_control( dialog, rec, szStatic, style );
1357 cx = MSI_RecordGetInteger( rec, 6 );
1358 cy = MSI_RecordGetInteger( rec, 7 );
1359 cx = msi_dialog_scale_unit( dialog, cx );
1360 cy = msi_dialog_scale_unit( dialog, cy );
1362 name = msi_get_binary_name( dialog->package, rec );
1363 control->hBitmap = msi_load_picture( dialog->package->db, name, cx, cy, flags );
1364 if( control->hBitmap )
1365 SendMessageW( control->hwnd, STM_SETIMAGE,
1366 IMAGE_BITMAP, (LPARAM) control->hBitmap );
1368 ERR("Failed to load bitmap %s\n", debugstr_w(name));
1372 return ERROR_SUCCESS;
1375 static UINT msi_dialog_icon_control( msi_dialog *dialog, MSIRECORD *rec )
1377 msi_control *control;
1383 control = msi_dialog_add_control( dialog, rec, szStatic,
1384 SS_ICON | SS_CENTERIMAGE | WS_GROUP );
1386 attributes = MSI_RecordGetInteger( rec, 8 );
1387 name = msi_get_binary_name( dialog->package, rec );
1388 control->hIcon = msi_load_icon( dialog->package->db, name, attributes );
1389 if( control->hIcon )
1390 SendMessageW( control->hwnd, STM_SETICON, (WPARAM) control->hIcon, 0 );
1392 ERR("Failed to load bitmap %s\n", debugstr_w(name));
1394 return ERROR_SUCCESS;
1397 /******************** Combo Box ***************************************/
1399 struct msi_combobox_info
1409 static LRESULT WINAPI MSIComboBox_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
1411 struct msi_combobox_info *info;
1415 TRACE("%p %04x %08lx %08lx\n", hWnd, msg, wParam, lParam);
1417 info = GetPropW( hWnd, szButtonData );
1421 r = CallWindowProcW( info->oldproc, hWnd, msg, wParam, lParam );
1426 for (j = 0; j < info->num_items; j++)
1427 msi_free( info->items[j] );
1428 msi_free( info->items );
1430 RemovePropW( hWnd, szButtonData );
1437 static UINT msi_combobox_add_item( MSIRECORD *rec, LPVOID param )
1439 struct msi_combobox_info *info = param;
1440 LPCWSTR value, text;
1443 value = MSI_RecordGetString( rec, 3 );
1444 text = MSI_RecordGetString( rec, 4 );
1446 info->items[info->addpos_items] = strdupW( value );
1448 pos = SendMessageW( info->hwnd, CB_ADDSTRING, 0, (LPARAM)text );
1449 SendMessageW( info->hwnd, CB_SETITEMDATA, pos, (LPARAM)info->items[info->addpos_items] );
1450 info->addpos_items++;
1452 return ERROR_SUCCESS;
1455 static UINT msi_combobox_add_items( struct msi_combobox_info *info, LPCWSTR property )
1458 MSIQUERY *view = NULL;
1461 static const WCHAR query[] = {
1462 'S','E','L','E','C','T',' ','*',' ',
1463 'F','R','O','M',' ','`','C','o','m','b','o','B','o','x','`',' ',
1464 'W','H','E','R','E',' ',
1465 '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',' ',
1466 'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','`',0
1469 r = MSI_OpenQuery( info->dialog->package->db, &view, query, property );
1470 if (r != ERROR_SUCCESS)
1473 /* just get the number of records */
1475 r = MSI_IterateRecords( view, &count, NULL, NULL );
1477 info->num_items = count;
1478 info->items = msi_alloc( sizeof(*info->items) * count );
1480 r = MSI_IterateRecords( view, NULL, msi_combobox_add_item, info );
1481 msiobj_release( &view->hdr );
1486 static UINT msi_dialog_set_control_condition( MSIRECORD *rec, LPVOID param )
1488 static const WCHAR szHide[] = {'H','i','d','e',0};
1489 static const WCHAR szShow[] = {'S','h','o','w',0};
1490 static const WCHAR szDisable[] = {'D','i','s','a','b','l','e',0};
1491 static const WCHAR szEnable[] = {'E','n','a','b','l','e',0};
1492 static const WCHAR szDefault[] = {'D','e','f','a','u','l','t',0};
1493 msi_dialog *dialog = param;
1494 msi_control *control;
1495 LPCWSTR name, action, condition;
1498 name = MSI_RecordGetString( rec, 2 );
1499 action = MSI_RecordGetString( rec, 3 );
1500 condition = MSI_RecordGetString( rec, 4 );
1501 r = MSI_EvaluateConditionW( dialog->package, condition );
1502 control = msi_dialog_find_control( dialog, name );
1503 if (r == MSICONDITION_TRUE && control)
1505 TRACE("%s control %s\n", debugstr_w(action), debugstr_w(name));
1507 /* FIXME: case sensitive? */
1508 if (!strcmpW( action, szHide ))
1509 ShowWindow(control->hwnd, SW_HIDE);
1510 else if (!strcmpW( action, szShow ))
1511 ShowWindow(control->hwnd, SW_SHOW);
1512 else if (!strcmpW( action, szDisable ))
1513 EnableWindow(control->hwnd, FALSE);
1514 else if (!strcmpW( action, szEnable ))
1515 EnableWindow(control->hwnd, TRUE);
1516 else if (!strcmpW( action, szDefault ))
1517 SetFocus(control->hwnd);
1519 FIXME("Unhandled action %s\n", debugstr_w(action));
1521 return ERROR_SUCCESS;
1524 static UINT msi_dialog_evaluate_control_conditions( msi_dialog *dialog )
1526 static const WCHAR query[] = {
1527 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1528 'C','o','n','t','r','o','l','C','o','n','d','i','t','i','o','n',' ',
1529 'W','H','E','R','E',' ','`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0};
1531 MSIQUERY *view = NULL;
1532 MSIPACKAGE *package = dialog->package;
1534 TRACE("%p %s\n", dialog, debugstr_w(dialog->name));
1536 /* query the Control table for all the elements of the control */
1537 r = MSI_OpenQuery( package->db, &view, query, dialog->name );
1538 if (r != ERROR_SUCCESS)
1539 return ERROR_SUCCESS;
1541 r = MSI_IterateRecords( view, 0, msi_dialog_set_control_condition, dialog );
1542 msiobj_release( &view->hdr );
1546 static UINT msi_dialog_combobox_handler( msi_dialog *dialog, msi_control *control, WPARAM param )
1548 struct msi_combobox_info *info;
1552 if (HIWORD(param) != CBN_SELCHANGE && HIWORD(param) != CBN_EDITCHANGE)
1553 return ERROR_SUCCESS;
1555 info = GetPropW( control->hwnd, szButtonData );
1556 index = SendMessageW( control->hwnd, CB_GETCURSEL, 0, 0 );
1557 if (index == CB_ERR)
1558 value = msi_get_window_text( control->hwnd );
1560 value = (LPWSTR) SendMessageW( control->hwnd, CB_GETITEMDATA, index, 0 );
1562 msi_dialog_set_property( info->dialog->package, control->property, value );
1563 msi_dialog_evaluate_control_conditions( info->dialog );
1565 if (index == CB_ERR)
1568 return ERROR_SUCCESS;
1571 static void msi_dialog_combobox_update( msi_dialog *dialog, msi_control *control )
1573 struct msi_combobox_info *info;
1577 info = GetPropW( control->hwnd, szButtonData );
1579 value = msi_dup_property( dialog->package->db, control->property );
1582 SendMessageW( control->hwnd, CB_SETCURSEL, -1, 0 );
1586 for (j = 0; j < info->num_items; j++)
1588 tmp = (LPWSTR) SendMessageW( control->hwnd, CB_GETITEMDATA, j, 0 );
1589 if (!strcmpW( value, tmp ))
1593 if (j < info->num_items)
1595 SendMessageW( control->hwnd, CB_SETCURSEL, j, 0 );
1599 SendMessageW( control->hwnd, CB_SETCURSEL, -1, 0 );
1600 SetWindowTextW( control->hwnd, value );
1606 static UINT msi_dialog_combo_control( msi_dialog *dialog, MSIRECORD *rec )
1608 struct msi_combobox_info *info;
1609 msi_control *control;
1610 DWORD attributes, style;
1613 info = msi_alloc( sizeof *info );
1615 return ERROR_FUNCTION_FAILED;
1617 style = CBS_AUTOHSCROLL | WS_TABSTOP | WS_GROUP | WS_CHILD;
1618 attributes = MSI_RecordGetInteger( rec, 8 );
1619 if ( ~attributes & msidbControlAttributesSorted)
1621 if ( attributes & msidbControlAttributesComboList)
1622 style |= CBS_DROPDOWNLIST;
1624 style |= CBS_DROPDOWN;
1626 control = msi_dialog_add_control( dialog, rec, WC_COMBOBOXW, style );
1630 return ERROR_FUNCTION_FAILED;
1633 control->handler = msi_dialog_combobox_handler;
1634 control->update = msi_dialog_combobox_update;
1636 prop = MSI_RecordGetString( rec, 9 );
1637 control->property = msi_dialog_dup_property( dialog, prop, FALSE );
1640 info->dialog = dialog;
1641 info->hwnd = control->hwnd;
1643 info->addpos_items = 0;
1644 info->oldproc = (WNDPROC)SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
1645 (LONG_PTR)MSIComboBox_WndProc );
1646 SetPropW( control->hwnd, szButtonData, info );
1648 if (control->property)
1649 msi_combobox_add_items( info, control->property );
1651 msi_dialog_combobox_update( dialog, control );
1653 return ERROR_SUCCESS;
1656 static UINT msi_dialog_edit_handler( msi_dialog *dialog, msi_control *control, WPARAM param )
1660 if (HIWORD(param) != EN_CHANGE)
1661 return ERROR_SUCCESS;
1663 TRACE("edit %s contents changed, set %s\n", debugstr_w(control->name), debugstr_w(control->property));
1665 buf = msi_get_window_text( control->hwnd );
1666 msi_dialog_set_property( dialog->package, control->property, buf );
1669 return ERROR_SUCCESS;
1672 /* length of 2^32 + 1 */
1673 #define MAX_NUM_DIGITS 11
1675 static UINT msi_dialog_edit_control( msi_dialog *dialog, MSIRECORD *rec )
1677 msi_control *control;
1679 LPWSTR val, begin, end;
1680 WCHAR num[MAX_NUM_DIGITS];
1683 control = msi_dialog_add_control( dialog, rec, szEdit,
1684 WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL );
1685 control->handler = msi_dialog_edit_handler;
1687 text = MSI_RecordGetString( rec, 10 );
1690 begin = strchrW( text, '{' );
1691 end = strchrW( text, '}' );
1693 if ( begin && end && end > begin &&
1694 begin[0] >= '0' && begin[0] <= '9' &&
1695 end - begin < MAX_NUM_DIGITS)
1697 lstrcpynW( num, begin + 1, end - begin );
1698 limit = atolW( num );
1700 SendMessageW( control->hwnd, EM_SETLIMITTEXT, limit, 0 );
1704 prop = MSI_RecordGetString( rec, 9 );
1706 control->property = strdupW( prop );
1708 val = msi_dup_property( dialog->package->db, control->property );
1709 SetWindowTextW( control->hwnd, val );
1711 return ERROR_SUCCESS;
1714 /******************** Masked Edit ********************************************/
1716 #define MASK_MAX_GROUPS 20
1718 struct msi_mask_group
1726 struct msi_maskedit_info
1734 struct msi_mask_group group[MASK_MAX_GROUPS];
1737 static BOOL msi_mask_editable( WCHAR type )
1752 static void msi_mask_control_change( struct msi_maskedit_info *info )
1757 val = msi_alloc( (info->num_chars+1)*sizeof(WCHAR) );
1758 for( i=0, n=0; i<info->num_groups; i++ )
1760 if( (info->group[i].len + n) > info->num_chars )
1762 ERR("can't fit control %d text into template\n",i);
1765 if (!msi_mask_editable(info->group[i].type))
1767 for(r=0; r<info->group[i].len; r++)
1768 val[n+r] = info->group[i].type;
1773 r = GetWindowTextW( info->group[i].hwnd, &val[n], info->group[i].len+1 );
1774 if( r != info->group[i].len )
1780 TRACE("%d/%d controls were good\n", i, info->num_groups);
1782 if( i == info->num_groups )
1784 TRACE("Set property %s to %s\n", debugstr_w(info->prop), debugstr_w(val));
1785 CharUpperBuffW( val, info->num_chars );
1786 msi_dialog_set_property( info->dialog->package, info->prop, val );
1787 msi_dialog_evaluate_control_conditions( info->dialog );
1792 /* now move to the next control if necessary */
1793 static VOID msi_mask_next_control( struct msi_maskedit_info *info, HWND hWnd )
1798 for( i=0; i<info->num_groups; i++ )
1799 if( info->group[i].hwnd == hWnd )
1802 /* don't move from the last control */
1803 if( i >= (info->num_groups-1) )
1806 len = SendMessageW( hWnd, WM_GETTEXTLENGTH, 0, 0 );
1807 if( len < info->group[i].len )
1810 hWndNext = GetNextDlgTabItem( GetParent( hWnd ), hWnd, FALSE );
1811 SetFocus( hWndNext );
1814 static LRESULT WINAPI
1815 MSIMaskedEdit_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
1817 struct msi_maskedit_info *info;
1820 TRACE("%p %04x %08lx %08lx\n", hWnd, msg, wParam, lParam);
1822 info = GetPropW(hWnd, szButtonData);
1824 r = CallWindowProcW(info->oldproc, hWnd, msg, wParam, lParam);
1829 if (HIWORD(wParam) == EN_CHANGE)
1831 msi_mask_control_change( info );
1832 msi_mask_next_control( info, (HWND) lParam );
1836 msi_free( info->prop );
1838 RemovePropW( hWnd, szButtonData );
1845 /* fish the various bits of the property out and put them in the control */
1847 msi_maskedit_set_text( struct msi_maskedit_info *info, LPCWSTR text )
1853 for( i = 0; i < info->num_groups; i++ )
1855 if( info->group[i].len < strlenW( p ) )
1857 LPWSTR chunk = strdupW( p );
1858 chunk[ info->group[i].len ] = 0;
1859 SetWindowTextW( info->group[i].hwnd, chunk );
1864 SetWindowTextW( info->group[i].hwnd, p );
1867 p += info->group[i].len;
1871 static struct msi_maskedit_info * msi_dialog_parse_groups( LPCWSTR mask )
1873 struct msi_maskedit_info * info = NULL;
1874 int i = 0, n = 0, total = 0;
1877 TRACE("masked control, template %s\n", debugstr_w(mask));
1882 info = msi_alloc_zero( sizeof *info );
1886 p = strchrW(mask, '<');
1892 for( i=0; i<MASK_MAX_GROUPS; i++ )
1894 /* stop at the end of the string */
1895 if( p[0] == 0 || p[0] == '>' )
1898 /* count the number of the same identifier */
1899 for( n=0; p[n] == p[0]; n++ )
1901 info->group[i].ofs = total;
1902 info->group[i].type = p[0];
1906 total++; /* an extra not part of the group */
1908 info->group[i].len = n;
1913 TRACE("%d characters in %d groups\n", total, i );
1914 if( i == MASK_MAX_GROUPS )
1915 ERR("too many groups in PIDTemplate %s\n", debugstr_w(mask));
1917 info->num_chars = total;
1918 info->num_groups = i;
1924 msi_maskedit_create_children( struct msi_maskedit_info *info, LPCWSTR font )
1926 DWORD width, height, style, wx, ww;
1931 style = WS_CHILD | WS_BORDER | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL;
1933 GetClientRect( info->hwnd, &rect );
1935 width = rect.right - rect.left;
1936 height = rect.bottom - rect.top;
1938 for( i = 0; i < info->num_groups; i++ )
1940 if (!msi_mask_editable( info->group[i].type ))
1942 wx = (info->group[i].ofs * width) / info->num_chars;
1943 ww = (info->group[i].len * width) / info->num_chars;
1945 hwnd = CreateWindowW( szEdit, NULL, style, wx, 0, ww, height,
1946 info->hwnd, NULL, NULL, NULL );
1949 ERR("failed to create mask edit sub window\n");
1953 SendMessageW( hwnd, EM_LIMITTEXT, info->group[i].len, 0 );
1955 msi_dialog_set_font( info->dialog, hwnd,
1956 font?font:info->dialog->default_font );
1957 info->group[i].hwnd = hwnd;
1962 * office 2003 uses "73931<````=````=````=````=`````>@@@@@"
1963 * delphi 7 uses "<????-??????-??????-????>" and "<???-???>"
1964 * filemaker pro 7 uses "<^^^^=^^^^=^^^^=^^^^=^^^^=^^^^=^^^^^>"
1966 static UINT msi_dialog_maskedit_control( msi_dialog *dialog, MSIRECORD *rec )
1968 LPWSTR font_mask, val = NULL, font;
1969 struct msi_maskedit_info *info = NULL;
1970 UINT ret = ERROR_SUCCESS;
1971 msi_control *control;
1976 font_mask = msi_get_deformatted_field( dialog->package, rec, 10 );
1977 font = msi_dialog_get_style( font_mask, &mask );
1980 WARN("mask template is empty\n");
1984 info = msi_dialog_parse_groups( mask );
1987 ERR("template %s is invalid\n", debugstr_w(mask));
1991 info->dialog = dialog;
1993 control = msi_dialog_add_control( dialog, rec, szStatic,
1994 SS_OWNERDRAW | WS_GROUP | WS_VISIBLE );
1997 ERR("Failed to create maskedit container\n");
1998 ret = ERROR_FUNCTION_FAILED;
2001 SetWindowLongPtrW( control->hwnd, GWL_EXSTYLE, WS_EX_CONTROLPARENT );
2003 info->hwnd = control->hwnd;
2005 /* subclass the static control */
2006 info->oldproc = (WNDPROC) SetWindowLongPtrW( info->hwnd, GWLP_WNDPROC,
2007 (LONG_PTR)MSIMaskedEdit_WndProc );
2008 SetPropW( control->hwnd, szButtonData, info );
2010 prop = MSI_RecordGetString( rec, 9 );
2012 info->prop = strdupW( prop );
2014 msi_maskedit_create_children( info, font );
2018 val = msi_dup_property( dialog->package->db, prop );
2021 msi_maskedit_set_text( info, val );
2027 if( ret != ERROR_SUCCESS )
2029 msi_free( font_mask );
2034 /******************** Progress Bar *****************************************/
2036 static UINT msi_dialog_progress_bar( msi_dialog *dialog, MSIRECORD *rec )
2038 msi_control *control;
2039 DWORD attributes, style;
2042 attributes = MSI_RecordGetInteger( rec, 8 );
2043 if( !(attributes & msidbControlAttributesProgress95) )
2044 style |= PBS_SMOOTH;
2046 control = msi_dialog_add_control( dialog, rec, PROGRESS_CLASSW, style );
2048 return ERROR_FUNCTION_FAILED;
2050 ControlEvent_SubscribeToEvent( dialog->package, dialog,
2051 szSetProgress, control->name, szProgress );
2052 return ERROR_SUCCESS;
2055 /******************** Path Edit ********************************************/
2057 struct msi_pathedit_info
2060 msi_control *control;
2064 static void msi_dialog_update_pathedit( msi_dialog *dialog, msi_control *control )
2069 if (!control && !(control = msi_dialog_find_control_by_type( dialog, szPathEdit )))
2072 indirect = control->attributes & msidbControlAttributesIndirect;
2073 prop = msi_dialog_dup_property( dialog, control->property, indirect );
2074 path = msi_dialog_dup_property( dialog, prop, TRUE );
2076 SetWindowTextW( control->hwnd, path );
2077 SendMessageW( control->hwnd, EM_SETSEL, 0, -1 );
2083 /* FIXME: test when this should fail */
2084 static BOOL msi_dialog_verify_path( LPWSTR path )
2086 if ( !lstrlenW( path ) )
2089 if ( PathIsRelativeW( path ) )
2095 /* returns TRUE if the path is valid, FALSE otherwise */
2096 static BOOL msi_dialog_onkillfocus( msi_dialog *dialog, msi_control *control )
2102 indirect = control->attributes & msidbControlAttributesIndirect;
2103 prop = msi_dialog_dup_property( dialog, control->property, indirect );
2105 buf = msi_get_window_text( control->hwnd );
2107 if ( !msi_dialog_verify_path( buf ) )
2109 /* FIXME: display an error message box */
2110 ERR("Invalid path %s\n", debugstr_w( buf ));
2112 SetFocus( control->hwnd );
2117 msi_dialog_set_property( dialog->package, prop, buf );
2120 msi_dialog_update_pathedit( dialog, control );
2122 TRACE("edit %s contents changed, set %s\n", debugstr_w(control->name),
2131 static LRESULT WINAPI MSIPathEdit_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
2133 struct msi_pathedit_info *info = GetPropW(hWnd, szButtonData);
2136 TRACE("%p %04x %08lx %08lx\n", hWnd, msg, wParam, lParam);
2138 if ( msg == WM_KILLFOCUS )
2140 /* if the path is invalid, don't handle this message */
2141 if ( !msi_dialog_onkillfocus( info->dialog, info->control ) )
2145 r = CallWindowProcW(info->oldproc, hWnd, msg, wParam, lParam);
2147 if ( msg == WM_NCDESTROY )
2150 RemovePropW( hWnd, szButtonData );
2156 static UINT msi_dialog_pathedit_control( msi_dialog *dialog, MSIRECORD *rec )
2158 struct msi_pathedit_info *info;
2159 msi_control *control;
2162 info = msi_alloc( sizeof *info );
2164 return ERROR_FUNCTION_FAILED;
2166 control = msi_dialog_add_control( dialog, rec, szEdit,
2167 WS_BORDER | WS_TABSTOP );
2168 control->attributes = MSI_RecordGetInteger( rec, 8 );
2169 prop = MSI_RecordGetString( rec, 9 );
2170 control->property = msi_dialog_dup_property( dialog, prop, FALSE );
2172 info->dialog = dialog;
2173 info->control = control;
2174 info->oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
2175 (LONG_PTR)MSIPathEdit_WndProc );
2176 SetPropW( control->hwnd, szButtonData, info );
2178 msi_dialog_update_pathedit( dialog, control );
2180 return ERROR_SUCCESS;
2183 static UINT msi_dialog_radiogroup_handler( msi_dialog *dialog, msi_control *control, WPARAM param )
2185 if (HIWORD(param) != BN_CLICKED)
2186 return ERROR_SUCCESS;
2188 TRACE("clicked radio button %s, set %s\n", debugstr_w(control->name), debugstr_w(control->property));
2190 msi_dialog_set_property( dialog->package, control->property, control->name );
2192 return msi_dialog_button_handler( dialog, control, param );
2195 /* radio buttons are a bit different from normal controls */
2196 static UINT msi_dialog_create_radiobutton( MSIRECORD *rec, LPVOID param )
2198 radio_button_group_descr *group = param;
2199 msi_dialog *dialog = group->dialog;
2200 msi_control *control;
2201 LPCWSTR prop, text, name;
2202 DWORD style, attributes = group->attributes;
2204 style = WS_CHILD | BS_AUTORADIOBUTTON | BS_MULTILINE | WS_TABSTOP;
2205 name = MSI_RecordGetString( rec, 3 );
2206 text = MSI_RecordGetString( rec, 8 );
2207 if( attributes & msidbControlAttributesVisible )
2208 style |= WS_VISIBLE;
2209 if( ~attributes & msidbControlAttributesEnabled )
2210 style |= WS_DISABLED;
2212 control = msi_dialog_create_window( dialog, rec, 0, szButton, name, text,
2213 style, group->parent->hwnd );
2215 return ERROR_FUNCTION_FAILED;
2216 control->handler = msi_dialog_radiogroup_handler;
2218 if (group->propval && !strcmpW( control->name, group->propval ))
2219 SendMessageW(control->hwnd, BM_SETCHECK, BST_CHECKED, 0);
2221 prop = MSI_RecordGetString( rec, 1 );
2223 control->property = strdupW( prop );
2225 return ERROR_SUCCESS;
2228 static BOOL CALLBACK msi_radioground_child_enum( HWND hWnd, LPARAM lParam )
2230 EnableWindow( hWnd, lParam );
2234 static LRESULT WINAPI MSIRadioGroup_WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
2236 WNDPROC oldproc = (WNDPROC)GetPropW( hWnd, szButtonData );
2239 TRACE("hWnd %p msg %04x wParam 0x%08lx lParam 0x%08lx\n", hWnd, msg, wParam, lParam);
2241 if (msg == WM_COMMAND) /* Forward notifications to dialog */
2242 SendMessageW( GetParent( hWnd ), msg, wParam, lParam );
2244 r = CallWindowProcW( oldproc, hWnd, msg, wParam, lParam );
2246 /* make sure the radio buttons show as disabled if the parent is disabled */
2247 if (msg == WM_ENABLE)
2248 EnumChildWindows( hWnd, msi_radioground_child_enum, wParam );
2253 static UINT msi_dialog_radiogroup_control( msi_dialog *dialog, MSIRECORD *rec )
2255 static const WCHAR query[] = {
2256 'S','E','L','E','C','T',' ','*',' ',
2257 'F','R','O','M',' ','R','a','d','i','o','B','u','t','t','o','n',' ',
2258 'W','H','E','R','E',' ',
2259 '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
2262 msi_control *control;
2263 MSIQUERY *view = NULL;
2264 radio_button_group_descr group;
2265 MSIPACKAGE *package = dialog->package;
2267 DWORD attr, style = WS_GROUP;
2269 prop = MSI_RecordGetString( rec, 9 );
2271 TRACE("%p %p %s\n", dialog, rec, debugstr_w( prop ));
2273 attr = MSI_RecordGetInteger( rec, 8 );
2274 if (attr & msidbControlAttributesHasBorder)
2275 style |= BS_GROUPBOX;
2277 style |= BS_OWNERDRAW;
2279 /* Create parent group box to hold radio buttons */
2280 control = msi_dialog_add_control( dialog, rec, szButton, style );
2282 return ERROR_FUNCTION_FAILED;
2284 oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
2285 (LONG_PTR)MSIRadioGroup_WndProc );
2286 SetPropW(control->hwnd, szButtonData, oldproc);
2287 SetWindowLongPtrW( control->hwnd, GWL_EXSTYLE, WS_EX_CONTROLPARENT );
2290 control->property = strdupW( prop );
2292 /* query the Radio Button table for all control in this group */
2293 r = MSI_OpenQuery( package->db, &view, query, prop );
2294 if( r != ERROR_SUCCESS )
2296 ERR("query failed for dialog %s radio group %s\n",
2297 debugstr_w(dialog->name), debugstr_w(prop));
2298 return ERROR_INVALID_PARAMETER;
2301 group.dialog = dialog;
2302 group.parent = control;
2303 group.attributes = MSI_RecordGetInteger( rec, 8 );
2304 group.propval = msi_dup_property( dialog->package->db, control->property );
2306 r = MSI_IterateRecords( view, 0, msi_dialog_create_radiobutton, &group );
2307 msiobj_release( &view->hdr );
2308 msi_free( group.propval );
2314 msi_seltree_sync_item_state( HWND hwnd, MSIFEATURE *feature, HTREEITEM hItem )
2317 DWORD index = feature->ActionRequest;
2319 TRACE("Feature %s -> %d %d %d\n", debugstr_w(feature->Title),
2320 feature->Installed, feature->Action, feature->ActionRequest);
2322 if (index == INSTALLSTATE_UNKNOWN)
2323 index = INSTALLSTATE_ABSENT;
2325 tvi.mask = TVIF_STATE;
2327 tvi.state = INDEXTOSTATEIMAGEMASK( index );
2328 tvi.stateMask = TVIS_STATEIMAGEMASK;
2330 SendMessageW( hwnd, TVM_SETITEMW, 0, (LPARAM) &tvi );
2334 msi_seltree_popup_menu( HWND hwnd, INT x, INT y )
2339 /* create a menu to display */
2340 hMenu = CreatePopupMenu();
2342 /* FIXME: load strings from resources */
2343 AppendMenuA( hMenu, MF_ENABLED, INSTALLSTATE_LOCAL, "Install feature locally");
2344 AppendMenuA( hMenu, MF_ENABLED, USER_INSTALLSTATE_ALL, "Install entire feature");
2345 AppendMenuA( hMenu, MF_ENABLED, INSTALLSTATE_ADVERTISED, "Install on demand");
2346 AppendMenuA( hMenu, MF_ENABLED, INSTALLSTATE_ABSENT, "Don't install");
2347 r = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD,
2348 x, y, 0, hwnd, NULL );
2349 DestroyMenu( hMenu );
2354 msi_seltree_update_feature_installstate( HWND hwnd, HTREEITEM hItem,
2355 MSIPACKAGE *package, MSIFEATURE *feature, INSTALLSTATE state )
2357 feature->ActionRequest = state;
2358 msi_seltree_sync_item_state( hwnd, feature, hItem );
2359 ACTION_UpdateComponentStates( package, feature );
2363 msi_seltree_update_siblings_and_children_installstate( HWND hwnd, HTREEITEM curr,
2364 MSIPACKAGE *package, INSTALLSTATE state)
2366 /* update all siblings */
2369 MSIFEATURE *feature;
2372 feature = msi_seltree_feature_from_item( hwnd, curr );
2373 msi_seltree_update_feature_installstate( hwnd, curr, package, feature, state );
2375 /* update this sibling's children */
2376 child = (HTREEITEM)SendMessageW( hwnd, TVM_GETNEXTITEM, (WPARAM)TVGN_CHILD, (LPARAM)curr );
2378 msi_seltree_update_siblings_and_children_installstate( hwnd, child,
2381 while ((curr = (HTREEITEM)SendMessageW( hwnd, TVM_GETNEXTITEM, (WPARAM)TVGN_NEXT, (LPARAM)curr )));
2385 msi_seltree_menu( HWND hwnd, HTREEITEM hItem )
2387 struct msi_selection_tree_info *info;
2388 MSIFEATURE *feature;
2389 MSIPACKAGE *package;
2397 info = GetPropW(hwnd, szButtonData);
2398 package = info->dialog->package;
2400 feature = msi_seltree_feature_from_item( hwnd, hItem );
2403 ERR("item %p feature was NULL\n", hItem);
2407 /* get the item's rectangle to put the menu just below it */
2409 SendMessageW( hwnd, TVM_GETITEMRECT, 0, (LPARAM) &u.rc );
2410 MapWindowPoints( hwnd, NULL, u.pt, 2 );
2412 r = msi_seltree_popup_menu( hwnd, u.rc.left, u.rc.top );
2416 case USER_INSTALLSTATE_ALL:
2417 r = INSTALLSTATE_LOCAL;
2419 case INSTALLSTATE_ADVERTISED:
2420 case INSTALLSTATE_ABSENT:
2423 child = (HTREEITEM)SendMessageW( hwnd, TVM_GETNEXTITEM, (WPARAM)TVGN_CHILD, (LPARAM)hItem );
2425 msi_seltree_update_siblings_and_children_installstate( hwnd, child, package, r );
2428 case INSTALLSTATE_LOCAL:
2429 msi_seltree_update_feature_installstate( hwnd, hItem, package, feature, r );
2436 static LRESULT WINAPI
2437 MSISelectionTree_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
2439 struct msi_selection_tree_info *info;
2440 TVHITTESTINFO tvhti;
2443 TRACE("%p %04x %08lx %08lx\n", hWnd, msg, wParam, lParam);
2445 info = GetPropW(hWnd, szButtonData);
2449 case WM_LBUTTONDOWN:
2450 tvhti.pt.x = (short)LOWORD( lParam );
2451 tvhti.pt.y = (short)HIWORD( lParam );
2454 r = CallWindowProcW(info->oldproc, hWnd, TVM_HITTEST, 0, (LPARAM) &tvhti );
2455 if (tvhti.flags & TVHT_ONITEMSTATEICON)
2456 return msi_seltree_menu( hWnd, tvhti.hItem );
2460 r = CallWindowProcW(info->oldproc, hWnd, msg, wParam, lParam);
2466 RemovePropW( hWnd, szButtonData );
2473 msi_seltree_add_child_features( MSIPACKAGE *package, HWND hwnd,
2474 LPCWSTR parent, HTREEITEM hParent )
2476 struct msi_selection_tree_info *info = GetPropW( hwnd, szButtonData );
2477 MSIFEATURE *feature;
2478 TVINSERTSTRUCTW tvis;
2479 HTREEITEM hitem, hfirst = NULL;
2481 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
2483 if ( parent && feature->Feature_Parent && strcmpW( parent, feature->Feature_Parent ))
2485 else if ( parent && !feature->Feature_Parent )
2487 else if ( !parent && feature->Feature_Parent )
2490 if ( !feature->Title )
2493 if ( !feature->Display )
2496 memset( &tvis, 0, sizeof tvis );
2497 tvis.hParent = hParent;
2498 tvis.hInsertAfter = TVI_LAST;
2499 tvis.u.item.mask = TVIF_TEXT | TVIF_PARAM;
2500 tvis.u.item.pszText = feature->Title;
2501 tvis.u.item.lParam = (LPARAM) feature;
2503 hitem = (HTREEITEM) SendMessageW( hwnd, TVM_INSERTITEMW, 0, (LPARAM) &tvis );
2510 msi_seltree_sync_item_state( hwnd, feature, hitem );
2511 msi_seltree_add_child_features( package, hwnd,
2512 feature->Feature, hitem );
2514 /* the node is expanded if Display is odd */
2515 if ( feature->Display % 2 != 0 )
2516 SendMessageW( hwnd, TVM_EXPAND, TVE_EXPAND, (LPARAM) hitem );
2519 /* select the first item */
2520 SendMessageW( hwnd, TVM_SELECTITEM, TVGN_CARET | TVGN_DROPHILITE, (LPARAM) hfirst );
2521 info->selected = hfirst;
2524 static void msi_seltree_create_imagelist( HWND hwnd )
2526 const int bm_width = 32, bm_height = 16, bm_count = 3;
2527 const int bm_resource = 0x1001;
2532 himl = ImageList_Create( bm_width, bm_height, FALSE, 4, 0 );
2535 ERR("failed to create image list\n");
2539 for (i=0; i<bm_count; i++)
2541 hbmp = LoadBitmapW( msi_hInstance, MAKEINTRESOURCEW(i+bm_resource) );
2544 ERR("failed to load bitmap %d\n", i);
2549 * Add a dummy bitmap at offset zero because the treeview
2550 * can't use it as a state mask (zero means no user state).
2553 ImageList_Add( himl, hbmp, NULL );
2555 ImageList_Add( himl, hbmp, NULL );
2558 SendMessageW( hwnd, TVM_SETIMAGELIST, TVSIL_STATE, (LPARAM)himl );
2561 static UINT msi_dialog_seltree_handler( msi_dialog *dialog,
2562 msi_control *control, WPARAM param )
2564 struct msi_selection_tree_info *info = GetPropW( control->hwnd, szButtonData );
2565 LPNMTREEVIEWW tv = (LPNMTREEVIEWW)param;
2566 MSIRECORD *row, *rec;
2568 MSIFEATURE *feature;
2569 LPCWSTR dir, title = NULL;
2570 UINT r = ERROR_SUCCESS;
2572 static const WCHAR select[] = {
2573 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2574 '`','F','e','a','t','u','r','e','`',' ','W','H','E','R','E',' ',
2575 '`','T','i','t','l','e','`',' ','=',' ','\'','%','s','\'',0
2578 if (tv->hdr.code != TVN_SELCHANGINGW)
2579 return ERROR_SUCCESS;
2581 info->selected = tv->itemNew.hItem;
2583 if (!(tv->itemNew.mask & TVIF_TEXT))
2585 feature = msi_seltree_feature_from_item( control->hwnd, tv->itemNew.hItem );
2587 title = feature->Title;
2590 title = tv->itemNew.pszText;
2592 row = MSI_QueryGetRecord( dialog->package->db, select, title );
2594 return ERROR_FUNCTION_FAILED;
2596 rec = MSI_CreateRecord( 1 );
2598 MSI_RecordSetStringW( rec, 1, MSI_RecordGetString( row, 4 ) );
2599 ControlEvent_FireSubscribedEvent( dialog->package, szSelectionDescription, rec );
2601 dir = MSI_RecordGetString( row, 7 );
2604 folder = msi_get_loaded_folder( dialog->package, dir );
2607 r = ERROR_FUNCTION_FAILED;
2610 MSI_RecordSetStringW( rec, 1, folder->ResolvedTarget );
2613 MSI_RecordSetStringW( rec, 1, NULL );
2615 ControlEvent_FireSubscribedEvent( dialog->package, szSelectionPath, rec );
2618 msiobj_release(&row->hdr);
2619 msiobj_release(&rec->hdr);
2624 static UINT msi_dialog_selection_tree( msi_dialog *dialog, MSIRECORD *rec )
2626 msi_control *control;
2627 LPCWSTR prop, control_name;
2628 MSIPACKAGE *package = dialog->package;
2630 struct msi_selection_tree_info *info;
2632 info = msi_alloc( sizeof *info );
2634 return ERROR_FUNCTION_FAILED;
2636 /* create the treeview control */
2637 style = TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT;
2638 style |= WS_GROUP | WS_VSCROLL;
2639 control = msi_dialog_add_control( dialog, rec, WC_TREEVIEWW, style );
2643 return ERROR_FUNCTION_FAILED;
2646 control->handler = msi_dialog_seltree_handler;
2647 control_name = MSI_RecordGetString( rec, 2 );
2648 control->attributes = MSI_RecordGetInteger( rec, 8 );
2649 prop = MSI_RecordGetString( rec, 9 );
2650 control->property = msi_dialog_dup_property( dialog, prop, FALSE );
2653 info->dialog = dialog;
2654 info->hwnd = control->hwnd;
2655 info->oldproc = (WNDPROC) SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
2656 (LONG_PTR)MSISelectionTree_WndProc );
2657 SetPropW( control->hwnd, szButtonData, info );
2659 ControlEvent_SubscribeToEvent( dialog->package, dialog,
2660 szSelectionPath, control_name, szProperty );
2663 msi_seltree_create_imagelist( control->hwnd );
2664 msi_seltree_add_child_features( package, control->hwnd, NULL, NULL );
2666 return ERROR_SUCCESS;
2669 /******************** Group Box ***************************************/
2671 static UINT msi_dialog_group_box( msi_dialog *dialog, MSIRECORD *rec )
2673 msi_control *control;
2676 style = BS_GROUPBOX | WS_CHILD | WS_GROUP;
2677 control = msi_dialog_add_control( dialog, rec, WC_BUTTONW, style );
2679 return ERROR_FUNCTION_FAILED;
2681 return ERROR_SUCCESS;
2684 /******************** List Box ***************************************/
2686 struct msi_listbox_info
2696 static LRESULT WINAPI MSIListBox_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
2698 struct msi_listbox_info *info;
2702 TRACE("%p %04x %08lx %08lx\n", hWnd, msg, wParam, lParam);
2704 info = GetPropW( hWnd, szButtonData );
2708 r = CallWindowProcW( info->oldproc, hWnd, msg, wParam, lParam );
2713 for (j = 0; j < info->num_items; j++)
2714 msi_free( info->items[j] );
2715 msi_free( info->items );
2717 RemovePropW( hWnd, szButtonData );
2724 static UINT msi_listbox_add_item( MSIRECORD *rec, LPVOID param )
2726 struct msi_listbox_info *info = param;
2727 LPCWSTR value, text;
2730 value = MSI_RecordGetString( rec, 3 );
2731 text = MSI_RecordGetString( rec, 4 );
2733 info->items[info->addpos_items] = strdupW( value );
2735 pos = SendMessageW( info->hwnd, LB_ADDSTRING, 0, (LPARAM)text );
2736 SendMessageW( info->hwnd, LB_SETITEMDATA, pos, (LPARAM)info->items[info->addpos_items] );
2737 info->addpos_items++;
2738 return ERROR_SUCCESS;
2741 static UINT msi_listbox_add_items( struct msi_listbox_info *info, LPCWSTR property )
2744 MSIQUERY *view = NULL;
2747 static const WCHAR query[] = {
2748 'S','E','L','E','C','T',' ','*',' ',
2749 'F','R','O','M',' ','`','L','i','s','t','B','o','x','`',' ',
2750 'W','H','E','R','E',' ',
2751 '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',' ',
2752 'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','`',0
2755 r = MSI_OpenQuery( info->dialog->package->db, &view, query, property );
2756 if ( r != ERROR_SUCCESS )
2759 /* just get the number of records */
2761 r = MSI_IterateRecords( view, &count, NULL, NULL );
2763 info->num_items = count;
2764 info->items = msi_alloc( sizeof(*info->items) * count );
2766 r = MSI_IterateRecords( view, NULL, msi_listbox_add_item, info );
2767 msiobj_release( &view->hdr );
2772 static UINT msi_dialog_listbox_handler( msi_dialog *dialog,
2773 msi_control *control, WPARAM param )
2775 struct msi_listbox_info *info;
2779 if( HIWORD(param) != LBN_SELCHANGE )
2780 return ERROR_SUCCESS;
2782 info = GetPropW( control->hwnd, szButtonData );
2783 index = SendMessageW( control->hwnd, LB_GETCURSEL, 0, 0 );
2784 value = (LPCWSTR) SendMessageW( control->hwnd, LB_GETITEMDATA, index, 0 );
2786 msi_dialog_set_property( info->dialog->package, control->property, value );
2787 msi_dialog_evaluate_control_conditions( info->dialog );
2789 return ERROR_SUCCESS;
2792 static UINT msi_dialog_list_box( msi_dialog *dialog, MSIRECORD *rec )
2794 struct msi_listbox_info *info;
2795 msi_control *control;
2796 DWORD attributes, style;
2799 info = msi_alloc( sizeof *info );
2801 return ERROR_FUNCTION_FAILED;
2803 style = WS_TABSTOP | WS_GROUP | WS_CHILD | LBS_NOTIFY | WS_VSCROLL | WS_BORDER;
2804 attributes = MSI_RecordGetInteger( rec, 8 );
2805 if (~attributes & msidbControlAttributesSorted)
2808 control = msi_dialog_add_control( dialog, rec, WC_LISTBOXW, style );
2812 return ERROR_FUNCTION_FAILED;
2815 control->handler = msi_dialog_listbox_handler;
2817 prop = MSI_RecordGetString( rec, 9 );
2818 control->property = msi_dialog_dup_property( dialog, prop, FALSE );
2821 info->dialog = dialog;
2822 info->hwnd = control->hwnd;
2824 info->addpos_items = 0;
2825 info->oldproc = (WNDPROC)SetWindowLongPtrW( control->hwnd, GWLP_WNDPROC,
2826 (LONG_PTR)MSIListBox_WndProc );
2827 SetPropW( control->hwnd, szButtonData, info );
2829 if ( control->property )
2830 msi_listbox_add_items( info, control->property );
2832 return ERROR_SUCCESS;
2835 /******************** Directory Combo ***************************************/
2837 static void msi_dialog_update_directory_combo( msi_dialog *dialog, msi_control *control )
2842 if (!control && !(control = msi_dialog_find_control_by_type( dialog, szDirectoryCombo )))
2845 indirect = control->attributes & msidbControlAttributesIndirect;
2846 prop = msi_dialog_dup_property( dialog, control->property, indirect );
2847 path = msi_dialog_dup_property( dialog, prop, TRUE );
2849 PathStripPathW( path );
2850 PathRemoveBackslashW( path );
2852 SendMessageW( control->hwnd, CB_INSERTSTRING, 0, (LPARAM)path );
2853 SendMessageW( control->hwnd, CB_SETCURSEL, 0, 0 );
2859 static UINT msi_dialog_directory_combo( msi_dialog *dialog, MSIRECORD *rec )
2861 msi_control *control;
2865 /* FIXME: use CBS_OWNERDRAWFIXED and add owner draw code */
2866 style = CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD |
2867 WS_GROUP | WS_TABSTOP | WS_VSCROLL;
2868 control = msi_dialog_add_control( dialog, rec, WC_COMBOBOXW, style );
2870 return ERROR_FUNCTION_FAILED;
2872 control->attributes = MSI_RecordGetInteger( rec, 8 );
2873 prop = MSI_RecordGetString( rec, 9 );
2874 control->property = msi_dialog_dup_property( dialog, prop, FALSE );
2876 msi_dialog_update_directory_combo( dialog, control );
2878 return ERROR_SUCCESS;
2881 /******************** Directory List ***************************************/
2883 static void msi_dialog_update_directory_list( msi_dialog *dialog, msi_control *control )
2885 WCHAR dir_spec[MAX_PATH];
2886 WIN32_FIND_DATAW wfd;
2892 static const WCHAR asterisk[] = {'*',0};
2894 if (!control && !(control = msi_dialog_find_control_by_type( dialog, szDirectoryList )))
2897 /* clear the list-view */
2898 SendMessageW( control->hwnd, LVM_DELETEALLITEMS, 0, 0 );
2900 indirect = control->attributes & msidbControlAttributesIndirect;
2901 prop = msi_dialog_dup_property( dialog, control->property, indirect );
2902 path = msi_dialog_dup_property( dialog, prop, TRUE );
2904 lstrcpyW( dir_spec, path );
2905 lstrcatW( dir_spec, asterisk );
2907 file = FindFirstFileW( dir_spec, &wfd );
2908 if ( file == INVALID_HANDLE_VALUE )
2913 if ( wfd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY )
2916 if ( !strcmpW( wfd.cFileName, szDot ) || !strcmpW( wfd.cFileName, szDotDot ) )
2919 item.mask = LVIF_TEXT;
2920 item.cchTextMax = MAX_PATH;
2923 item.pszText = wfd.cFileName;
2925 SendMessageW( control->hwnd, LVM_INSERTITEMW, 0, (LPARAM)&item );
2926 } while ( FindNextFileW( file, &wfd ) );
2933 UINT msi_dialog_directorylist_up( msi_dialog *dialog )
2935 msi_control *control;
2936 LPWSTR prop, path, ptr;
2939 control = msi_dialog_find_control_by_type( dialog, szDirectoryList );
2940 indirect = control->attributes & msidbControlAttributesIndirect;
2941 prop = msi_dialog_dup_property( dialog, control->property, indirect );
2942 path = msi_dialog_dup_property( dialog, prop, TRUE );
2944 /* strip off the last directory */
2945 ptr = PathFindFileNameW( path );
2946 if (ptr != path) *(ptr - 1) = '\0';
2947 PathAddBackslashW( path );
2949 msi_dialog_set_property( dialog->package, prop, path );
2951 msi_dialog_update_directory_list( dialog, NULL );
2952 msi_dialog_update_directory_combo( dialog, NULL );
2953 msi_dialog_update_pathedit( dialog, NULL );
2958 return ERROR_SUCCESS;
2961 static UINT msi_dialog_dirlist_handler( msi_dialog *dialog,
2962 msi_control *control, WPARAM param )
2964 LPNMHDR nmhdr = (LPNMHDR)param;
2965 WCHAR new_path[MAX_PATH];
2966 WCHAR text[MAX_PATH];
2972 if (nmhdr->code != LVN_ITEMACTIVATE)
2973 return ERROR_SUCCESS;
2975 index = SendMessageW( control->hwnd, LVM_GETNEXTITEM, -1, LVNI_SELECTED );
2978 ERR("No list-view item selected!\n");
2979 return ERROR_FUNCTION_FAILED;
2983 item.pszText = text;
2984 item.cchTextMax = MAX_PATH;
2985 SendMessageW( control->hwnd, LVM_GETITEMTEXTW, index, (LPARAM)&item );
2987 indirect = control->attributes & msidbControlAttributesIndirect;
2988 prop = msi_dialog_dup_property( dialog, control->property, indirect );
2989 path = msi_dialog_dup_property( dialog, prop, TRUE );
2991 lstrcpyW( new_path, path );
2992 lstrcatW( new_path, text );
2993 lstrcatW( new_path, szBackSlash );
2995 msi_dialog_set_property( dialog->package, prop, new_path );
2997 msi_dialog_update_directory_list( dialog, NULL );
2998 msi_dialog_update_directory_combo( dialog, NULL );
2999 msi_dialog_update_pathedit( dialog, NULL );
3003 return ERROR_SUCCESS;
3006 static UINT msi_dialog_directory_list( msi_dialog *dialog, MSIRECORD *rec )
3008 msi_control *control;
3012 style = LVS_LIST | WS_VSCROLL | LVS_SHAREIMAGELISTS |
3013 LVS_AUTOARRANGE | LVS_SINGLESEL | WS_BORDER |
3014 LVS_SORTASCENDING | WS_CHILD | WS_GROUP | WS_TABSTOP;
3015 control = msi_dialog_add_control( dialog, rec, WC_LISTVIEWW, style );
3017 return ERROR_FUNCTION_FAILED;
3019 control->attributes = MSI_RecordGetInteger( rec, 8 );
3020 control->handler = msi_dialog_dirlist_handler;
3021 prop = MSI_RecordGetString( rec, 9 );
3022 control->property = msi_dialog_dup_property( dialog, prop, FALSE );
3024 /* double click to activate an item in the list */
3025 SendMessageW( control->hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE,
3026 0, LVS_EX_TWOCLICKACTIVATE );
3028 msi_dialog_update_directory_list( dialog, control );
3030 return ERROR_SUCCESS;
3033 /******************** VolumeCost List ***************************************/
3035 static BOOL str_is_number( LPCWSTR str )
3039 for (i = 0; i < lstrlenW( str ); i++)
3040 if (!isdigitW(str[i]))
3046 static const WCHAR column_keys[][80] =
3048 {'V','o','l','u','m','e','C','o','s','t','V','o','l','u','m','e',0},
3049 {'V','o','l','u','m','e','C','o','s','t','S','i','z','e',0},
3050 {'V','o','l','u','m','e','C','o','s','t','A','v','a','i','l','a','b','l','e',0},
3051 {'V','o','l','u','m','e','C','o','s','t','R','e','q','u','i','r','e','d',0},
3052 {'V','o','l','u','m','e','C','o','s','t','D','i','f','f','e','r','e','n','c','e',0}
3055 static void msi_dialog_vcl_add_columns( msi_dialog *dialog, msi_control *control, MSIRECORD *rec )
3057 LPCWSTR text = MSI_RecordGetString( rec, 10 );
3058 LPCWSTR begin = text, end;
3063 static const WCHAR negative[] = {'-',0};
3067 while ((begin = strchrW( begin, '{' )) && count < 5)
3069 if (!(end = strchrW( begin, '}' )))
3072 num = msi_alloc( (end-begin+1)*sizeof(WCHAR) );
3076 lstrcpynW( num, begin + 1, end - begin );
3077 begin += end - begin + 1;
3079 /* empty braces or '0' hides the column */
3080 if ( !num[0] || !strcmpW( num, szZero ) )
3087 /* the width must be a positive number
3088 * if a width is invalid, all remaining columns are hidden
3090 if ( !strncmpW( num, negative, 1 ) || !str_is_number( num ) ) {
3095 ZeroMemory( &lvc, sizeof(lvc) );
3096 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
3097 lvc.cx = atolW( num );
3098 lvc.pszText = msi_dialog_get_uitext( dialog, column_keys[count] );
3100 SendMessageW( control->hwnd, LVM_INSERTCOLUMNW, count++, (LPARAM)&lvc );
3101 msi_free( lvc.pszText );
3106 static LONGLONG msi_vcl_get_cost( msi_dialog *dialog )
3108 MSIFEATURE *feature;
3110 LONGLONG total_cost = 0;
3112 LIST_FOR_EACH_ENTRY( feature, &dialog->package->features, MSIFEATURE, entry )
3114 if (ERROR_SUCCESS == (MSI_GetFeatureCost(dialog->package, feature,
3115 MSICOSTTREE_SELFONLY, INSTALLSTATE_LOCAL, &each_cost)))
3117 /* each_cost is in 512-byte units */
3118 total_cost += each_cost * 512;
3120 if (ERROR_SUCCESS == (MSI_GetFeatureCost(dialog->package, feature,
3121 MSICOSTTREE_SELFONLY, INSTALLSTATE_ABSENT, &each_cost)))
3123 /* each_cost is in 512-byte units */
3124 total_cost -= each_cost * 512;
3130 static void msi_dialog_vcl_add_drives( msi_dialog *dialog, msi_control *control )
3132 ULARGE_INTEGER total, free;
3133 LONGLONG difference, cost;
3134 WCHAR size_text[MAX_PATH];
3135 WCHAR cost_text[MAX_PATH];
3141 cost = msi_vcl_get_cost(dialog);
3142 StrFormatByteSizeW(cost, cost_text, MAX_PATH);
3144 size = GetLogicalDriveStringsW( 0, NULL );
3145 if ( !size ) return;
3147 drives = msi_alloc( (size + 1) * sizeof(WCHAR) );
3148 if ( !drives ) return;
3150 GetLogicalDriveStringsW( size, drives );
3155 lvitem.mask = LVIF_TEXT;
3157 lvitem.iSubItem = 0;
3158 lvitem.pszText = ptr;
3159 lvitem.cchTextMax = lstrlenW(ptr) + 1;
3160 SendMessageW( control->hwnd, LVM_INSERTITEMW, 0, (LPARAM)&lvitem );
3162 GetDiskFreeSpaceExW(ptr, &free, &total, NULL);
3163 difference = free.QuadPart - cost;
3165 StrFormatByteSizeW(total.QuadPart, size_text, MAX_PATH);
3166 lvitem.iSubItem = 1;
3167 lvitem.pszText = size_text;
3168 lvitem.cchTextMax = lstrlenW(size_text) + 1;
3169 SendMessageW( control->hwnd, LVM_SETITEMW, 0, (LPARAM)&lvitem );
3171 StrFormatByteSizeW(free.QuadPart, size_text, MAX_PATH);
3172 lvitem.iSubItem = 2;
3173 lvitem.pszText = size_text;
3174 lvitem.cchTextMax = lstrlenW(size_text) + 1;
3175 SendMessageW( control->hwnd, LVM_SETITEMW, 0, (LPARAM)&lvitem );
3177 lvitem.iSubItem = 3;
3178 lvitem.pszText = cost_text;
3179 lvitem.cchTextMax = lstrlenW(cost_text) + 1;
3180 SendMessageW( control->hwnd, LVM_SETITEMW, 0, (LPARAM)&lvitem );
3182 StrFormatByteSizeW(difference, size_text, MAX_PATH);
3183 lvitem.iSubItem = 4;
3184 lvitem.pszText = size_text;
3185 lvitem.cchTextMax = lstrlenW(size_text) + 1;
3186 SendMessageW( control->hwnd, LVM_SETITEMW, 0, (LPARAM)&lvitem );
3188 ptr += lstrlenW(ptr) + 1;
3195 static UINT msi_dialog_volumecost_list( msi_dialog *dialog, MSIRECORD *rec )
3197 msi_control *control;
3200 style = LVS_REPORT | WS_VSCROLL | WS_HSCROLL | LVS_SHAREIMAGELISTS |
3201 LVS_AUTOARRANGE | LVS_SINGLESEL | WS_BORDER |
3202 WS_CHILD | WS_TABSTOP | WS_GROUP;
3203 control = msi_dialog_add_control( dialog, rec, WC_LISTVIEWW, style );
3205 return ERROR_FUNCTION_FAILED;
3207 msi_dialog_vcl_add_columns( dialog, control, rec );
3208 msi_dialog_vcl_add_drives( dialog, control );
3210 return ERROR_SUCCESS;
3213 /******************** VolumeSelect Combo ***************************************/
3215 static UINT msi_dialog_volsel_handler( msi_dialog *dialog,
3216 msi_control *control, WPARAM param )
3218 WCHAR text[MAX_PATH];
3223 if (HIWORD(param) != CBN_SELCHANGE)
3224 return ERROR_SUCCESS;
3226 index = SendMessageW( control->hwnd, CB_GETCURSEL, 0, 0 );
3227 if ( index == CB_ERR )
3229 ERR("No ComboBox item selected!\n");
3230 return ERROR_FUNCTION_FAILED;
3233 SendMessageW( control->hwnd, CB_GETLBTEXT, index, (LPARAM)text );
3235 indirect = control->attributes & msidbControlAttributesIndirect;
3236 prop = msi_dialog_dup_property( dialog, control->property, indirect );
3238 msi_dialog_set_property( dialog->package, prop, text );
3241 return ERROR_SUCCESS;
3244 static void msi_dialog_vsc_add_drives( msi_dialog *dialog, msi_control *control )
3249 size = GetLogicalDriveStringsW( 0, NULL );
3250 if ( !size ) return;
3252 drives = msi_alloc( (size + 1) * sizeof(WCHAR) );
3253 if ( !drives ) return;
3255 GetLogicalDriveStringsW( size, drives );
3260 SendMessageW( control->hwnd, CB_ADDSTRING, 0, (LPARAM)ptr );
3261 ptr += lstrlenW(ptr) + 1;
3267 static UINT msi_dialog_volumeselect_combo( msi_dialog *dialog, MSIRECORD *rec )
3269 msi_control *control;
3273 /* FIXME: CBS_OWNERDRAWFIXED */
3274 style = WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP |
3275 CBS_DROPDOWNLIST | CBS_SORT | CBS_HASSTRINGS |
3276 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR;
3277 control = msi_dialog_add_control( dialog, rec, WC_COMBOBOXW, style );
3279 return ERROR_FUNCTION_FAILED;
3281 control->attributes = MSI_RecordGetInteger( rec, 8 );
3282 control->handler = msi_dialog_volsel_handler;
3283 prop = MSI_RecordGetString( rec, 9 );
3284 control->property = msi_dialog_dup_property( dialog, prop, FALSE );
3286 msi_dialog_vsc_add_drives( dialog, control );
3288 return ERROR_SUCCESS;
3291 static const struct control_handler msi_dialog_handler[] =
3293 { szText, msi_dialog_text_control },
3294 { szPushButton, msi_dialog_button_control },
3295 { szLine, msi_dialog_line_control },
3296 { szBitmap, msi_dialog_bitmap_control },
3297 { szCheckBox, msi_dialog_checkbox_control },
3298 { szScrollableText, msi_dialog_scrolltext_control },
3299 { szComboBox, msi_dialog_combo_control },
3300 { szEdit, msi_dialog_edit_control },
3301 { szMaskedEdit, msi_dialog_maskedit_control },
3302 { szPathEdit, msi_dialog_pathedit_control },
3303 { szProgressBar, msi_dialog_progress_bar },
3304 { szRadioButtonGroup, msi_dialog_radiogroup_control },
3305 { szIcon, msi_dialog_icon_control },
3306 { szSelectionTree, msi_dialog_selection_tree },
3307 { szGroupBox, msi_dialog_group_box },
3308 { szListBox, msi_dialog_list_box },
3309 { szDirectoryCombo, msi_dialog_directory_combo },
3310 { szDirectoryList, msi_dialog_directory_list },
3311 { szVolumeCostList, msi_dialog_volumecost_list },
3312 { szVolumeSelectCombo, msi_dialog_volumeselect_combo },
3315 #define NUM_CONTROL_TYPES (sizeof msi_dialog_handler/sizeof msi_dialog_handler[0])
3317 static UINT msi_dialog_create_controls( MSIRECORD *rec, LPVOID param )
3319 msi_dialog *dialog = param;
3320 LPCWSTR control_type;
3323 /* find and call the function that can create this type of control */
3324 control_type = MSI_RecordGetString( rec, 3 );
3325 for( i=0; i<NUM_CONTROL_TYPES; i++ )
3326 if (!strcmpiW( msi_dialog_handler[i].control_type, control_type ))
3328 if( i != NUM_CONTROL_TYPES )
3329 msi_dialog_handler[i].func( dialog, rec );
3331 ERR("no handler for element type %s\n", debugstr_w(control_type));
3333 return ERROR_SUCCESS;
3336 static UINT msi_dialog_fill_controls( msi_dialog *dialog )
3338 static const WCHAR query[] = {
3339 'S','E','L','E','C','T',' ','*',' ',
3340 'F','R','O','M',' ','C','o','n','t','r','o','l',' ',
3341 'W','H','E','R','E',' ',
3342 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0};
3344 MSIQUERY *view = NULL;
3345 MSIPACKAGE *package = dialog->package;
3347 TRACE("%p %s\n", dialog, debugstr_w(dialog->name) );
3349 /* query the Control table for all the elements of the control */
3350 r = MSI_OpenQuery( package->db, &view, query, dialog->name );
3351 if( r != ERROR_SUCCESS )
3353 ERR("query failed for dialog %s\n", debugstr_w(dialog->name));
3354 return ERROR_INVALID_PARAMETER;
3357 r = MSI_IterateRecords( view, 0, msi_dialog_create_controls, dialog );
3358 msiobj_release( &view->hdr );
3363 UINT msi_dialog_reset( msi_dialog *dialog )
3365 /* FIXME: should restore the original values of any properties we changed */
3366 return msi_dialog_evaluate_control_conditions( dialog );
3369 /* figure out the height of 10 point MS Sans Serif */
3370 static INT msi_dialog_get_sans_serif_height( HWND hwnd )
3372 static const WCHAR szSansSerif[] = {
3373 'M','S',' ','S','a','n','s',' ','S','e','r','i','f',0 };
3378 HFONT hFont, hOldFont;
3381 hdc = GetDC( hwnd );
3384 memset( &lf, 0, sizeof lf );
3385 lf.lfHeight = MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72);
3386 strcpyW( lf.lfFaceName, szSansSerif );
3387 hFont = CreateFontIndirectW(&lf);
3390 hOldFont = SelectObject( hdc, hFont );
3391 r = GetTextMetricsW( hdc, &tm );
3393 height = tm.tmHeight;
3394 SelectObject( hdc, hOldFont );
3395 DeleteObject( hFont );
3397 ReleaseDC( hwnd, hdc );
3402 /* fetch the associated record from the Dialog table */
3403 static MSIRECORD *msi_get_dialog_record( msi_dialog *dialog )
3405 static const WCHAR query[] = {
3406 'S','E','L','E','C','T',' ','*',' ',
3407 'F','R','O','M',' ','D','i','a','l','o','g',' ',
3408 'W','H','E','R','E',' ',
3409 '`','D','i','a','l','o','g','`',' ','=',' ','\'','%','s','\'',0};
3410 MSIPACKAGE *package = dialog->package;
3411 MSIRECORD *rec = NULL;
3413 TRACE("%p %s\n", dialog, debugstr_w(dialog->name) );
3415 rec = MSI_QueryGetRecord( package->db, query, dialog->name );
3417 WARN("query failed for dialog %s\n", debugstr_w(dialog->name));
3422 static void msi_dialog_adjust_dialog_pos( msi_dialog *dialog, MSIRECORD *rec, LPRECT pos )
3424 static const WCHAR szScreenX[] = {'S','c','r','e','e','n','X',0};
3425 static const WCHAR szScreenY[] = {'S','c','r','e','e','n','Y',0};
3432 center.x = MSI_RecordGetInteger( rec, 2 );
3433 center.y = MSI_RecordGetInteger( rec, 3 );
3435 sz.cx = MSI_RecordGetInteger( rec, 4 );
3436 sz.cy = MSI_RecordGetInteger( rec, 5 );
3438 sz.cx = msi_dialog_scale_unit( dialog, sz.cx );
3439 sz.cy = msi_dialog_scale_unit( dialog, sz.cy );
3441 xres = msi_get_property_int( dialog->package->db, szScreenX, 0 );
3442 yres = msi_get_property_int( dialog->package->db, szScreenY, 0 );
3444 center.x = MulDiv( center.x, xres, 100 );
3445 center.y = MulDiv( center.y, yres, 100 );
3447 /* turn the client pos into the window rectangle */
3448 if (dialog->package->center_x && dialog->package->center_y)
3450 pos->left = dialog->package->center_x - sz.cx / 2.0;
3451 pos->right = pos->left + sz.cx;
3452 pos->top = dialog->package->center_y - sz.cy / 2.0;
3453 pos->bottom = pos->top + sz.cy;
3457 pos->left = center.x - sz.cx/2;
3458 pos->right = pos->left + sz.cx;
3459 pos->top = center.y - sz.cy/2;
3460 pos->bottom = pos->top + sz.cy;
3462 /* save the center */
3463 dialog->package->center_x = center.x;
3464 dialog->package->center_y = center.y;
3467 dialog->size.cx = sz.cx;
3468 dialog->size.cy = sz.cy;
3470 TRACE("%u %u %u %u\n", pos->left, pos->top, pos->right, pos->bottom);
3472 style = GetWindowLongPtrW( dialog->hwnd, GWL_STYLE );
3473 AdjustWindowRect( pos, style, FALSE );
3476 static void msi_dialog_set_tab_order( msi_dialog *dialog, LPCWSTR first )
3478 struct list tab_chain;
3479 msi_control *control;
3480 HWND prev = HWND_TOP;
3482 list_init( &tab_chain );
3483 if (!(control = msi_dialog_find_control( dialog, first ))) return;
3485 dialog->hWndFocus = control->hwnd;
3488 list_remove( &control->entry );
3489 list_add_tail( &tab_chain, &control->entry );
3490 if (!control->tabnext) break;
3491 control = msi_dialog_find_control( dialog, control->tabnext );
3494 LIST_FOR_EACH_ENTRY( control, &tab_chain, msi_control, entry )
3496 SetWindowPos( control->hwnd, prev, 0, 0, 0, 0,
3497 SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW |
3498 SWP_NOREPOSITION | SWP_NOSENDCHANGING | SWP_NOSIZE );
3499 prev = control->hwnd;
3502 /* put them back on the main list */
3503 list_move_head( &dialog->controls, &tab_chain );
3506 static LRESULT msi_dialog_oncreate( HWND hwnd, LPCREATESTRUCTW cs )
3508 static const WCHAR df[] = {
3509 'D','e','f','a','u','l','t','U','I','F','o','n','t',0 };
3510 static const WCHAR dfv[] = {
3511 'M','S',' ','S','h','e','l','l',' ','D','l','g',0 };
3512 msi_dialog *dialog = cs->lpCreateParams;
3513 MSIRECORD *rec = NULL;
3514 LPWSTR title = NULL;
3517 TRACE("%p %p\n", dialog, dialog->package);
3519 dialog->hwnd = hwnd;
3520 SetWindowLongPtrW( hwnd, GWLP_USERDATA, (LONG_PTR) dialog );
3522 rec = msi_get_dialog_record( dialog );
3525 TRACE("No record found for dialog %s\n", debugstr_w(dialog->name));
3529 dialog->scale = msi_dialog_get_sans_serif_height(dialog->hwnd);
3531 msi_dialog_adjust_dialog_pos( dialog, rec, &pos );
3533 dialog->attributes = MSI_RecordGetInteger( rec, 6 );
3535 dialog->default_font = msi_dup_property( dialog->package->db, df );
3536 if (!dialog->default_font)
3538 dialog->default_font = strdupW(dfv);
3539 if (!dialog->default_font) return -1;
3542 title = msi_get_deformatted_field( dialog->package, rec, 7 );
3543 SetWindowTextW( hwnd, title );
3546 SetWindowPos( hwnd, 0, pos.left, pos.top,
3547 pos.right - pos.left, pos.bottom - pos.top,
3548 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW );
3550 msi_dialog_build_font_list( dialog );
3551 msi_dialog_fill_controls( dialog );
3552 msi_dialog_evaluate_control_conditions( dialog );
3553 msi_dialog_set_tab_order( dialog, MSI_RecordGetString( rec, 8 ) );
3554 msiobj_release( &rec->hdr );
3559 static LRESULT msi_dialog_oncommand( msi_dialog *dialog, WPARAM param, HWND hwnd )
3561 msi_control *control = NULL;
3563 TRACE("%p %p %08lx\n", dialog, hwnd, param);
3568 control = msi_dialog_find_control( dialog, dialog->control_default );
3570 case 2: /* escape */
3571 control = msi_dialog_find_control( dialog, dialog->control_cancel );
3574 control = msi_dialog_find_control_by_hwnd( dialog, hwnd );
3579 if( control->handler )
3581 control->handler( dialog, control, param );
3582 msi_dialog_evaluate_control_conditions( dialog );
3589 static LRESULT msi_dialog_onnotify( msi_dialog *dialog, LPARAM param )
3591 LPNMHDR nmhdr = (LPNMHDR) param;
3592 msi_control *control = msi_dialog_find_control_by_hwnd( dialog, nmhdr->hwndFrom );
3594 TRACE("%p %p\n", dialog, nmhdr->hwndFrom);
3596 if ( control && control->handler )
3597 control->handler( dialog, control, param );
3602 static void msi_dialog_setfocus( msi_dialog *dialog )
3604 HWND hwnd = dialog->hWndFocus;
3606 hwnd = GetNextDlgTabItem( dialog->hwnd, hwnd, TRUE);
3607 hwnd = GetNextDlgTabItem( dialog->hwnd, hwnd, FALSE);
3609 dialog->hWndFocus = hwnd;
3612 static LRESULT WINAPI MSIDialog_WndProc( HWND hwnd, UINT msg,
3613 WPARAM wParam, LPARAM lParam )
3615 msi_dialog *dialog = (LPVOID) GetWindowLongPtrW( hwnd, GWLP_USERDATA );
3617 TRACE("0x%04x\n", msg);
3622 dialog->package->center_x = LOWORD(lParam) + dialog->size.cx / 2.0;
3623 dialog->package->center_y = HIWORD(lParam) + dialog->size.cy / 2.0;
3627 return msi_dialog_oncreate( hwnd, (LPCREATESTRUCTW)lParam );
3630 return msi_dialog_oncommand( dialog, wParam, (HWND)lParam );
3633 if( LOWORD(wParam) == WA_INACTIVE )
3634 dialog->hWndFocus = GetFocus();
3636 msi_dialog_setfocus( dialog );
3640 msi_dialog_setfocus( dialog );
3643 /* bounce back to our subclassed static control */
3644 case WM_CTLCOLORSTATIC:
3645 return SendMessageW( (HWND) lParam, WM_CTLCOLORSTATIC, wParam, lParam );
3648 dialog->hwnd = NULL;
3651 return msi_dialog_onnotify( dialog, lParam );
3653 return DefWindowProcW(hwnd, msg, wParam, lParam);
3656 static LRESULT WINAPI MSIHiddenWindowProc( HWND hwnd, UINT msg,
3657 WPARAM wParam, LPARAM lParam )
3659 msi_dialog *dialog = (msi_dialog*) lParam;
3661 TRACE("%d %p\n", msg, dialog);
3665 case WM_MSI_DIALOG_CREATE:
3666 return msi_dialog_run_message_loop( dialog );
3667 case WM_MSI_DIALOG_DESTROY:
3668 msi_dialog_destroy( dialog );
3671 return DefWindowProcW( hwnd, msg, wParam, lParam );
3674 static BOOL msi_dialog_register_class( void )
3678 ZeroMemory( &cls, sizeof cls );
3679 cls.lpfnWndProc = MSIDialog_WndProc;
3680 cls.hInstance = NULL;
3681 cls.hIcon = LoadIconW(0, (LPWSTR)IDI_APPLICATION);
3682 cls.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
3683 cls.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
3684 cls.lpszMenuName = NULL;
3685 cls.lpszClassName = szMsiDialogClass;
3687 if( !RegisterClassW( &cls ) )
3690 cls.lpfnWndProc = MSIHiddenWindowProc;
3691 cls.lpszClassName = szMsiHiddenWindow;
3693 if( !RegisterClassW( &cls ) )
3696 uiThreadId = GetCurrentThreadId();
3698 hMsiHiddenWindow = CreateWindowW( szMsiHiddenWindow, NULL, WS_OVERLAPPED,
3699 0, 0, 100, 100, NULL, NULL, NULL, NULL );
3700 if( !hMsiHiddenWindow )
3706 /* functions that interface to other modules within MSI */
3708 msi_dialog *msi_dialog_create( MSIPACKAGE* package,
3709 LPCWSTR szDialogName, msi_dialog *parent,
3710 msi_dialog_event_handler event_handler )
3712 MSIRECORD *rec = NULL;
3715 TRACE("%p %s\n", package, debugstr_w(szDialogName));
3717 if (!hMsiHiddenWindow)
3718 msi_dialog_register_class();
3720 /* allocate the structure for the dialog to use */
3721 dialog = msi_alloc_zero( sizeof *dialog + sizeof(WCHAR)*strlenW(szDialogName) );
3724 strcpyW( dialog->name, szDialogName );
3725 dialog->parent = parent;
3726 msiobj_addref( &package->hdr );
3727 dialog->package = package;
3728 dialog->event_handler = event_handler;
3729 dialog->finished = 0;
3730 list_init( &dialog->controls );
3731 list_init( &dialog->fonts );
3733 /* verify that the dialog exists */
3734 rec = msi_get_dialog_record( dialog );
3737 msiobj_release( &package->hdr );
3741 dialog->attributes = MSI_RecordGetInteger( rec, 6 );
3742 dialog->control_default = strdupW( MSI_RecordGetString( rec, 9 ) );
3743 dialog->control_cancel = strdupW( MSI_RecordGetString( rec, 10 ) );
3744 msiobj_release( &rec->hdr );
3749 static void msi_process_pending_messages( HWND hdlg )
3753 while( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ) )
3755 if( hdlg && IsDialogMessageW( hdlg, &msg ))
3757 TranslateMessage( &msg );
3758 DispatchMessageW( &msg );
3762 void msi_dialog_end_dialog( msi_dialog *dialog )
3764 TRACE("%p\n", dialog);
3765 dialog->finished = 1;
3766 PostMessageW(dialog->hwnd, WM_NULL, 0, 0);
3769 void msi_dialog_check_messages( HANDLE handle )
3773 /* in threads other than the UI thread, block */
3774 if( uiThreadId != GetCurrentThreadId() )
3777 WaitForSingleObject( handle, INFINITE );
3781 /* there's two choices for the UI thread */
3784 msi_process_pending_messages( NULL );
3790 * block here until somebody creates a new dialog or
3791 * the handle we're waiting on becomes ready
3793 r = MsgWaitForMultipleObjects( 1, &handle, 0, INFINITE, QS_ALLINPUT );
3794 if( r == WAIT_OBJECT_0 )
3799 UINT msi_dialog_run_message_loop( msi_dialog *dialog )
3804 if( uiThreadId != GetCurrentThreadId() )
3805 return SendMessageW( hMsiHiddenWindow, WM_MSI_DIALOG_CREATE, 0, (LPARAM) dialog );
3807 /* create the dialog window, don't show it yet */
3808 style = WS_OVERLAPPED;
3809 if( dialog->attributes & msidbDialogAttributesVisible )
3810 style |= WS_VISIBLE;
3812 hwnd = CreateWindowW( szMsiDialogClass, dialog->name, style,
3813 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
3814 NULL, NULL, NULL, dialog );
3817 ERR("Failed to create dialog %s\n", debugstr_w( dialog->name ));
3818 return ERROR_FUNCTION_FAILED;
3821 ShowWindow( hwnd, SW_SHOW );
3822 /* UpdateWindow( hwnd ); - and causes the transparent static controls not to paint */
3824 if( dialog->attributes & msidbDialogAttributesModal )
3826 while( !dialog->finished )
3828 MsgWaitForMultipleObjects( 0, NULL, 0, INFINITE, QS_ALLINPUT );
3829 msi_process_pending_messages( dialog->hwnd );
3833 return ERROR_IO_PENDING;
3835 return ERROR_SUCCESS;
3838 void msi_dialog_do_preview( msi_dialog *dialog )
3841 dialog->attributes |= msidbDialogAttributesVisible;
3842 dialog->attributes &= ~msidbDialogAttributesModal;
3843 msi_dialog_run_message_loop( dialog );
3846 void msi_dialog_destroy( msi_dialog *dialog )
3848 msi_font *font, *next;
3850 if( uiThreadId != GetCurrentThreadId() )
3852 SendMessageW( hMsiHiddenWindow, WM_MSI_DIALOG_DESTROY, 0, (LPARAM) dialog );
3857 ShowWindow( dialog->hwnd, SW_HIDE );
3860 DestroyWindow( dialog->hwnd );
3862 /* unsubscribe events */
3863 ControlEvent_CleanupDialogSubscriptions(dialog->package, dialog->name);
3865 /* destroy the list of controls */
3866 while( !list_empty( &dialog->controls ) )
3870 t = LIST_ENTRY( list_head( &dialog->controls ),
3871 msi_control, entry );
3872 msi_destroy_control( t );
3875 /* destroy the list of fonts */
3876 LIST_FOR_EACH_ENTRY_SAFE( font, next, &dialog->fonts, msi_font, entry )
3878 list_remove( &font->entry );
3879 DeleteObject( font->hfont );
3882 msi_free( dialog->default_font );
3884 msi_free( dialog->control_default );
3885 msi_free( dialog->control_cancel );
3886 msiobj_release( &dialog->package->hdr );
3887 dialog->package = NULL;
3891 void msi_dialog_unregister_class( void )
3893 DestroyWindow( hMsiHiddenWindow );
3894 hMsiHiddenWindow = NULL;
3895 UnregisterClassW( szMsiDialogClass, NULL );
3896 UnregisterClassW( szMsiHiddenWindow, NULL );
3900 static UINT error_dialog_handler(MSIPACKAGE *package, LPCWSTR event,
3901 LPCWSTR argument, msi_dialog* dialog)
3903 static const WCHAR end_dialog[] = {'E','n','d','D','i','a','l','o','g',0};
3904 static const WCHAR error_abort[] = {'E','r','r','o','r','A','b','o','r','t',0};
3905 static const WCHAR error_cancel[] = {'E','r','r','o','r','C','a','n','c','e','l',0};
3906 static const WCHAR error_no[] = {'E','r','r','o','r','N','o',0};
3907 static const WCHAR result_prop[] = {
3908 'M','S','I','E','r','r','o','r','D','i','a','l','o','g','R','e','s','u','l','t',0
3911 if ( strcmpW( event, end_dialog ) )
3912 return ERROR_SUCCESS;
3914 if ( !strcmpW( argument, error_abort ) || !strcmpW( argument, error_cancel ) ||
3915 !strcmpW( argument, error_no ) )
3917 msi_set_property( package->db, result_prop, error_abort );
3920 ControlEvent_CleanupSubscriptions(package);
3921 msi_dialog_end_dialog( dialog );
3923 return ERROR_SUCCESS;
3926 static UINT msi_error_dialog_set_error( MSIPACKAGE *package, LPWSTR error_dialog, LPWSTR error )
3930 static const WCHAR update[] =
3931 {'U','P','D','A','T','E',' ','`','C','o','n','t','r','o','l','`',' ',
3932 'S','E','T',' ','`','T','e','x','t','`',' ','=',' ','\'','%','s','\'',' ',
3933 'W','H','E','R','E', ' ','`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ',
3934 'A','N','D',' ','`','C','o','n','t','r','o','l','`',' ','=',' ',
3935 '\'','E','r','r','o','r','T','e','x','t','\'',0};
3937 row = MSI_QueryGetRecord( package->db, update, error, error_dialog );
3939 return ERROR_FUNCTION_FAILED;
3941 msiobj_release(&row->hdr);
3942 return ERROR_SUCCESS;
3945 UINT msi_spawn_error_dialog( MSIPACKAGE *package, LPWSTR error_dialog, LPWSTR error )
3948 WCHAR result[MAX_PATH];
3949 UINT r = ERROR_SUCCESS;
3950 DWORD size = MAX_PATH;
3953 static const WCHAR pn_prop[] = {'P','r','o','d','u','c','t','N','a','m','e',0};
3954 static const WCHAR title_fmt[] = {'%','s',' ','W','a','r','n','i','n','g',0};
3955 static const WCHAR error_abort[] = {'E','r','r','o','r','A','b','o','r','t',0};
3956 static const WCHAR result_prop[] = {
3957 'M','S','I','E','r','r','o','r','D','i','a','l','o','g','R','e','s','u','l','t',0
3960 if ( (msi_get_property_int( package->db, szUILevel, 0 ) & INSTALLUILEVEL_MASK) == INSTALLUILEVEL_NONE )
3961 return ERROR_SUCCESS;
3963 if ( !error_dialog )
3965 LPWSTR product_name = msi_dup_property( package->db, pn_prop );
3966 WCHAR title[MAX_PATH];
3968 sprintfW( title, title_fmt, product_name );
3969 res = MessageBoxW( NULL, error, title, MB_OKCANCEL | MB_ICONWARNING );
3971 msi_free( product_name );
3974 return ERROR_SUCCESS;
3976 return ERROR_FUNCTION_FAILED;
3979 r = msi_error_dialog_set_error( package, error_dialog, error );
3980 if ( r != ERROR_SUCCESS )
3983 dialog = msi_dialog_create( package, error_dialog, package->dialog,
3984 error_dialog_handler );
3986 return ERROR_FUNCTION_FAILED;
3988 dialog->finished = FALSE;
3989 r = msi_dialog_run_message_loop( dialog );
3990 if ( r != ERROR_SUCCESS )
3993 r = msi_get_property( package->db, result_prop, result, &size );
3994 if ( r != ERROR_SUCCESS)
3997 if ( !strcmpW( result, error_abort ) )
3998 r = ERROR_FUNCTION_FAILED;
4001 msi_dialog_destroy( dialog );