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
);
48 extern HINSTANCE msi_hInstance
;
50 struct msi_control_tag
;
51 typedef struct msi_control_tag msi_control
;
52 typedef UINT (*msi_handler
)( msi_dialog
*, msi_control
*, WPARAM
);
54 struct msi_control_tag
66 float progress_current
;
72 typedef struct msi_font_tag
74 struct msi_font_tag
*next
;
84 msi_dialog_event_handler event_handler
;
94 LPWSTR control_default
;
95 LPWSTR control_cancel
;
99 typedef UINT (*msi_dialog_control_func
)( msi_dialog
*dialog
, MSIRECORD
*rec
);
100 struct control_handler
102 LPCWSTR control_type
;
103 msi_dialog_control_func func
;
112 } radio_button_group_descr
;
114 static const WCHAR szMsiDialogClass
[] = {
115 'M','s','i','D','i','a','l','o','g','C','l','o','s','e','C','l','a','s','s',0
117 static const WCHAR szMsiHiddenWindow
[] = {
118 'M','s','i','H','i','d','d','e','n','W','i','n','d','o','w',0 };
119 static const WCHAR szStatic
[] = { 'S','t','a','t','i','c',0 };
120 static const WCHAR szButton
[] = { 'B','U','T','T','O','N', 0 };
121 static const WCHAR szButtonData
[] = { 'M','S','I','D','A','T','A',0 };
122 static const WCHAR szProgress
[] = { 'P','r','o','g','r','e','s','s',0 };
123 static const WCHAR szText
[] = { 'T','e','x','t',0 };
124 static const WCHAR szPushButton
[] = { 'P','u','s','h','B','u','t','t','o','n',0 };
125 static const WCHAR szLine
[] = { 'L','i','n','e',0 };
126 static const WCHAR szBitmap
[] = { 'B','i','t','m','a','p',0 };
127 static const WCHAR szCheckBox
[] = { 'C','h','e','c','k','B','o','x',0 };
128 static const WCHAR szScrollableText
[] = {
129 'S','c','r','o','l','l','a','b','l','e','T','e','x','t',0 };
130 static const WCHAR szComboBox
[] = { 'C','o','m','b','o','B','o','x',0 };
131 static const WCHAR szEdit
[] = { 'E','d','i','t',0 };
132 static const WCHAR szMaskedEdit
[] = { 'M','a','s','k','e','d','E','d','i','t',0 };
133 static const WCHAR szPathEdit
[] = { 'P','a','t','h','E','d','i','t',0 };
134 static const WCHAR szProgressBar
[] = {
135 'P','r','o','g','r','e','s','s','B','a','r',0 };
136 static const WCHAR szRadioButtonGroup
[] = {
137 'R','a','d','i','o','B','u','t','t','o','n','G','r','o','u','p',0 };
138 static const WCHAR szIcon
[] = { 'I','c','o','n',0 };
139 static const WCHAR szSelectionTree
[] = {
140 'S','e','l','e','c','t','i','o','n','T','r','e','e',0 };
141 static const WCHAR szGroupBox
[] = { 'G','r','o','u','p','B','o','x',0 };
142 static const WCHAR szListBox
[] = { 'L','i','s','t','B','o','x',0 };
143 static const WCHAR szDirectoryCombo
[] = { 'D','i','r','e','c','t','o','r','y','C','o','m','b','o',0 };
144 static const WCHAR szDirectoryList
[] = { 'D','i','r','e','c','t','o','r','y','L','i','s','t',0 };
145 static const WCHAR szVolumeCostList
[] = { 'V','o','l','u','m','e','C','o','s','t','L','i','s','t',0 };
146 static const WCHAR szVolumeSelectCombo
[] = { 'V','o','l','u','m','e','S','e','l','e','c','t','C','o','m','b','o',0 };
147 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};
148 static const WCHAR szSelectionPath
[] = {'S','e','l','e','c','t','i','o','n','P','a','t','h',0};
149 static const WCHAR szProperty
[] = {'P','r','o','p','e','r','t','y',0};
151 static UINT
msi_dialog_checkbox_handler( msi_dialog
*, msi_control
*, WPARAM
);
152 static void msi_dialog_checkbox_sync_state( msi_dialog
*, msi_control
* );
153 static UINT
msi_dialog_button_handler( msi_dialog
*, msi_control
*, WPARAM
);
154 static UINT
msi_dialog_edit_handler( msi_dialog
*, msi_control
*, WPARAM
);
155 static UINT
msi_dialog_radiogroup_handler( msi_dialog
*, msi_control
*, WPARAM
);
156 static UINT
msi_dialog_evaluate_control_conditions( msi_dialog
*dialog
);
157 static LRESULT WINAPI
MSIRadioGroup_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
158 static MSIFEATURE
*msi_seltree_get_selected_feature( msi_control
*control
);
160 /* dialog sequencing */
162 #define WM_MSI_DIALOG_CREATE (WM_USER+0x100)
163 #define WM_MSI_DIALOG_DESTROY (WM_USER+0x101)
165 static DWORD uiThreadId
;
166 static HWND hMsiHiddenWindow
;
168 static INT
msi_dialog_scale_unit( msi_dialog
*dialog
, INT val
)
170 return (dialog
->scale
* val
+ 5) / 10;
173 static msi_control
*msi_dialog_find_control( msi_dialog
*dialog
, LPCWSTR name
)
175 msi_control
*control
;
181 LIST_FOR_EACH_ENTRY( control
, &dialog
->controls
, msi_control
, entry
)
182 if( !strcmpW( control
->name
, name
) ) /* FIXME: case sensitive? */
187 static msi_control
*msi_dialog_find_control_by_type( msi_dialog
*dialog
, LPCWSTR type
)
189 msi_control
*control
;
195 LIST_FOR_EACH_ENTRY( control
, &dialog
->controls
, msi_control
, entry
)
196 if( !strcmpW( control
->type
, type
) ) /* FIXME: case sensitive? */
201 static msi_control
*msi_dialog_find_control_by_hwnd( msi_dialog
*dialog
, HWND hwnd
)
203 msi_control
*control
;
207 LIST_FOR_EACH_ENTRY( control
, &dialog
->controls
, msi_control
, entry
)
208 if( hwnd
== control
->hwnd
)
213 static LPWSTR
msi_get_deformatted_field( MSIPACKAGE
*package
, MSIRECORD
*rec
, int field
)
215 LPCWSTR str
= MSI_RecordGetString( rec
, field
);
219 deformat_string( package
, str
, &ret
);
223 static LPWSTR
msi_dialog_dup_property( msi_dialog
*dialog
, LPCWSTR property
, BOOL indirect
)
231 prop
= msi_dup_property( dialog
->package
, property
);
234 prop
= strdupW( property
);
239 msi_dialog
*msi_dialog_get_parent( msi_dialog
*dialog
)
241 return dialog
->parent
;
244 LPWSTR
msi_dialog_get_name( msi_dialog
*dialog
)
250 * msi_dialog_get_style
252 * Extract the {\style} string from the front of the text to display and
253 * update the pointer. Only the last style in a list is applied.
255 static LPWSTR
msi_dialog_get_style( LPCWSTR p
, LPCWSTR
*rest
)
266 while ((first
= strchrW( p
, '{' )) && (q
= strchrW( first
+ 1, '}' )))
269 if( *p
!= '\\' && *p
!= '&' )
272 /* little bit of sanity checking to stop us getting confused with RTF */
273 for( i
=++p
; i
<q
; i
++ )
274 if( *i
== '}' || *i
== '\\' )
284 ret
= msi_alloc( len
*sizeof(WCHAR
) );
287 memcpy( ret
, p
, len
*sizeof(WCHAR
) );
292 static UINT
msi_dialog_add_font( MSIRECORD
*rec
, LPVOID param
)
294 msi_dialog
*dialog
= param
;
301 /* create a font and add it to the list */
302 name
= MSI_RecordGetString( rec
, 1 );
303 font
= msi_alloc( sizeof *font
+ strlenW( name
)*sizeof (WCHAR
) );
304 strcpyW( font
->name
, name
);
305 font
->next
= dialog
->font_list
;
306 dialog
->font_list
= font
;
308 font
->color
= MSI_RecordGetInteger( rec
, 4 );
310 memset( &lf
, 0, sizeof lf
);
311 face
= MSI_RecordGetString( rec
, 2 );
312 lf
.lfHeight
= MSI_RecordGetInteger( rec
, 3 );
313 style
= MSI_RecordGetInteger( rec
, 5 );
314 if( style
& msidbTextStyleStyleBitsBold
)
315 lf
.lfWeight
= FW_BOLD
;
316 if( style
& msidbTextStyleStyleBitsItalic
)
318 if( style
& msidbTextStyleStyleBitsUnderline
)
319 lf
.lfUnderline
= TRUE
;
320 if( style
& msidbTextStyleStyleBitsStrike
)
321 lf
.lfStrikeOut
= TRUE
;
322 lstrcpynW( lf
.lfFaceName
, face
, LF_FACESIZE
);
324 /* adjust the height */
325 hdc
= GetDC( dialog
->hwnd
);
328 lf
.lfHeight
= -MulDiv(lf
.lfHeight
, GetDeviceCaps(hdc
, LOGPIXELSY
), 72);
329 ReleaseDC( dialog
->hwnd
, hdc
);
332 font
->hfont
= CreateFontIndirectW( &lf
);
334 TRACE("Adding font style %s\n", debugstr_w(font
->name
) );
336 return ERROR_SUCCESS
;
339 static msi_font
*msi_dialog_find_font( msi_dialog
*dialog
, LPCWSTR name
)
343 for( font
= dialog
->font_list
; font
; font
= font
->next
)
344 if( !strcmpW( font
->name
, name
) ) /* FIXME: case sensitive? */
350 static UINT
msi_dialog_set_font( msi_dialog
*dialog
, HWND hwnd
, LPCWSTR name
)
354 font
= msi_dialog_find_font( dialog
, name
);
356 SendMessageW( hwnd
, WM_SETFONT
, (WPARAM
) font
->hfont
, TRUE
);
358 ERR("No font entry for %s\n", debugstr_w(name
));
359 return ERROR_SUCCESS
;
362 static UINT
msi_dialog_build_font_list( msi_dialog
*dialog
)
364 static const WCHAR query
[] = {
365 'S','E','L','E','C','T',' ','*',' ',
366 'F','R','O','M',' ','`','T','e','x','t','S','t','y','l','e','`',' ',0
369 MSIQUERY
*view
= NULL
;
371 TRACE("dialog %p\n", dialog
);
373 r
= MSI_OpenQuery( dialog
->package
->db
, &view
, query
);
374 if( r
!= ERROR_SUCCESS
)
377 r
= MSI_IterateRecords( view
, NULL
, msi_dialog_add_font
, dialog
);
378 msiobj_release( &view
->hdr
);
383 static void msi_destroy_control( msi_control
*t
)
385 list_remove( &t
->entry
);
386 /* leave dialog->hwnd - destroying parent destroys child windows */
387 msi_free( t
->property
);
388 msi_free( t
->value
);
390 DeleteObject( t
->hBitmap
);
392 DestroyIcon( t
->hIcon
);
393 msi_free( t
->tabnext
);
396 FreeLibrary( t
->hDll
);
400 static msi_control
*msi_dialog_create_window( msi_dialog
*dialog
,
401 MSIRECORD
*rec
, DWORD exstyle
, LPCWSTR szCls
, LPCWSTR name
, LPCWSTR text
,
402 DWORD style
, HWND parent
)
404 DWORD x
, y
, width
, height
;
405 LPWSTR font
= NULL
, title_font
= NULL
;
406 LPCWSTR title
= NULL
;
407 msi_control
*control
;
411 control
= msi_alloc( sizeof *control
+ strlenW(name
)*sizeof(WCHAR
) );
415 strcpyW( control
->name
, name
);
416 list_add_head( &dialog
->controls
, &control
->entry
);
417 control
->handler
= NULL
;
418 control
->property
= NULL
;
419 control
->value
= NULL
;
420 control
->hBitmap
= NULL
;
421 control
->hIcon
= NULL
;
422 control
->hDll
= NULL
;
423 control
->tabnext
= strdupW( MSI_RecordGetString( rec
, 11) );
424 control
->type
= strdupW( MSI_RecordGetString( rec
, 3 ) );
425 control
->progress_current
= 0;
426 control
->progress_max
= 100;
428 x
= MSI_RecordGetInteger( rec
, 4 );
429 y
= MSI_RecordGetInteger( rec
, 5 );
430 width
= MSI_RecordGetInteger( rec
, 6 );
431 height
= MSI_RecordGetInteger( rec
, 7 );
433 x
= msi_dialog_scale_unit( dialog
, x
);
434 y
= msi_dialog_scale_unit( dialog
, y
);
435 width
= msi_dialog_scale_unit( dialog
, width
);
436 height
= msi_dialog_scale_unit( dialog
, height
);
440 deformat_string( dialog
->package
, text
, &title_font
);
441 font
= msi_dialog_get_style( title_font
, &title
);
444 control
->hwnd
= CreateWindowExW( exstyle
, szCls
, title
, style
,
445 x
, y
, width
, height
, parent
, NULL
, NULL
, NULL
);
447 TRACE("Dialog %s control %s hwnd %p\n",
448 debugstr_w(dialog
->name
), debugstr_w(text
), control
->hwnd
);
450 msi_dialog_set_font( dialog
, control
->hwnd
,
451 font
? font
: dialog
->default_font
);
453 msi_free( title_font
);
459 static LPWSTR
msi_dialog_get_uitext( msi_dialog
*dialog
, LPCWSTR key
)
464 static const WCHAR query
[] = {
465 's','e','l','e','c','t',' ','*',' ',
466 'f','r','o','m',' ','`','U','I','T','e','x','t','`',' ',
467 'w','h','e','r','e',' ','`','K','e','y','`',' ','=',' ','\'','%','s','\'',0
470 rec
= MSI_QueryGetRecord( dialog
->package
->db
, query
, key
);
471 if (!rec
) return NULL
;
472 text
= strdupW( MSI_RecordGetString( rec
, 2 ) );
473 msiobj_release( &rec
->hdr
);
477 static MSIRECORD
*msi_get_binary_record( MSIDATABASE
*db
, LPCWSTR name
)
479 static const WCHAR query
[] = {
480 's','e','l','e','c','t',' ','*',' ',
481 'f','r','o','m',' ','B','i','n','a','r','y',' ',
482 'w','h','e','r','e',' ',
483 '`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0
486 return MSI_QueryGetRecord( db
, query
, name
);
489 static LPWSTR
msi_create_tmp_path(void)
493 static const WCHAR prefix
[] = { 'm','s','i',0 };
496 r
= GetTempPathW( MAX_PATH
, tmp
);
499 len
= lstrlenW( tmp
) + 20;
500 path
= msi_alloc( len
* sizeof (WCHAR
) );
503 r
= GetTempFileNameW( tmp
, prefix
, 0, path
);
514 static HANDLE
msi_load_image( MSIDATABASE
*db
, LPCWSTR name
, UINT type
,
515 UINT cx
, UINT cy
, UINT flags
)
517 MSIRECORD
*rec
= NULL
;
518 HANDLE himage
= NULL
;
522 TRACE("%p %s %u %u %08x\n", db
, debugstr_w(name
), cx
, cy
, flags
);
524 tmp
= msi_create_tmp_path();
528 rec
= msi_get_binary_record( db
, name
);
531 r
= MSI_RecordStreamToFile( rec
, 2, tmp
);
532 if( r
== ERROR_SUCCESS
)
534 himage
= LoadImageW( 0, tmp
, type
, cx
, cy
, flags
);
536 msiobj_release( &rec
->hdr
);
544 static HICON
msi_load_icon( MSIDATABASE
*db
, LPCWSTR text
, UINT attributes
)
546 DWORD cx
= 0, cy
= 0, flags
;
548 flags
= LR_LOADFROMFILE
| LR_DEFAULTSIZE
;
549 if( attributes
& msidbControlAttributesFixedSize
)
551 flags
&= ~LR_DEFAULTSIZE
;
552 if( attributes
& msidbControlAttributesIconSize16
)
557 if( attributes
& msidbControlAttributesIconSize32
)
562 /* msidbControlAttributesIconSize48 handled by above logic */
564 return msi_load_image( db
, text
, IMAGE_ICON
, cx
, cy
, flags
);
568 /* called from the Control Event subscription code */
569 void msi_dialog_handle_event( msi_dialog
* dialog
, LPCWSTR control
,
570 LPCWSTR attribute
, MSIRECORD
*rec
)
573 LPCWSTR font_text
, text
= NULL
;
576 static const WCHAR empty
[] = {0};
578 ctrl
= msi_dialog_find_control( dialog
, control
);
581 if( !lstrcmpW(attribute
, szText
) )
583 font_text
= MSI_RecordGetString( rec
, 1 );
584 font
= msi_dialog_get_style( font_text
, &text
);
585 if (!text
) text
= empty
;
586 SetWindowTextW( ctrl
->hwnd
, text
);
588 msi_dialog_check_messages( NULL
);
590 else if( !lstrcmpW(attribute
, szProgress
) )
594 func
= MSI_RecordGetInteger( rec
, 1 );
595 val
= MSI_RecordGetInteger( rec
, 2 );
600 ctrl
->progress_max
= val
;
601 ctrl
->progress_current
= 0;
602 SendMessageW(ctrl
->hwnd
, PBM_SETRANGE
, 0, MAKELPARAM(0,100));
603 SendMessageW(ctrl
->hwnd
, PBM_SETPOS
, 0, 0);
605 case 1: /* FIXME: not sure what this is supposed to do */
608 ctrl
->progress_current
+= val
;
609 SendMessageW(ctrl
->hwnd
, PBM_SETPOS
, 100*(ctrl
->progress_current
/ctrl
->progress_max
), 0);
612 ERR("Unknown progress message %d\n", func
);
616 else if ( !lstrcmpW(attribute
, szProperty
) )
618 MSIFEATURE
*feature
= msi_seltree_get_selected_feature( ctrl
);
619 MSI_SetPropertyW( dialog
->package
, ctrl
->property
, feature
->Directory
);
621 else if ( !lstrcmpW(attribute
, szSelectionPath
) )
623 LPWSTR prop
= msi_dialog_dup_property( dialog
, ctrl
->property
, TRUE
);
626 path
= msi_dup_property( dialog
->package
, prop
);
627 SetWindowTextW( ctrl
->hwnd
, path
);
633 FIXME("Attribute %s not being set\n", debugstr_w(attribute
));
638 static void msi_dialog_map_events(msi_dialog
* dialog
, LPCWSTR control
)
640 static const WCHAR Query
[] = {
641 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
642 '`','E','v','e','n','t','M','a','p','p','i','n','g','`',' ',
643 'W','H','E','R','E',' ',
644 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ',
646 '`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',0
649 LPCWSTR event
, attribute
;
651 row
= MSI_QueryGetRecord( dialog
->package
->db
, Query
, dialog
->name
, control
);
655 event
= MSI_RecordGetString( row
, 3 );
656 attribute
= MSI_RecordGetString( row
, 4 );
657 ControlEvent_SubscribeToEvent( dialog
->package
, dialog
, event
, control
, attribute
);
658 msiobj_release( &row
->hdr
);
661 /* everything except radio buttons */
662 static msi_control
*msi_dialog_add_control( msi_dialog
*dialog
,
663 MSIRECORD
*rec
, LPCWSTR szCls
, DWORD style
)
669 name
= MSI_RecordGetString( rec
, 2 );
670 attributes
= MSI_RecordGetInteger( rec
, 8 );
671 text
= MSI_RecordGetString( rec
, 10 );
672 if( attributes
& msidbControlAttributesVisible
)
674 if( ~attributes
& msidbControlAttributesEnabled
)
675 style
|= WS_DISABLED
;
676 if( attributes
& msidbControlAttributesSunken
)
677 exstyle
|= WS_EX_CLIENTEDGE
;
679 msi_dialog_map_events(dialog
, name
);
681 return msi_dialog_create_window( dialog
, rec
, exstyle
, szCls
, name
,
682 text
, style
, dialog
->hwnd
);
693 * we don't erase our own background,
694 * so we have to make sure that the parent window redraws first
696 static void msi_text_on_settext( HWND hWnd
)
701 hParent
= GetParent( hWnd
);
702 GetWindowRect( hWnd
, &rc
);
703 MapWindowPoints( NULL
, hParent
, (LPPOINT
) &rc
, 2 );
704 InvalidateRect( hParent
, &rc
, TRUE
);
707 static LRESULT WINAPI
708 MSIText_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
710 struct msi_text_info
*info
;
713 TRACE("%p %04x %08lx %08lx\n", hWnd
, msg
, wParam
, lParam
);
715 info
= GetPropW(hWnd
, szButtonData
);
718 SetTextColor( (HDC
)wParam
, info
->font
->color
);
720 if( msg
== WM_CTLCOLORSTATIC
&&
721 ( info
->attributes
& msidbControlAttributesTransparent
) )
723 SetBkMode( (HDC
)wParam
, TRANSPARENT
);
724 return (LRESULT
) GetStockObject(NULL_BRUSH
);
727 r
= CallWindowProcW(info
->oldproc
, hWnd
, msg
, wParam
, lParam
);
732 msi_text_on_settext( hWnd
);
736 RemovePropW( hWnd
, szButtonData
);
743 static UINT
msi_dialog_text_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
745 msi_control
*control
;
746 struct msi_text_info
*info
;
747 LPCWSTR text
, ptr
, prop
;
750 TRACE("%p %p\n", dialog
, rec
);
752 control
= msi_dialog_add_control( dialog
, rec
, szStatic
, SS_LEFT
| WS_GROUP
);
754 return ERROR_FUNCTION_FAILED
;
756 info
= msi_alloc( sizeof *info
);
758 return ERROR_SUCCESS
;
760 control
->attributes
= MSI_RecordGetInteger( rec
, 8 );
761 prop
= MSI_RecordGetString( rec
, 9 );
762 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
764 text
= MSI_RecordGetString( rec
, 10 );
765 font_name
= msi_dialog_get_style( text
, &ptr
);
766 info
->font
= ( font_name
) ? msi_dialog_find_font( dialog
, font_name
) : NULL
;
767 msi_free( font_name
);
769 info
->attributes
= MSI_RecordGetInteger( rec
, 8 );
770 if( info
->attributes
& msidbControlAttributesTransparent
)
771 SetWindowLongPtrW( control
->hwnd
, GWL_EXSTYLE
, WS_EX_TRANSPARENT
);
773 info
->oldproc
= (WNDPROC
) SetWindowLongPtrW( control
->hwnd
, GWLP_WNDPROC
,
774 (LONG_PTR
)MSIText_WndProc
);
775 SetPropW( control
->hwnd
, szButtonData
, info
);
777 ControlEvent_SubscribeToEvent( dialog
->package
, dialog
,
778 szSelectionPath
, control
->name
, szSelectionPath
);
780 return ERROR_SUCCESS
;
783 static UINT
msi_dialog_button_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
785 msi_control
*control
;
786 UINT attributes
, style
;
789 TRACE("%p %p\n", dialog
, rec
);
792 attributes
= MSI_RecordGetInteger( rec
, 8 );
793 if( attributes
& msidbControlAttributesIcon
)
796 control
= msi_dialog_add_control( dialog
, rec
, szButton
, style
);
798 return ERROR_FUNCTION_FAILED
;
800 control
->handler
= msi_dialog_button_handler
;
803 text
= msi_get_deformatted_field( dialog
->package
, rec
, 10 );
804 control
->hIcon
= msi_load_icon( dialog
->package
->db
, text
, attributes
);
805 if( attributes
& msidbControlAttributesIcon
)
806 SendMessageW( control
->hwnd
, BM_SETIMAGE
, IMAGE_ICON
, (LPARAM
) control
->hIcon
);
809 return ERROR_SUCCESS
;
812 static LPWSTR
msi_get_checkbox_value( msi_dialog
*dialog
, LPCWSTR prop
)
814 static const WCHAR query
[] = {
815 'S','E','L','E','C','T',' ','*',' ',
816 'F','R','O','M',' ','`','C','h','e','c','k','B','o','x','`',' ',
817 'W','H','E','R','E',' ',
818 '`','P','r','o','p','e','r','t','y','`',' ','=',' ',
821 MSIRECORD
*rec
= NULL
;
824 /* find if there is a value associated with the checkbox */
825 rec
= MSI_QueryGetRecord( dialog
->package
->db
, query
, prop
);
829 ret
= msi_get_deformatted_field( dialog
->package
, rec
, 2 );
835 msiobj_release( &rec
->hdr
);
839 ret
= msi_dup_property( dialog
->package
, prop
);
849 static UINT
msi_dialog_checkbox_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
851 msi_control
*control
;
854 TRACE("%p %p\n", dialog
, rec
);
856 control
= msi_dialog_add_control( dialog
, rec
, szButton
,
857 BS_CHECKBOX
| BS_MULTILINE
| WS_TABSTOP
);
858 control
->handler
= msi_dialog_checkbox_handler
;
859 prop
= MSI_RecordGetString( rec
, 9 );
862 control
->property
= strdupW( prop
);
863 control
->value
= msi_get_checkbox_value( dialog
, prop
);
864 TRACE("control %s value %s\n", debugstr_w(control
->property
),
865 debugstr_w(control
->value
));
867 msi_dialog_checkbox_sync_state( dialog
, control
);
869 return ERROR_SUCCESS
;
872 static UINT
msi_dialog_line_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
874 TRACE("%p %p\n", dialog
, rec
);
876 /* line is exactly 2 units in height */
877 MSI_RecordSetInteger( rec
, 7, 2 );
879 msi_dialog_add_control( dialog
, rec
, szStatic
, SS_ETCHEDHORZ
| SS_SUNKEN
);
880 return ERROR_SUCCESS
;
883 /******************** Scroll Text ********************************************/
885 struct msi_scrolltext_info
888 msi_control
*control
;
892 static LRESULT WINAPI
893 MSIScrollText_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
895 struct msi_scrolltext_info
*info
;
898 TRACE("%p %04x %08lx %08lx\n", hWnd
, msg
, wParam
, lParam
);
900 info
= GetPropW( hWnd
, szButtonData
);
902 r
= CallWindowProcW( info
->oldproc
, hWnd
, msg
, wParam
, lParam
);
908 RemovePropW( hWnd
, szButtonData
);
911 /* native MSI sets a wait cursor here */
912 msi_dialog_button_handler( info
->dialog
, info
->control
, BN_CLICKED
);
918 struct msi_streamin_info
925 static DWORD CALLBACK
926 msi_richedit_stream_in( DWORD_PTR arg
, LPBYTE buffer
, LONG count
, LONG
*pcb
)
928 struct msi_streamin_info
*info
= (struct msi_streamin_info
*) arg
;
930 if( (count
+ info
->offset
) > info
->length
)
931 count
= info
->length
- info
->offset
;
932 memcpy( buffer
, &info
->string
[ info
->offset
], count
);
934 info
->offset
+= count
;
936 TRACE("%d/%d\n", info
->offset
, info
->length
);
941 static void msi_scrolltext_add_text( msi_control
*control
, LPCWSTR text
)
943 struct msi_streamin_info info
;
946 info
.string
= strdupWtoA( text
);
948 info
.length
= lstrlenA( info
.string
) + 1;
950 es
.dwCookie
= (DWORD_PTR
) &info
;
952 es
.pfnCallback
= msi_richedit_stream_in
;
954 SendMessageW( control
->hwnd
, EM_STREAMIN
, SF_RTF
, (LPARAM
) &es
);
956 msi_free( info
.string
);
959 static UINT
msi_dialog_scrolltext_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
961 static const WCHAR szRichEdit20W
[] = {
962 'R','i','c','h','E','d','i','t','2','0','W',0
964 struct msi_scrolltext_info
*info
;
965 msi_control
*control
;
970 info
= msi_alloc( sizeof *info
);
972 return ERROR_FUNCTION_FAILED
;
974 hRichedit
= LoadLibraryA("riched20");
976 style
= WS_BORDER
| ES_MULTILINE
| WS_VSCROLL
|
977 ES_READONLY
| ES_AUTOVSCROLL
| WS_TABSTOP
;
978 control
= msi_dialog_add_control( dialog
, rec
, szRichEdit20W
, style
);
981 FreeLibrary( hRichedit
);
983 return ERROR_FUNCTION_FAILED
;
986 control
->hDll
= hRichedit
;
988 info
->dialog
= dialog
;
989 info
->control
= control
;
991 /* subclass the static control */
992 info
->oldproc
= (WNDPROC
) SetWindowLongPtrW( control
->hwnd
, GWLP_WNDPROC
,
993 (LONG_PTR
)MSIScrollText_WndProc
);
994 SetPropW( control
->hwnd
, szButtonData
, info
);
996 /* add the text into the richedit */
997 text
= MSI_RecordGetString( rec
, 10 );
999 msi_scrolltext_add_text( control
, text
);
1001 return ERROR_SUCCESS
;
1004 static HBITMAP
msi_load_picture( MSIDATABASE
*db
, LPCWSTR name
,
1005 INT cx
, INT cy
, DWORD flags
)
1007 HBITMAP hOleBitmap
= 0, hBitmap
= 0, hOldSrcBitmap
, hOldDestBitmap
;
1008 MSIRECORD
*rec
= NULL
;
1009 IStream
*stm
= NULL
;
1010 IPicture
*pic
= NULL
;
1015 rec
= msi_get_binary_record( db
, name
);
1019 r
= MSI_RecordGetIStream( rec
, 2, &stm
);
1020 msiobj_release( &rec
->hdr
);
1021 if( r
!= ERROR_SUCCESS
)
1024 r
= OleLoadPicture( stm
, 0, TRUE
, &IID_IPicture
, (LPVOID
*) &pic
);
1025 IStream_Release( stm
);
1028 ERR("failed to load picture\n");
1032 r
= IPicture_get_Handle( pic
, (OLE_HANDLE
*) &hOleBitmap
);
1035 ERR("failed to get bitmap handle\n");
1039 /* make the bitmap the desired size */
1040 r
= GetObjectW( hOleBitmap
, sizeof bm
, &bm
);
1041 if (r
!= sizeof bm
)
1043 ERR("failed to get bitmap size\n");
1047 if (flags
& LR_DEFAULTSIZE
)
1053 srcdc
= CreateCompatibleDC( NULL
);
1054 hOldSrcBitmap
= SelectObject( srcdc
, hOleBitmap
);
1055 destdc
= CreateCompatibleDC( NULL
);
1056 hBitmap
= CreateCompatibleBitmap( srcdc
, cx
, cy
);
1057 hOldDestBitmap
= SelectObject( destdc
, hBitmap
);
1058 StretchBlt( destdc
, 0, 0, cx
, cy
,
1059 srcdc
, 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
1060 SelectObject( srcdc
, hOldSrcBitmap
);
1061 SelectObject( destdc
, hOldDestBitmap
);
1067 IPicture_Release( pic
);
1071 static UINT
msi_dialog_bitmap_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1073 UINT cx
, cy
, flags
, style
, attributes
;
1074 msi_control
*control
;
1077 flags
= LR_LOADFROMFILE
;
1078 style
= SS_BITMAP
| SS_LEFT
| WS_GROUP
;
1080 attributes
= MSI_RecordGetInteger( rec
, 8 );
1081 if( attributes
& msidbControlAttributesFixedSize
)
1083 flags
|= LR_DEFAULTSIZE
;
1084 style
|= SS_CENTERIMAGE
;
1087 control
= msi_dialog_add_control( dialog
, rec
, szStatic
, style
);
1088 cx
= MSI_RecordGetInteger( rec
, 6 );
1089 cy
= MSI_RecordGetInteger( rec
, 7 );
1090 cx
= msi_dialog_scale_unit( dialog
, cx
);
1091 cy
= msi_dialog_scale_unit( dialog
, cy
);
1093 text
= msi_get_deformatted_field( dialog
->package
, rec
, 10 );
1094 control
->hBitmap
= msi_load_picture( dialog
->package
->db
, text
, cx
, cy
, flags
);
1095 if( control
->hBitmap
)
1096 SendMessageW( control
->hwnd
, STM_SETIMAGE
,
1097 IMAGE_BITMAP
, (LPARAM
) control
->hBitmap
);
1099 ERR("Failed to load bitmap %s\n", debugstr_w(text
));
1103 return ERROR_SUCCESS
;
1106 static UINT
msi_dialog_icon_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1108 msi_control
*control
;
1114 control
= msi_dialog_add_control( dialog
, rec
, szStatic
,
1115 SS_ICON
| SS_CENTERIMAGE
| WS_GROUP
);
1117 attributes
= MSI_RecordGetInteger( rec
, 8 );
1118 text
= msi_get_deformatted_field( dialog
->package
, rec
, 10 );
1119 control
->hIcon
= msi_load_icon( dialog
->package
->db
, text
, attributes
);
1120 if( control
->hIcon
)
1121 SendMessageW( control
->hwnd
, STM_SETICON
, (WPARAM
) control
->hIcon
, 0 );
1123 ERR("Failed to load bitmap %s\n", debugstr_w(text
));
1125 return ERROR_SUCCESS
;
1128 static UINT
msi_dialog_combo_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1130 static const WCHAR szCombo
[] = { 'C','O','M','B','O','B','O','X',0 };
1131 DWORD attributes
, style
;
1133 style
= CBS_AUTOHSCROLL
| WS_TABSTOP
| WS_GROUP
| WS_CHILD
;
1134 attributes
= MSI_RecordGetInteger( rec
, 8 );
1135 if ( ~attributes
& msidbControlAttributesSorted
)
1137 if ( attributes
& msidbControlAttributesComboList
)
1138 style
|= CBS_DROPDOWNLIST
;
1140 style
|= CBS_DROPDOWN
;
1142 msi_dialog_add_control( dialog
, rec
, szCombo
, style
);
1143 return ERROR_SUCCESS
;
1146 static UINT
msi_dialog_edit_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1148 msi_control
*control
;
1150 LPWSTR val
, begin
, end
;
1154 control
= msi_dialog_add_control( dialog
, rec
, szEdit
,
1155 WS_BORDER
| WS_TABSTOP
| ES_AUTOHSCROLL
);
1156 control
->handler
= msi_dialog_edit_handler
;
1158 text
= MSI_RecordGetString( rec
, 10 );
1161 begin
= strchrW( text
, '{' );
1162 end
= strchrW( text
, '}' );
1164 if ( begin
&& end
&& end
> begin
)
1166 lstrcpynW( num
, begin
+ 1, end
- begin
);
1167 limit
= atolW( num
);
1169 SendMessageW( control
->hwnd
, EM_SETLIMITTEXT
, limit
, 0 );
1173 prop
= MSI_RecordGetString( rec
, 9 );
1175 control
->property
= strdupW( prop
);
1177 val
= msi_dup_property( dialog
->package
, control
->property
);
1178 SetWindowTextW( control
->hwnd
, val
);
1180 return ERROR_SUCCESS
;
1183 /******************** Masked Edit ********************************************/
1185 #define MASK_MAX_GROUPS 20
1187 struct msi_mask_group
1195 struct msi_maskedit_info
1203 struct msi_mask_group group
[MASK_MAX_GROUPS
];
1206 static BOOL
msi_mask_editable( WCHAR type
)
1221 static void msi_mask_control_change( struct msi_maskedit_info
*info
)
1226 val
= msi_alloc( (info
->num_chars
+1)*sizeof(WCHAR
) );
1227 for( i
=0, n
=0; i
<info
->num_groups
; i
++ )
1229 if( (info
->group
[i
].len
+ n
) > info
->num_chars
)
1231 ERR("can't fit control %d text into template\n",i
);
1234 if (!msi_mask_editable(info
->group
[i
].type
))
1236 for(r
=0; r
<info
->group
[i
].len
; r
++)
1237 val
[n
+r
] = info
->group
[i
].type
;
1242 r
= GetWindowTextW( info
->group
[i
].hwnd
, &val
[n
], info
->group
[i
].len
+1 );
1243 if( r
!= info
->group
[i
].len
)
1249 TRACE("%d/%d controls were good\n", i
, info
->num_groups
);
1251 if( i
== info
->num_groups
)
1253 TRACE("Set property %s to %s\n",
1254 debugstr_w(info
->prop
), debugstr_w(val
) );
1255 CharUpperBuffW( val
, info
->num_chars
);
1256 MSI_SetPropertyW( info
->dialog
->package
, info
->prop
, val
);
1257 msi_dialog_evaluate_control_conditions( info
->dialog
);
1262 /* now move to the next control if necessary */
1263 static VOID
msi_mask_next_control( struct msi_maskedit_info
*info
, HWND hWnd
)
1268 for( i
=0; i
<info
->num_groups
; i
++ )
1269 if( info
->group
[i
].hwnd
== hWnd
)
1272 /* don't move from the last control */
1273 if( i
>= (info
->num_groups
-1) )
1276 len
= SendMessageW( hWnd
, WM_GETTEXTLENGTH
, 0, 0 );
1277 if( len
< info
->group
[i
].len
)
1280 hWndNext
= GetNextDlgTabItem( GetParent( hWnd
), hWnd
, FALSE
);
1281 SetFocus( hWndNext
);
1284 static LRESULT WINAPI
1285 MSIMaskedEdit_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1287 struct msi_maskedit_info
*info
;
1290 TRACE("%p %04x %08lx %08lx\n", hWnd
, msg
, wParam
, lParam
);
1292 info
= GetPropW(hWnd
, szButtonData
);
1294 r
= CallWindowProcW(info
->oldproc
, hWnd
, msg
, wParam
, lParam
);
1299 if (HIWORD(wParam
) == EN_CHANGE
)
1301 msi_mask_control_change( info
);
1302 msi_mask_next_control( info
, (HWND
) lParam
);
1306 msi_free( info
->prop
);
1308 RemovePropW( hWnd
, szButtonData
);
1315 /* fish the various bits of the property out and put them in the control */
1317 msi_maskedit_set_text( struct msi_maskedit_info
*info
, LPCWSTR text
)
1323 for( i
= 0; i
< info
->num_groups
; i
++ )
1325 if( info
->group
[i
].len
< lstrlenW( p
) )
1327 LPWSTR chunk
= strdupW( p
);
1328 chunk
[ info
->group
[i
].len
] = 0;
1329 SetWindowTextW( info
->group
[i
].hwnd
, chunk
);
1334 SetWindowTextW( info
->group
[i
].hwnd
, p
);
1337 p
+= info
->group
[i
].len
;
1341 static struct msi_maskedit_info
* msi_dialog_parse_groups( LPCWSTR mask
)
1343 struct msi_maskedit_info
* info
= NULL
;
1344 int i
= 0, n
= 0, total
= 0;
1347 TRACE("masked control, template %s\n", debugstr_w(mask
));
1352 info
= msi_alloc_zero( sizeof *info
);
1356 p
= strchrW(mask
, '<');
1362 for( i
=0; i
<MASK_MAX_GROUPS
; i
++ )
1364 /* stop at the end of the string */
1365 if( p
[0] == 0 || p
[0] == '>' )
1368 /* count the number of the same identifier */
1369 for( n
=0; p
[n
] == p
[0]; n
++ )
1371 info
->group
[i
].ofs
= total
;
1372 info
->group
[i
].type
= p
[0];
1376 total
++; /* an extra not part of the group */
1378 info
->group
[i
].len
= n
;
1383 TRACE("%d characters in %d groups\n", total
, i
);
1384 if( i
== MASK_MAX_GROUPS
)
1385 ERR("too many groups in PIDTemplate %s\n", debugstr_w(mask
));
1387 info
->num_chars
= total
;
1388 info
->num_groups
= i
;
1394 msi_maskedit_create_children( struct msi_maskedit_info
*info
, LPCWSTR font
)
1396 DWORD width
, height
, style
, wx
, ww
;
1401 style
= WS_CHILD
| WS_BORDER
| WS_VISIBLE
| WS_TABSTOP
| ES_AUTOHSCROLL
;
1403 GetClientRect( info
->hwnd
, &rect
);
1405 width
= rect
.right
- rect
.left
;
1406 height
= rect
.bottom
- rect
.top
;
1408 for( i
= 0; i
< info
->num_groups
; i
++ )
1410 if (!msi_mask_editable( info
->group
[i
].type
))
1412 wx
= (info
->group
[i
].ofs
* width
) / info
->num_chars
;
1413 ww
= (info
->group
[i
].len
* width
) / info
->num_chars
;
1415 hwnd
= CreateWindowW( szEdit
, NULL
, style
, wx
, 0, ww
, height
,
1416 info
->hwnd
, NULL
, NULL
, NULL
);
1419 ERR("failed to create mask edit sub window\n");
1423 SendMessageW( hwnd
, EM_LIMITTEXT
, info
->group
[i
].len
, 0 );
1425 msi_dialog_set_font( info
->dialog
, hwnd
,
1426 font
?font
:info
->dialog
->default_font
);
1427 info
->group
[i
].hwnd
= hwnd
;
1432 * office 2003 uses "73931<````=````=````=````=`````>@@@@@"
1433 * delphi 7 uses "<????-??????-??????-????>" and "<???-???>"
1434 * filemaker pro 7 uses "<^^^^=^^^^=^^^^=^^^^=^^^^=^^^^=^^^^^>"
1436 static UINT
msi_dialog_maskedit_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1438 LPWSTR font_mask
, val
= NULL
, font
;
1439 struct msi_maskedit_info
*info
= NULL
;
1440 UINT ret
= ERROR_SUCCESS
;
1441 msi_control
*control
;
1446 font_mask
= msi_get_deformatted_field( dialog
->package
, rec
, 10 );
1447 font
= msi_dialog_get_style( font_mask
, &mask
);
1450 ERR("mask template is empty\n");
1454 info
= msi_dialog_parse_groups( mask
);
1457 ERR("template %s is invalid\n", debugstr_w(mask
));
1461 info
->dialog
= dialog
;
1463 control
= msi_dialog_add_control( dialog
, rec
, szStatic
,
1464 SS_OWNERDRAW
| WS_GROUP
| WS_VISIBLE
);
1467 ERR("Failed to create maskedit container\n");
1468 ret
= ERROR_FUNCTION_FAILED
;
1471 SetWindowLongPtrW( control
->hwnd
, GWL_EXSTYLE
, WS_EX_CONTROLPARENT
);
1473 info
->hwnd
= control
->hwnd
;
1475 /* subclass the static control */
1476 info
->oldproc
= (WNDPROC
) SetWindowLongPtrW( info
->hwnd
, GWLP_WNDPROC
,
1477 (LONG_PTR
)MSIMaskedEdit_WndProc
);
1478 SetPropW( control
->hwnd
, szButtonData
, info
);
1480 prop
= MSI_RecordGetString( rec
, 9 );
1482 info
->prop
= strdupW( prop
);
1484 msi_maskedit_create_children( info
, font
);
1488 val
= msi_dup_property( dialog
->package
, prop
);
1491 msi_maskedit_set_text( info
, val
);
1497 if( ret
!= ERROR_SUCCESS
)
1499 msi_free( font_mask
);
1504 /******************** Progress Bar *****************************************/
1506 static UINT
msi_dialog_progress_bar( msi_dialog
*dialog
, MSIRECORD
*rec
)
1508 msi_dialog_add_control( dialog
, rec
, PROGRESS_CLASSW
, WS_VISIBLE
);
1509 return ERROR_SUCCESS
;
1512 /******************** Path Edit ********************************************/
1514 struct msi_pathedit_info
1517 msi_control
*control
;
1521 static LPWSTR
msi_get_window_text( HWND hwnd
)
1527 buf
= msi_alloc( sz
*sizeof(WCHAR
) );
1530 r
= GetWindowTextW( hwnd
, buf
, sz
);
1534 buf
= msi_realloc( buf
, sz
*sizeof(WCHAR
) );
1540 static void msi_dialog_update_pathedit( msi_dialog
*dialog
, msi_control
*control
)
1545 if (!control
&& !(control
= msi_dialog_find_control_by_type( dialog
, szPathEdit
)))
1548 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
1549 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
1550 path
= msi_dialog_dup_property( dialog
, prop
, TRUE
);
1552 SetWindowTextW( control
->hwnd
, path
);
1553 SendMessageW( control
->hwnd
, EM_SETSEL
, 0, -1 );
1559 /* FIXME: test when this should fail */
1560 static BOOL
msi_dialog_verify_path( LPWSTR path
)
1562 if ( !lstrlenW( path
) )
1565 if ( PathIsRelativeW( path
) )
1571 /* returns TRUE if the path is valid, FALSE otherwise */
1572 static BOOL
msi_dialog_onkillfocus( msi_dialog
*dialog
, msi_control
*control
)
1578 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
1579 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
1581 buf
= msi_get_window_text( control
->hwnd
);
1583 if ( !msi_dialog_verify_path( buf
) )
1585 /* FIXME: display an error message box */
1586 ERR("Invalid path %s\n", debugstr_w( buf
));
1588 SetFocus( control
->hwnd
);
1593 MSI_SetPropertyW( dialog
->package
, prop
, buf
);
1596 msi_dialog_update_pathedit( dialog
, control
);
1598 TRACE("edit %s contents changed, set %s\n", debugstr_w(control
->name
),
1607 static LRESULT WINAPI
MSIPathEdit_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1609 struct msi_pathedit_info
*info
= GetPropW(hWnd
, szButtonData
);
1612 TRACE("%p %04x %08lx %08lx\n", hWnd
, msg
, wParam
, lParam
);
1614 if ( msg
== WM_KILLFOCUS
)
1616 /* if the path is invalid, don't handle this message */
1617 if ( !msi_dialog_onkillfocus( info
->dialog
, info
->control
) )
1621 r
= CallWindowProcW(info
->oldproc
, hWnd
, msg
, wParam
, lParam
);
1623 if ( msg
== WM_NCDESTROY
)
1626 RemovePropW( hWnd
, szButtonData
);
1632 static UINT
msi_dialog_pathedit_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1634 struct msi_pathedit_info
*info
;
1635 msi_control
*control
;
1638 info
= msi_alloc( sizeof *info
);
1640 return ERROR_FUNCTION_FAILED
;
1642 control
= msi_dialog_add_control( dialog
, rec
, szEdit
,
1643 WS_BORDER
| WS_TABSTOP
);
1644 control
->attributes
= MSI_RecordGetInteger( rec
, 8 );
1645 prop
= MSI_RecordGetString( rec
, 9 );
1646 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
1648 info
->dialog
= dialog
;
1649 info
->control
= control
;
1650 info
->oldproc
= (WNDPROC
) SetWindowLongPtrW( control
->hwnd
, GWLP_WNDPROC
,
1651 (LONG_PTR
)MSIPathEdit_WndProc
);
1652 SetPropW( control
->hwnd
, szButtonData
, info
);
1654 msi_dialog_update_pathedit( dialog
, control
);
1656 return ERROR_SUCCESS
;
1659 /* radio buttons are a bit different from normal controls */
1660 static UINT
msi_dialog_create_radiobutton( MSIRECORD
*rec
, LPVOID param
)
1662 radio_button_group_descr
*group
= (radio_button_group_descr
*)param
;
1663 msi_dialog
*dialog
= group
->dialog
;
1664 msi_control
*control
;
1665 LPCWSTR prop
, text
, name
;
1666 DWORD style
, attributes
= group
->attributes
;
1668 style
= WS_CHILD
| BS_AUTORADIOBUTTON
| BS_MULTILINE
| WS_TABSTOP
;
1669 name
= MSI_RecordGetString( rec
, 3 );
1670 text
= MSI_RecordGetString( rec
, 8 );
1671 if( attributes
& msidbControlAttributesVisible
)
1672 style
|= WS_VISIBLE
;
1673 if( ~attributes
& msidbControlAttributesEnabled
)
1674 style
|= WS_DISABLED
;
1676 control
= msi_dialog_create_window( dialog
, rec
, 0, szButton
, name
, text
,
1677 style
, group
->parent
->hwnd
);
1679 return ERROR_FUNCTION_FAILED
;
1680 control
->handler
= msi_dialog_radiogroup_handler
;
1682 if (!lstrcmpW(control
->name
, group
->propval
))
1683 SendMessageW(control
->hwnd
, BM_SETCHECK
, BST_CHECKED
, 0);
1685 prop
= MSI_RecordGetString( rec
, 1 );
1687 control
->property
= strdupW( prop
);
1689 return ERROR_SUCCESS
;
1692 static UINT
msi_dialog_radiogroup_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1694 static const WCHAR query
[] = {
1695 'S','E','L','E','C','T',' ','*',' ',
1696 'F','R','O','M',' ','R','a','d','i','o','B','u','t','t','o','n',' ',
1697 'W','H','E','R','E',' ',
1698 '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
1701 msi_control
*control
;
1702 MSIQUERY
*view
= NULL
;
1703 radio_button_group_descr group
;
1704 MSIPACKAGE
*package
= dialog
->package
;
1707 prop
= MSI_RecordGetString( rec
, 9 );
1709 TRACE("%p %p %s\n", dialog
, rec
, debugstr_w( prop
));
1711 /* Create parent group box to hold radio buttons */
1712 control
= msi_dialog_add_control( dialog
, rec
, szButton
, BS_GROUPBOX
|WS_GROUP
);
1714 return ERROR_FUNCTION_FAILED
;
1716 oldproc
= (WNDPROC
) SetWindowLongPtrW( control
->hwnd
, GWLP_WNDPROC
,
1717 (LONG_PTR
)MSIRadioGroup_WndProc
);
1718 SetPropW(control
->hwnd
, szButtonData
, oldproc
);
1719 SetWindowLongPtrW( control
->hwnd
, GWL_EXSTYLE
, WS_EX_CONTROLPARENT
);
1722 control
->property
= strdupW( prop
);
1724 /* query the Radio Button table for all control in this group */
1725 r
= MSI_OpenQuery( package
->db
, &view
, query
, prop
);
1726 if( r
!= ERROR_SUCCESS
)
1728 ERR("query failed for dialog %s radio group %s\n",
1729 debugstr_w(dialog
->name
), debugstr_w(prop
));
1730 return ERROR_INVALID_PARAMETER
;
1733 group
.dialog
= dialog
;
1734 group
.parent
= control
;
1735 group
.attributes
= MSI_RecordGetInteger( rec
, 8 );
1736 group
.propval
= msi_dup_property( dialog
->package
, control
->property
);
1738 r
= MSI_IterateRecords( view
, 0, msi_dialog_create_radiobutton
, &group
);
1739 msiobj_release( &view
->hdr
);
1740 msi_free( group
.propval
);
1745 /******************** Selection Tree ***************************************/
1747 struct msi_selection_tree_info
1756 msi_seltree_sync_item_state( HWND hwnd
, MSIFEATURE
*feature
, HTREEITEM hItem
)
1759 DWORD index
= feature
->Action
;
1761 TRACE("Feature %s -> %d %d %d\n", debugstr_w(feature
->Title
),
1762 feature
->Installed
, feature
->Action
, feature
->ActionRequest
);
1764 if (index
== INSTALLSTATE_UNKNOWN
)
1765 index
= INSTALLSTATE_ABSENT
;
1767 tvi
.mask
= TVIF_STATE
;
1769 tvi
.state
= INDEXTOSTATEIMAGEMASK( index
);
1770 tvi
.stateMask
= TVIS_STATEIMAGEMASK
;
1772 SendMessageW( hwnd
, TVM_SETITEMW
, 0, (LPARAM
) &tvi
);
1776 msi_seltree_popup_menu( HWND hwnd
, INT x
, INT y
)
1781 /* create a menu to display */
1782 hMenu
= CreatePopupMenu();
1784 /* FIXME: load strings from resources */
1785 AppendMenuA( hMenu
, MF_ENABLED
, INSTALLSTATE_LOCAL
, "Install feature locally");
1786 AppendMenuA( hMenu
, MF_GRAYED
, 0x1000, "Install entire feature");
1787 AppendMenuA( hMenu
, MF_ENABLED
, INSTALLSTATE_ADVERTISED
, "Install on demand");
1788 AppendMenuA( hMenu
, MF_ENABLED
, INSTALLSTATE_ABSENT
, "Don't install");
1789 r
= TrackPopupMenu( hMenu
, TPM_LEFTALIGN
| TPM_TOPALIGN
| TPM_RETURNCMD
,
1790 x
, y
, 0, hwnd
, NULL
);
1791 DestroyMenu( hMenu
);
1796 msi_seltree_feature_from_item( HWND hwnd
, HTREEITEM hItem
)
1800 /* get the feature from the item */
1801 memset( &tvi
, 0, sizeof tvi
);
1803 tvi
.mask
= TVIF_PARAM
| TVIF_HANDLE
;
1804 SendMessageW( hwnd
, TVM_GETITEMW
, 0, (LPARAM
) &tvi
);
1806 return (MSIFEATURE
*) tvi
.lParam
;
1810 msi_seltree_menu( HWND hwnd
, HTREEITEM hItem
)
1812 struct msi_selection_tree_info
*info
;
1813 MSIFEATURE
*feature
;
1814 MSIPACKAGE
*package
;
1822 info
= GetPropW(hwnd
, szButtonData
);
1823 package
= info
->dialog
->package
;
1825 feature
= msi_seltree_feature_from_item( hwnd
, hItem
);
1828 ERR("item %p feature was NULL\n", hItem
);
1832 /* get the item's rectangle to put the menu just below it */
1834 SendMessageW( hwnd
, TVM_GETITEMRECT
, 0, (LPARAM
) &u
.rc
);
1835 MapWindowPoints( hwnd
, NULL
, u
.pt
, 2 );
1837 r
= msi_seltree_popup_menu( hwnd
, u
.rc
.left
, u
.rc
.top
);
1841 case INSTALLSTATE_LOCAL
:
1842 case INSTALLSTATE_ADVERTISED
:
1843 case INSTALLSTATE_ABSENT
:
1844 msi_feature_set_state( feature
, r
);
1847 FIXME("select feature and all children\n");
1851 msi_seltree_sync_item_state( hwnd
, feature
, hItem
);
1852 ACTION_UpdateComponentStates( package
, feature
->Feature
);
1857 static MSIFEATURE
*msi_seltree_get_selected_feature( msi_control
*control
)
1859 struct msi_selection_tree_info
*info
= GetPropW(control
->hwnd
, szButtonData
);
1860 return msi_seltree_feature_from_item( control
->hwnd
, info
->selected
);
1863 static LRESULT WINAPI
1864 MSISelectionTree_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1866 struct msi_selection_tree_info
*info
;
1867 TVHITTESTINFO tvhti
;
1870 TRACE("%p %04x %08lx %08lx\n", hWnd
, msg
, wParam
, lParam
);
1872 info
= GetPropW(hWnd
, szButtonData
);
1876 case WM_LBUTTONDOWN
:
1877 tvhti
.pt
.x
= (short)LOWORD( lParam
);
1878 tvhti
.pt
.y
= (short)HIWORD( lParam
);
1881 r
= CallWindowProcW(info
->oldproc
, hWnd
, TVM_HITTEST
, 0, (LPARAM
) &tvhti
);
1882 if (tvhti
.flags
& TVHT_ONITEMSTATEICON
)
1883 return msi_seltree_menu( hWnd
, tvhti
.hItem
);
1887 r
= CallWindowProcW(info
->oldproc
, hWnd
, msg
, wParam
, lParam
);
1893 RemovePropW( hWnd
, szButtonData
);
1900 msi_seltree_add_child_features( MSIPACKAGE
*package
, HWND hwnd
,
1901 LPCWSTR parent
, HTREEITEM hParent
)
1903 struct msi_selection_tree_info
*info
= GetPropW( hwnd
, szButtonData
);
1904 MSIFEATURE
*feature
;
1905 TVINSERTSTRUCTW tvis
;
1906 HTREEITEM hitem
, hfirst
= NULL
;
1908 LIST_FOR_EACH_ENTRY( feature
, &package
->features
, MSIFEATURE
, entry
)
1910 if ( lstrcmpW( parent
, feature
->Feature_Parent
) )
1913 if ( !feature
->Title
)
1916 if ( !feature
->Display
)
1919 memset( &tvis
, 0, sizeof tvis
);
1920 tvis
.hParent
= hParent
;
1921 tvis
.hInsertAfter
= TVI_LAST
;
1922 tvis
.u
.item
.mask
= TVIF_TEXT
| TVIF_PARAM
;
1923 tvis
.u
.item
.pszText
= feature
->Title
;
1924 tvis
.u
.item
.lParam
= (LPARAM
) feature
;
1926 hitem
= (HTREEITEM
) SendMessageW( hwnd
, TVM_INSERTITEMW
, 0, (LPARAM
) &tvis
);
1933 msi_seltree_sync_item_state( hwnd
, feature
, hitem
);
1934 msi_seltree_add_child_features( package
, hwnd
,
1935 feature
->Feature
, hitem
);
1937 /* the node is expanded if Display is odd */
1938 if ( feature
->Display
% 2 != 0 )
1939 SendMessageW( hwnd
, TVM_EXPAND
, TVE_EXPAND
, (LPARAM
) hitem
);
1942 /* select the first item */
1943 SendMessageW( hwnd
, TVM_SELECTITEM
, TVGN_CARET
| TVGN_DROPHILITE
, (LPARAM
) hfirst
);
1944 info
->selected
= hfirst
;
1947 static void msi_seltree_create_imagelist( HWND hwnd
)
1949 const int bm_width
= 32, bm_height
= 16, bm_count
= 3;
1950 const int bm_resource
= 0x1001;
1955 himl
= ImageList_Create( bm_width
, bm_height
, FALSE
, 4, 0 );
1958 ERR("failed to create image list\n");
1962 for (i
=0; i
<bm_count
; i
++)
1964 hbmp
= LoadBitmapW( msi_hInstance
, MAKEINTRESOURCEW(i
+bm_resource
) );
1967 ERR("failed to load bitmap %d\n", i
);
1972 * Add a dummy bitmap at offset zero because the treeview
1973 * can't use it as a state mask (zero means no user state).
1976 ImageList_Add( himl
, hbmp
, NULL
);
1978 ImageList_Add( himl
, hbmp
, NULL
);
1981 SendMessageW( hwnd
, TVM_SETIMAGELIST
, TVSIL_STATE
, (LPARAM
)himl
);
1984 static UINT
msi_dialog_seltree_handler( msi_dialog
*dialog
,
1985 msi_control
*control
, WPARAM param
)
1987 struct msi_selection_tree_info
*info
= GetPropW( control
->hwnd
, szButtonData
);
1988 LPNMTREEVIEWW tv
= (LPNMTREEVIEWW
)param
;
1989 MSIRECORD
*row
, *rec
;
1992 UINT r
= ERROR_SUCCESS
;
1994 static const WCHAR select
[] = {
1995 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
1996 '`','F','e','a','t','u','r','e','`',' ','W','H','E','R','E',' ',
1997 '`','T','i','t','l','e','`',' ','=',' ','\'','%','s','\'',0
2000 if (tv
->hdr
.code
!= TVN_SELCHANGINGW
)
2001 return ERROR_SUCCESS
;
2003 info
->selected
= tv
->itemNew
.hItem
;
2005 row
= MSI_QueryGetRecord( dialog
->package
->db
, select
, tv
->itemNew
.pszText
);
2007 return ERROR_FUNCTION_FAILED
;
2009 rec
= MSI_CreateRecord( 1 );
2011 MSI_RecordSetStringW( rec
, 1, MSI_RecordGetString( row
, 4 ) );
2012 ControlEvent_FireSubscribedEvent( dialog
->package
, szSelectionDescription
, rec
);
2014 dir
= MSI_RecordGetString( row
, 7 );
2015 folder
= get_loaded_folder( dialog
->package
, dir
);
2018 r
= ERROR_FUNCTION_FAILED
;
2022 MSI_RecordSetStringW( rec
, 1, folder
->ResolvedTarget
);
2023 ControlEvent_FireSubscribedEvent( dialog
->package
, szSelectionPath
, rec
);
2026 msiobj_release(&row
->hdr
);
2027 msiobj_release(&rec
->hdr
);
2032 static UINT
msi_dialog_selection_tree( msi_dialog
*dialog
, MSIRECORD
*rec
)
2034 msi_control
*control
;
2036 MSIPACKAGE
*package
= dialog
->package
;
2038 struct msi_selection_tree_info
*info
;
2040 info
= msi_alloc( sizeof *info
);
2042 return ERROR_FUNCTION_FAILED
;
2044 /* create the treeview control */
2045 style
= TVS_HASLINES
| TVS_HASBUTTONS
| TVS_LINESATROOT
;
2046 style
|= WS_GROUP
| WS_VSCROLL
;
2047 control
= msi_dialog_add_control( dialog
, rec
, WC_TREEVIEWW
, style
);
2051 return ERROR_FUNCTION_FAILED
;
2054 control
->handler
= msi_dialog_seltree_handler
;
2055 control
->attributes
= MSI_RecordGetInteger( rec
, 8 );
2056 prop
= MSI_RecordGetString( rec
, 9 );
2057 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
2060 info
->dialog
= dialog
;
2061 info
->hwnd
= control
->hwnd
;
2062 info
->oldproc
= (WNDPROC
) SetWindowLongPtrW( control
->hwnd
, GWLP_WNDPROC
,
2063 (LONG_PTR
)MSISelectionTree_WndProc
);
2064 SetPropW( control
->hwnd
, szButtonData
, info
);
2066 ControlEvent_SubscribeToEvent( dialog
->package
, dialog
,
2067 szSelectionPath
, control
->name
, szProperty
);
2070 msi_seltree_create_imagelist( control
->hwnd
);
2071 msi_seltree_add_child_features( package
, control
->hwnd
, NULL
, NULL
);
2073 return ERROR_SUCCESS
;
2076 /******************** Group Box ***************************************/
2078 static UINT
msi_dialog_group_box( msi_dialog
*dialog
, MSIRECORD
*rec
)
2080 msi_control
*control
;
2083 style
= BS_GROUPBOX
| WS_CHILD
| WS_GROUP
;
2084 control
= msi_dialog_add_control( dialog
, rec
, WC_BUTTONW
, style
);
2086 return ERROR_FUNCTION_FAILED
;
2088 return ERROR_SUCCESS
;
2091 /******************** List Box ***************************************/
2093 struct msi_listbox_info
2103 static LRESULT WINAPI
MSIListBox_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
2105 struct msi_listbox_info
*info
;
2109 TRACE("%p %04x %08lx %08lx\n", hWnd
, msg
, wParam
, lParam
);
2111 info
= GetPropW( hWnd
, szButtonData
);
2115 r
= CallWindowProcW( info
->oldproc
, hWnd
, msg
, wParam
, lParam
);
2120 for (j
= 0; j
< info
->num_items
; j
++)
2121 msi_free( info
->items
[j
] );
2122 msi_free( info
->items
);
2124 RemovePropW( hWnd
, szButtonData
);
2131 static UINT
msi_listbox_add_item( MSIRECORD
*rec
, LPVOID param
)
2133 struct msi_listbox_info
*info
= param
;
2134 LPCWSTR value
, text
;
2137 value
= MSI_RecordGetString( rec
, 3 );
2138 text
= MSI_RecordGetString( rec
, 4 );
2140 info
->items
[info
->addpos_items
] = strdupW( value
);
2142 pos
= SendMessageW( info
->hwnd
, LB_ADDSTRING
, 0, (LPARAM
)text
);
2143 SendMessageW( info
->hwnd
, LB_SETITEMDATA
, pos
, (LPARAM
)info
->items
[info
->addpos_items
] );
2144 info
->addpos_items
++;
2145 return ERROR_SUCCESS
;
2148 static UINT
msi_listbox_add_items( struct msi_listbox_info
*info
, LPCWSTR property
)
2151 MSIQUERY
*view
= NULL
;
2154 static const WCHAR query
[] = {
2155 'S','E','L','E','C','T',' ','*',' ',
2156 'F','R','O','M',' ','`','L','i','s','t','B','o','x','`',' ',
2157 'W','H','E','R','E',' ',
2158 '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',' ',
2159 'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','`',0
2162 r
= MSI_OpenQuery( info
->dialog
->package
->db
, &view
, query
, property
);
2163 if ( r
!= ERROR_SUCCESS
)
2166 /* just get the number of records */
2167 r
= MSI_IterateRecords( view
, &count
, NULL
, NULL
);
2169 info
->num_items
= count
;
2170 info
->items
= msi_alloc( sizeof(*info
->items
) * count
);
2172 r
= MSI_IterateRecords( view
, NULL
, msi_listbox_add_item
, info
);
2173 msiobj_release( &view
->hdr
);
2178 static UINT
msi_dialog_listbox_handler( msi_dialog
*dialog
,
2179 msi_control
*control
, WPARAM param
)
2181 struct msi_listbox_info
*info
;
2185 if( HIWORD(param
) != LBN_SELCHANGE
)
2186 return ERROR_SUCCESS
;
2188 info
= GetPropW( control
->hwnd
, szButtonData
);
2189 index
= SendMessageW( control
->hwnd
, LB_GETCURSEL
, 0, 0 );
2190 value
= (LPCWSTR
) SendMessageW( control
->hwnd
, LB_GETITEMDATA
, index
, 0 );
2192 MSI_SetPropertyW( info
->dialog
->package
,
2193 control
->property
, value
);
2194 msi_dialog_evaluate_control_conditions( info
->dialog
);
2196 return ERROR_SUCCESS
;
2199 static UINT
msi_dialog_list_box( msi_dialog
*dialog
, MSIRECORD
*rec
)
2201 struct msi_listbox_info
*info
;
2202 msi_control
*control
;
2203 DWORD attributes
, style
;
2206 info
= msi_alloc( sizeof *info
);
2208 return ERROR_FUNCTION_FAILED
;
2210 style
= WS_TABSTOP
| WS_GROUP
| WS_CHILD
| LBS_NOTIFY
| WS_VSCROLL
| WS_BORDER
;
2211 attributes
= MSI_RecordGetInteger( rec
, 8 );
2212 if (~attributes
& msidbControlAttributesSorted
)
2215 control
= msi_dialog_add_control( dialog
, rec
, WC_LISTBOXW
, style
);
2217 return ERROR_FUNCTION_FAILED
;
2219 control
->handler
= msi_dialog_listbox_handler
;
2221 prop
= MSI_RecordGetString( rec
, 9 );
2222 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
2225 info
->dialog
= dialog
;
2226 info
->hwnd
= control
->hwnd
;
2228 info
->addpos_items
= 0;
2229 info
->oldproc
= (WNDPROC
)SetWindowLongPtrW( control
->hwnd
, GWLP_WNDPROC
,
2230 (LONG_PTR
)MSIListBox_WndProc
);
2231 SetPropW( control
->hwnd
, szButtonData
, info
);
2233 if ( control
->property
)
2234 msi_listbox_add_items( info
, control
->property
);
2236 return ERROR_SUCCESS
;
2239 /******************** Directory Combo ***************************************/
2241 static void msi_dialog_update_directory_combo( msi_dialog
*dialog
, msi_control
*control
)
2246 if (!control
&& !(control
= msi_dialog_find_control_by_type( dialog
, szDirectoryCombo
)))
2249 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
2250 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
2251 path
= msi_dialog_dup_property( dialog
, prop
, TRUE
);
2253 PathStripPathW( path
);
2254 PathRemoveBackslashW( path
);
2256 SendMessageW( control
->hwnd
, CB_INSERTSTRING
, 0, (LPARAM
)path
);
2257 SendMessageW( control
->hwnd
, CB_SETCURSEL
, 0, 0 );
2263 static UINT
msi_dialog_directory_combo( msi_dialog
*dialog
, MSIRECORD
*rec
)
2265 msi_control
*control
;
2269 /* FIXME: use CBS_OWNERDRAWFIXED and add owner draw code */
2270 style
= CBS_DROPDOWNLIST
| CBS_HASSTRINGS
| WS_CHILD
|
2271 WS_GROUP
| WS_TABSTOP
| WS_VSCROLL
;
2272 control
= msi_dialog_add_control( dialog
, rec
, WC_COMBOBOXW
, style
);
2274 return ERROR_FUNCTION_FAILED
;
2276 control
->attributes
= MSI_RecordGetInteger( rec
, 8 );
2277 prop
= MSI_RecordGetString( rec
, 9 );
2278 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
2280 msi_dialog_update_directory_combo( dialog
, control
);
2282 return ERROR_SUCCESS
;
2285 /******************** Directory List ***************************************/
2287 static void msi_dialog_update_directory_list( msi_dialog
*dialog
, msi_control
*control
)
2289 WCHAR dir_spec
[MAX_PATH
];
2290 WIN32_FIND_DATAW wfd
;
2296 static const WCHAR asterisk
[] = {'*',0};
2297 static const WCHAR dot
[] = {'.',0};
2298 static const WCHAR dotdot
[] = {'.','.',0};
2300 if (!control
&& !(control
= msi_dialog_find_control_by_type( dialog
, szDirectoryList
)))
2303 /* clear the list-view */
2304 SendMessageW( control
->hwnd
, LVM_DELETEALLITEMS
, 0, 0 );
2306 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
2307 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
2308 path
= msi_dialog_dup_property( dialog
, prop
, TRUE
);
2310 lstrcpyW( dir_spec
, path
);
2311 lstrcatW( dir_spec
, asterisk
);
2313 file
= FindFirstFileW( dir_spec
, &wfd
);
2314 if ( file
== INVALID_HANDLE_VALUE
)
2319 if ( wfd
.dwFileAttributes
!= FILE_ATTRIBUTE_DIRECTORY
)
2322 if ( !lstrcmpW( wfd
.cFileName
, dot
) || !lstrcmpW( wfd
.cFileName
, dotdot
) )
2325 item
.mask
= LVIF_TEXT
;
2326 item
.cchTextMax
= MAX_PATH
;
2329 item
.pszText
= wfd
.cFileName
;
2331 SendMessageW( control
->hwnd
, LVM_INSERTITEMW
, 0, (LPARAM
)&item
);
2332 } while ( FindNextFileW( file
, &wfd
) );
2339 UINT
msi_dialog_directorylist_up( msi_dialog
*dialog
)
2341 msi_control
*control
;
2342 LPWSTR prop
, path
, ptr
;
2345 control
= msi_dialog_find_control_by_type( dialog
, szDirectoryList
);
2346 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
2347 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
2348 path
= msi_dialog_dup_property( dialog
, prop
, TRUE
);
2350 /* strip off the last directory */
2351 ptr
= PathFindFileNameW( path
);
2352 if (ptr
!= path
) *(ptr
- 1) = '\0';
2353 PathAddBackslashW( path
);
2355 MSI_SetPropertyW( dialog
->package
, prop
, path
);
2357 msi_dialog_update_directory_list( dialog
, NULL
);
2358 msi_dialog_update_directory_combo( dialog
, NULL
);
2359 msi_dialog_update_pathedit( dialog
, NULL
);
2364 return ERROR_SUCCESS
;
2367 static UINT
msi_dialog_dirlist_handler( msi_dialog
*dialog
,
2368 msi_control
*control
, WPARAM param
)
2370 LPNMHDR nmhdr
= (LPNMHDR
)param
;
2371 WCHAR new_path
[MAX_PATH
];
2372 WCHAR text
[MAX_PATH
];
2378 static const WCHAR backslash
[] = {'\\',0};
2380 if (nmhdr
->code
!= LVN_ITEMACTIVATE
)
2381 return ERROR_SUCCESS
;
2383 index
= SendMessageW( control
->hwnd
, LVM_GETNEXTITEM
, -1, LVNI_SELECTED
);
2386 ERR("No list-view item selected!\n");
2387 return ERROR_FUNCTION_FAILED
;
2391 item
.pszText
= text
;
2392 item
.cchTextMax
= MAX_PATH
;
2393 SendMessageW( control
->hwnd
, LVM_GETITEMTEXTW
, index
, (LPARAM
)&item
);
2395 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
2396 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
2397 path
= msi_dialog_dup_property( dialog
, prop
, TRUE
);
2399 lstrcpyW( new_path
, path
);
2400 lstrcatW( new_path
, text
);
2401 lstrcatW( new_path
, backslash
);
2403 MSI_SetPropertyW( dialog
->package
, prop
, new_path
);
2405 msi_dialog_update_directory_list( dialog
, NULL
);
2406 msi_dialog_update_directory_combo( dialog
, NULL
);
2407 msi_dialog_update_pathedit( dialog
, NULL
);
2411 return ERROR_SUCCESS
;
2414 static UINT
msi_dialog_directory_list( msi_dialog
*dialog
, MSIRECORD
*rec
)
2416 msi_control
*control
;
2420 style
= LVS_LIST
| WS_VSCROLL
| LVS_SHAREIMAGELISTS
|
2421 LVS_AUTOARRANGE
| LVS_SINGLESEL
| WS_BORDER
|
2422 LVS_SORTASCENDING
| WS_CHILD
| WS_GROUP
| WS_TABSTOP
;
2423 control
= msi_dialog_add_control( dialog
, rec
, WC_LISTVIEWW
, style
);
2425 return ERROR_FUNCTION_FAILED
;
2427 control
->attributes
= MSI_RecordGetInteger( rec
, 8 );
2428 control
->handler
= msi_dialog_dirlist_handler
;
2429 prop
= MSI_RecordGetString( rec
, 9 );
2430 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
2432 /* double click to activate an item in the list */
2433 SendMessageW( control
->hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
,
2434 0, LVS_EX_TWOCLICKACTIVATE
);
2436 msi_dialog_update_directory_list( dialog
, control
);
2438 return ERROR_SUCCESS
;
2441 /******************** VolumeCost List ***************************************/
2443 static BOOL
str_is_number( LPCWSTR str
)
2447 for (i
= 0; i
< lstrlenW( str
); i
++)
2448 if (!isdigitW(str
[i
]))
2454 static const WCHAR column_keys
[][80] =
2456 {'V','o','l','u','m','e','C','o','s','t','V','o','l','u','m','e',0},
2457 {'V','o','l','u','m','e','C','o','s','t','S','i','z','e',0},
2458 {'V','o','l','u','m','e','C','o','s','t','A','v','a','i','l','a','b','l','e',0},
2459 {'V','o','l','u','m','e','C','o','s','t','R','e','q','u','i','r','e','d',0},
2460 {'V','o','l','u','m','e','C','o','s','t','D','i','f','f','e','r','e','n','c','e',0}
2463 static void msi_dialog_vcl_add_columns( msi_dialog
*dialog
, msi_control
*control
, MSIRECORD
*rec
)
2465 LPCWSTR text
= MSI_RecordGetString( rec
, 10 );
2466 LPCWSTR begin
= text
, end
;
2471 static const WCHAR zero
[] = {'0',0};
2472 static const WCHAR negative
[] = {'-',0};
2476 while ((begin
= strchrW( begin
, '{' )) && count
< 5)
2478 if (!(end
= strchrW( begin
, '}' )))
2481 lstrcpynW( num
, begin
+ 1, end
- begin
);
2482 begin
+= end
- begin
+ 1;
2484 /* empty braces or '0' hides the column */
2485 if ( !num
[0] || !lstrcmpW( num
, zero
) )
2491 /* the width must be a positive number
2492 * if a width is invalid, all remaining columns are hidden
2494 if ( !strncmpW( num
, negative
, 1 ) || !str_is_number( num
) )
2497 ZeroMemory( &lvc
, sizeof(lvc
) );
2498 lvc
.mask
= LVCF_TEXT
| LVCF_WIDTH
| LVCF_SUBITEM
;
2499 lvc
.cx
= atolW( num
);
2500 lvc
.pszText
= msi_dialog_get_uitext( dialog
, column_keys
[count
] );
2502 SendMessageW( control
->hwnd
, LVM_INSERTCOLUMNW
, count
++, (LPARAM
)&lvc
);
2503 msi_free( lvc
.pszText
);
2507 static void msi_dialog_vcl_add_drives( msi_dialog
*dialog
, msi_control
*control
)
2509 ULARGE_INTEGER total
, free
;
2510 WCHAR size_text
[MAX_PATH
];
2516 size
= GetLogicalDriveStringsW( 0, NULL
);
2517 if ( !size
) return;
2519 drives
= msi_alloc( (size
+ 1) * sizeof(WCHAR
) );
2520 if ( !drives
) return;
2522 GetLogicalDriveStringsW( size
, drives
);
2527 lvitem
.mask
= LVIF_TEXT
;
2529 lvitem
.iSubItem
= 0;
2530 lvitem
.pszText
= ptr
;
2531 lvitem
.cchTextMax
= lstrlenW(ptr
) + 1;
2532 SendMessageW( control
->hwnd
, LVM_INSERTITEMW
, 0, (LPARAM
)&lvitem
);
2534 GetDiskFreeSpaceExW(ptr
, &free
, &total
, NULL
);
2536 StrFormatByteSizeW(total
.QuadPart
, size_text
, MAX_PATH
);
2537 lvitem
.iSubItem
= 1;
2538 lvitem
.pszText
= size_text
;
2539 lvitem
.cchTextMax
= lstrlenW(size_text
) + 1;
2540 SendMessageW( control
->hwnd
, LVM_SETITEMW
, 0, (LPARAM
)&lvitem
);
2542 StrFormatByteSizeW(free
.QuadPart
, size_text
, MAX_PATH
);
2543 lvitem
.iSubItem
= 2;
2544 lvitem
.pszText
= size_text
;
2545 lvitem
.cchTextMax
= lstrlenW(size_text
) + 1;
2546 SendMessageW( control
->hwnd
, LVM_SETITEMW
, 0, (LPARAM
)&lvitem
);
2548 ptr
+= lstrlenW(ptr
) + 1;
2555 static UINT
msi_dialog_volumecost_list( msi_dialog
*dialog
, MSIRECORD
*rec
)
2557 msi_control
*control
;
2560 style
= LVS_REPORT
| WS_VSCROLL
| WS_HSCROLL
| LVS_SHAREIMAGELISTS
|
2561 LVS_AUTOARRANGE
| LVS_SINGLESEL
| WS_BORDER
|
2562 WS_CHILD
| WS_TABSTOP
| WS_GROUP
;
2563 control
= msi_dialog_add_control( dialog
, rec
, WC_LISTVIEWW
, style
);
2565 return ERROR_FUNCTION_FAILED
;
2567 msi_dialog_vcl_add_columns( dialog
, control
, rec
);
2568 msi_dialog_vcl_add_drives( dialog
, control
);
2570 return ERROR_SUCCESS
;
2573 /******************** VolumeSelect Combo ***************************************/
2575 static UINT
msi_dialog_volsel_handler( msi_dialog
*dialog
,
2576 msi_control
*control
, WPARAM param
)
2578 WCHAR text
[MAX_PATH
];
2583 if (HIWORD(param
) != CBN_SELCHANGE
)
2584 return ERROR_SUCCESS
;
2586 index
= SendMessageW( control
->hwnd
, CB_GETCURSEL
, 0, 0 );
2587 if ( index
== CB_ERR
)
2589 ERR("No ComboBox item selected!\n");
2590 return ERROR_FUNCTION_FAILED
;
2593 SendMessageW( control
->hwnd
, CB_GETLBTEXT
, index
, (LPARAM
)text
);
2595 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
2596 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
2598 MSI_SetPropertyW( dialog
->package
, prop
, text
);
2601 return ERROR_SUCCESS
;
2604 static void msi_dialog_vsc_add_drives( msi_dialog
*dialog
, msi_control
*control
)
2609 size
= GetLogicalDriveStringsW( 0, NULL
);
2610 if ( !size
) return;
2612 drives
= msi_alloc( (size
+ 1) * sizeof(WCHAR
) );
2613 if ( !drives
) return;
2615 GetLogicalDriveStringsW( size
, drives
);
2620 SendMessageW( control
->hwnd
, CB_ADDSTRING
, 0, (LPARAM
)ptr
);
2621 ptr
+= lstrlenW(ptr
) + 1;
2627 static UINT
msi_dialog_volumeselect_combo( msi_dialog
*dialog
, MSIRECORD
*rec
)
2629 msi_control
*control
;
2633 /* FIXME: CBS_OWNERDRAWFIXED */
2634 style
= WS_CHILD
| WS_VISIBLE
| WS_GROUP
| WS_TABSTOP
|
2635 CBS_DROPDOWNLIST
| CBS_SORT
| CBS_HASSTRINGS
|
2636 WS_EX_LEFT
| WS_EX_LTRREADING
| WS_EX_RIGHTSCROLLBAR
;
2637 control
= msi_dialog_add_control( dialog
, rec
, WC_COMBOBOXW
, style
);
2639 return ERROR_FUNCTION_FAILED
;
2641 control
->attributes
= MSI_RecordGetInteger( rec
, 8 );
2642 control
->handler
= msi_dialog_volsel_handler
;
2643 prop
= MSI_RecordGetString( rec
, 9 );
2644 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
2646 msi_dialog_vsc_add_drives( dialog
, control
);
2648 return ERROR_SUCCESS
;
2651 static const struct control_handler msi_dialog_handler
[] =
2653 { szText
, msi_dialog_text_control
},
2654 { szPushButton
, msi_dialog_button_control
},
2655 { szLine
, msi_dialog_line_control
},
2656 { szBitmap
, msi_dialog_bitmap_control
},
2657 { szCheckBox
, msi_dialog_checkbox_control
},
2658 { szScrollableText
, msi_dialog_scrolltext_control
},
2659 { szComboBox
, msi_dialog_combo_control
},
2660 { szEdit
, msi_dialog_edit_control
},
2661 { szMaskedEdit
, msi_dialog_maskedit_control
},
2662 { szPathEdit
, msi_dialog_pathedit_control
},
2663 { szProgressBar
, msi_dialog_progress_bar
},
2664 { szRadioButtonGroup
, msi_dialog_radiogroup_control
},
2665 { szIcon
, msi_dialog_icon_control
},
2666 { szSelectionTree
, msi_dialog_selection_tree
},
2667 { szGroupBox
, msi_dialog_group_box
},
2668 { szListBox
, msi_dialog_list_box
},
2669 { szDirectoryCombo
, msi_dialog_directory_combo
},
2670 { szDirectoryList
, msi_dialog_directory_list
},
2671 { szVolumeCostList
, msi_dialog_volumecost_list
},
2672 { szVolumeSelectCombo
, msi_dialog_volumeselect_combo
},
2675 #define NUM_CONTROL_TYPES (sizeof msi_dialog_handler/sizeof msi_dialog_handler[0])
2677 static UINT
msi_dialog_create_controls( MSIRECORD
*rec
, LPVOID param
)
2679 msi_dialog
*dialog
= param
;
2680 LPCWSTR control_type
;
2683 /* find and call the function that can create this type of control */
2684 control_type
= MSI_RecordGetString( rec
, 3 );
2685 for( i
=0; i
<NUM_CONTROL_TYPES
; i
++ )
2686 if (!strcmpiW( msi_dialog_handler
[i
].control_type
, control_type
))
2688 if( i
!= NUM_CONTROL_TYPES
)
2689 msi_dialog_handler
[i
].func( dialog
, rec
);
2691 ERR("no handler for element type %s\n", debugstr_w(control_type
));
2693 return ERROR_SUCCESS
;
2696 static UINT
msi_dialog_fill_controls( msi_dialog
*dialog
)
2698 static const WCHAR query
[] = {
2699 'S','E','L','E','C','T',' ','*',' ',
2700 'F','R','O','M',' ','C','o','n','t','r','o','l',' ',
2701 'W','H','E','R','E',' ',
2702 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0};
2704 MSIQUERY
*view
= NULL
;
2705 MSIPACKAGE
*package
= dialog
->package
;
2707 TRACE("%p %s\n", dialog
, debugstr_w(dialog
->name
) );
2709 /* query the Control table for all the elements of the control */
2710 r
= MSI_OpenQuery( package
->db
, &view
, query
, dialog
->name
);
2711 if( r
!= ERROR_SUCCESS
)
2713 ERR("query failed for dialog %s\n", debugstr_w(dialog
->name
));
2714 return ERROR_INVALID_PARAMETER
;
2717 r
= MSI_IterateRecords( view
, 0, msi_dialog_create_controls
, dialog
);
2718 msiobj_release( &view
->hdr
);
2723 static UINT
msi_dialog_set_control_condition( MSIRECORD
*rec
, LPVOID param
)
2725 static const WCHAR szHide
[] = { 'H','i','d','e',0 };
2726 static const WCHAR szShow
[] = { 'S','h','o','w',0 };
2727 static const WCHAR szDisable
[] = { 'D','i','s','a','b','l','e',0 };
2728 static const WCHAR szEnable
[] = { 'E','n','a','b','l','e',0 };
2729 static const WCHAR szDefault
[] = { 'D','e','f','a','u','l','t',0 };
2730 msi_dialog
*dialog
= param
;
2731 msi_control
*control
;
2732 LPCWSTR name
, action
, condition
;
2735 name
= MSI_RecordGetString( rec
, 2 );
2736 action
= MSI_RecordGetString( rec
, 3 );
2737 condition
= MSI_RecordGetString( rec
, 4 );
2738 r
= MSI_EvaluateConditionW( dialog
->package
, condition
);
2739 control
= msi_dialog_find_control( dialog
, name
);
2740 if( r
== MSICONDITION_TRUE
&& control
)
2742 TRACE("%s control %s\n", debugstr_w(action
), debugstr_w(name
));
2744 /* FIXME: case sensitive? */
2745 if(!lstrcmpW(action
, szHide
))
2746 ShowWindow(control
->hwnd
, SW_HIDE
);
2747 else if(!strcmpW(action
, szShow
))
2748 ShowWindow(control
->hwnd
, SW_SHOW
);
2749 else if(!strcmpW(action
, szDisable
))
2750 EnableWindow(control
->hwnd
, FALSE
);
2751 else if(!strcmpW(action
, szEnable
))
2752 EnableWindow(control
->hwnd
, TRUE
);
2753 else if(!strcmpW(action
, szDefault
))
2754 SetFocus(control
->hwnd
);
2756 FIXME("Unhandled action %s\n", debugstr_w(action
));
2759 return ERROR_SUCCESS
;
2762 static UINT
msi_dialog_evaluate_control_conditions( msi_dialog
*dialog
)
2764 static const WCHAR query
[] = {
2765 'S','E','L','E','C','T',' ','*',' ',
2766 'F','R','O','M',' ',
2767 'C','o','n','t','r','o','l','C','o','n','d','i','t','i','o','n',' ',
2768 'W','H','E','R','E',' ',
2769 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0
2772 MSIQUERY
*view
= NULL
;
2773 MSIPACKAGE
*package
= dialog
->package
;
2775 TRACE("%p %s\n", dialog
, debugstr_w(dialog
->name
) );
2777 /* query the Control table for all the elements of the control */
2778 r
= MSI_OpenQuery( package
->db
, &view
, query
, dialog
->name
);
2779 if( r
!= ERROR_SUCCESS
)
2780 return ERROR_SUCCESS
;
2782 r
= MSI_IterateRecords( view
, 0, msi_dialog_set_control_condition
, dialog
);
2783 msiobj_release( &view
->hdr
);
2788 UINT
msi_dialog_reset( msi_dialog
*dialog
)
2790 /* FIXME: should restore the original values of any properties we changed */
2791 return msi_dialog_evaluate_control_conditions( dialog
);
2794 /* figure out the height of 10 point MS Sans Serif */
2795 static INT
msi_dialog_get_sans_serif_height( HWND hwnd
)
2797 static const WCHAR szSansSerif
[] = {
2798 'M','S',' ','S','a','n','s',' ','S','e','r','i','f',0 };
2803 HFONT hFont
, hOldFont
;
2806 hdc
= GetDC( hwnd
);
2809 memset( &lf
, 0, sizeof lf
);
2810 lf
.lfHeight
= MulDiv(10, GetDeviceCaps(hdc
, LOGPIXELSY
), 72);
2811 strcpyW( lf
.lfFaceName
, szSansSerif
);
2812 hFont
= CreateFontIndirectW(&lf
);
2815 hOldFont
= SelectObject( hdc
, hFont
);
2816 r
= GetTextMetricsW( hdc
, &tm
);
2818 height
= tm
.tmHeight
;
2819 SelectObject( hdc
, hOldFont
);
2820 DeleteObject( hFont
);
2822 ReleaseDC( hwnd
, hdc
);
2827 /* fetch the associated record from the Dialog table */
2828 static MSIRECORD
*msi_get_dialog_record( msi_dialog
*dialog
)
2830 static const WCHAR query
[] = {
2831 'S','E','L','E','C','T',' ','*',' ',
2832 'F','R','O','M',' ','D','i','a','l','o','g',' ',
2833 'W','H','E','R','E',' ',
2834 '`','D','i','a','l','o','g','`',' ','=',' ','\'','%','s','\'',0};
2835 MSIPACKAGE
*package
= dialog
->package
;
2836 MSIRECORD
*rec
= NULL
;
2838 TRACE("%p %s\n", dialog
, debugstr_w(dialog
->name
) );
2840 rec
= MSI_QueryGetRecord( package
->db
, query
, dialog
->name
);
2842 ERR("query failed for dialog %s\n", debugstr_w(dialog
->name
));
2847 static void msi_dialog_adjust_dialog_pos( msi_dialog
*dialog
, MSIRECORD
*rec
, LPRECT pos
)
2849 static const WCHAR szScreenX
[] = {'S','c','r','e','e','n','X',0};
2850 static const WCHAR szScreenY
[] = {'S','c','r','e','e','n','Y',0};
2857 center
.x
= MSI_RecordGetInteger( rec
, 2 );
2858 center
.y
= MSI_RecordGetInteger( rec
, 3 );
2860 sz
.cx
= MSI_RecordGetInteger( rec
, 4 );
2861 sz
.cy
= MSI_RecordGetInteger( rec
, 5 );
2863 sz
.cx
= msi_dialog_scale_unit( dialog
, sz
.cx
);
2864 sz
.cy
= msi_dialog_scale_unit( dialog
, sz
.cy
);
2866 xres
= msi_get_property_int( dialog
->package
, szScreenX
, 0 );
2867 yres
= msi_get_property_int( dialog
->package
, szScreenY
, 0 );
2869 center
.x
= MulDiv( center
.x
, xres
, 100 );
2870 center
.y
= MulDiv( center
.y
, yres
, 100 );
2872 /* turn the client pos into the window rectangle */
2873 if (dialog
->package
->center_x
&& dialog
->package
->center_y
)
2875 pos
->left
= dialog
->package
->center_x
- sz
.cx
/ 2.0;
2876 pos
->right
= pos
->left
+ sz
.cx
;
2877 pos
->top
= dialog
->package
->center_y
- sz
.cy
/ 2.0;
2878 pos
->bottom
= pos
->top
+ sz
.cy
;
2882 pos
->left
= center
.x
- sz
.cx
/2;
2883 pos
->right
= pos
->left
+ sz
.cx
;
2884 pos
->top
= center
.y
- sz
.cy
/2;
2885 pos
->bottom
= pos
->top
+ sz
.cy
;
2887 /* save the center */
2888 dialog
->package
->center_x
= center
.x
;
2889 dialog
->package
->center_y
= center
.y
;
2892 dialog
->size
.cx
= sz
.cx
;
2893 dialog
->size
.cy
= sz
.cy
;
2895 TRACE("%u %u %u %u\n", pos
->left
, pos
->top
, pos
->right
, pos
->bottom
);
2897 style
= GetWindowLongPtrW( dialog
->hwnd
, GWL_STYLE
);
2898 AdjustWindowRect( pos
, style
, FALSE
);
2901 static BOOL
msi_control_set_next( msi_control
*control
, msi_control
*next
)
2903 return SetWindowPos( next
->hwnd
, control
->hwnd
, 0, 0, 0, 0,
2904 SWP_NOMOVE
| SWP_NOOWNERZORDER
| SWP_NOREDRAW
|
2905 SWP_NOREPOSITION
| SWP_NOSENDCHANGING
| SWP_NOSIZE
);
2908 static UINT
msi_dialog_set_tab_order( msi_dialog
*dialog
)
2910 msi_control
*control
, *tab_next
;
2912 LIST_FOR_EACH_ENTRY( control
, &dialog
->controls
, msi_control
, entry
)
2914 tab_next
= msi_dialog_find_control( dialog
, control
->tabnext
);
2917 msi_control_set_next( control
, tab_next
);
2920 return ERROR_SUCCESS
;
2923 static void msi_dialog_set_first_control( msi_dialog
* dialog
, LPCWSTR name
)
2925 msi_control
*control
;
2927 control
= msi_dialog_find_control( dialog
, name
);
2929 dialog
->hWndFocus
= control
->hwnd
;
2931 dialog
->hWndFocus
= NULL
;
2934 static LRESULT
msi_dialog_oncreate( HWND hwnd
, LPCREATESTRUCTW cs
)
2936 static const WCHAR df
[] = {
2937 'D','e','f','a','u','l','t','U','I','F','o','n','t',0 };
2938 static const WCHAR dfv
[] = {
2939 'M','S',' ','S','h','e','l','l',' ','D','l','g',0 };
2940 msi_dialog
*dialog
= (msi_dialog
*) cs
->lpCreateParams
;
2941 MSIRECORD
*rec
= NULL
;
2942 LPWSTR title
= NULL
;
2945 TRACE("%p %p\n", dialog
, dialog
->package
);
2947 dialog
->hwnd
= hwnd
;
2948 SetWindowLongPtrW( hwnd
, GWLP_USERDATA
, (LONG_PTR
) dialog
);
2950 rec
= msi_get_dialog_record( dialog
);
2953 TRACE("No record found for dialog %s\n", debugstr_w(dialog
->name
));
2957 dialog
->scale
= msi_dialog_get_sans_serif_height(dialog
->hwnd
);
2959 msi_dialog_adjust_dialog_pos( dialog
, rec
, &pos
);
2961 dialog
->attributes
= MSI_RecordGetInteger( rec
, 6 );
2963 dialog
->default_font
= msi_dup_property( dialog
->package
, df
);
2964 if (!dialog
->default_font
)
2966 dialog
->default_font
= strdupW(dfv
);
2967 if (!dialog
->default_font
) return -1;
2970 title
= msi_get_deformatted_field( dialog
->package
, rec
, 7 );
2971 SetWindowTextW( hwnd
, title
);
2974 SetWindowPos( hwnd
, 0, pos
.left
, pos
.top
,
2975 pos
.right
- pos
.left
, pos
.bottom
- pos
.top
,
2976 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_NOREDRAW
);
2978 msi_dialog_build_font_list( dialog
);
2979 msi_dialog_fill_controls( dialog
);
2980 msi_dialog_evaluate_control_conditions( dialog
);
2981 msi_dialog_set_tab_order( dialog
);
2982 msi_dialog_set_first_control( dialog
, MSI_RecordGetString( rec
, 8 ) );
2983 msiobj_release( &rec
->hdr
);
2988 static UINT
msi_dialog_send_event( msi_dialog
*dialog
, LPCWSTR event
, LPCWSTR arg
)
2990 LPWSTR event_fmt
= NULL
, arg_fmt
= NULL
;
2992 TRACE("Sending control event %s %s\n", debugstr_w(event
), debugstr_w(arg
));
2994 deformat_string( dialog
->package
, event
, &event_fmt
);
2995 deformat_string( dialog
->package
, arg
, &arg_fmt
);
2997 dialog
->event_handler( dialog
->package
, event_fmt
, arg_fmt
, dialog
);
2999 msi_free( event_fmt
);
3000 msi_free( arg_fmt
);
3002 return ERROR_SUCCESS
;
3005 static UINT
msi_dialog_set_property( msi_dialog
*dialog
, LPCWSTR event
, LPCWSTR arg
)
3007 static const WCHAR szNullArg
[] = { '{','}',0 };
3008 LPWSTR p
, prop
, arg_fmt
= NULL
;
3011 len
= strlenW(event
);
3012 prop
= msi_alloc( len
*sizeof(WCHAR
));
3013 strcpyW( prop
, &event
[1] );
3014 p
= strchrW( prop
, ']' );
3015 if( p
&& p
[1] == 0 )
3018 if( strcmpW( szNullArg
, arg
) )
3019 deformat_string( dialog
->package
, arg
, &arg_fmt
);
3020 MSI_SetPropertyW( dialog
->package
, prop
, arg_fmt
);
3021 msi_free( arg_fmt
);
3024 ERR("Badly formatted property string - what happens?\n");
3026 return ERROR_SUCCESS
;
3029 static UINT
msi_dialog_control_event( MSIRECORD
*rec
, LPVOID param
)
3031 msi_dialog
*dialog
= param
;
3032 LPCWSTR condition
, event
, arg
;
3035 condition
= MSI_RecordGetString( rec
, 5 );
3036 r
= MSI_EvaluateConditionW( dialog
->package
, condition
);
3037 if( r
== MSICONDITION_TRUE
|| r
== MSICONDITION_NONE
)
3039 event
= MSI_RecordGetString( rec
, 3 );
3040 arg
= MSI_RecordGetString( rec
, 4 );
3041 if( event
[0] == '[' )
3042 msi_dialog_set_property( dialog
, event
, arg
);
3044 msi_dialog_send_event( dialog
, event
, arg
);
3047 return ERROR_SUCCESS
;
3056 static UINT
add_rec_to_list( MSIRECORD
*rec
, LPVOID param
)
3058 struct rec_list
*add_rec
;
3059 struct list
*records
= (struct list
*)param
;
3061 msiobj_addref( &rec
->hdr
);
3063 add_rec
= msi_alloc( sizeof( *add_rec
) );
3066 msiobj_release( &rec
->hdr
);
3067 return ERROR_OUTOFMEMORY
;
3071 list_add_tail( records
, &add_rec
->entry
);
3072 return ERROR_SUCCESS
;
3075 static inline void remove_rec_from_list( struct rec_list
*rec_entry
)
3077 msiobj_release( &rec_entry
->rec
->hdr
);
3078 list_remove( &rec_entry
->entry
);
3079 msi_free( rec_entry
);
3082 static UINT
msi_dialog_button_handler( msi_dialog
*dialog
,
3083 msi_control
*control
, WPARAM param
)
3085 static const WCHAR query
[] = {
3086 'S','E','L','E','C','T',' ','*',' ',
3087 'F','R','O','M',' ','C','o','n','t','r','o','l','E','v','e','n','t',' ',
3088 'W','H','E','R','E',' ',
3089 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ',
3091 '`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',' ',
3092 'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','i','n','g','`',0
3094 MSIQUERY
*view
= NULL
;
3095 struct rec_list
*rec_entry
, *next
;
3099 if( HIWORD(param
) != BN_CLICKED
)
3100 return ERROR_SUCCESS
;
3102 list_init( &events
);
3104 r
= MSI_OpenQuery( dialog
->package
->db
, &view
, query
,
3105 dialog
->name
, control
->name
);
3106 if( r
!= ERROR_SUCCESS
)
3108 ERR("query failed\n");
3112 r
= MSI_IterateRecords( view
, 0, add_rec_to_list
, &events
);
3113 msiobj_release( &view
->hdr
);
3114 if (r
!= ERROR_SUCCESS
)
3117 /* handle all SetProperty events first */
3118 LIST_FOR_EACH_ENTRY_SAFE( rec_entry
, next
, &events
, struct rec_list
, entry
)
3120 LPCWSTR event
= MSI_RecordGetString( rec_entry
->rec
, 3 );
3122 if ( event
[0] != '[' )
3125 r
= msi_dialog_control_event( rec_entry
->rec
, dialog
);
3126 remove_rec_from_list( rec_entry
);
3128 if ( r
!= ERROR_SUCCESS
)
3132 /* handle all other events */
3133 LIST_FOR_EACH_ENTRY_SAFE( rec_entry
, next
, &events
, struct rec_list
, entry
)
3135 r
= msi_dialog_control_event( rec_entry
->rec
, dialog
);
3136 remove_rec_from_list( rec_entry
);
3138 if ( r
!= ERROR_SUCCESS
)
3143 LIST_FOR_EACH_ENTRY_SAFE( rec_entry
, next
, &events
, struct rec_list
, entry
)
3145 remove_rec_from_list( rec_entry
);
3151 static UINT
msi_dialog_get_checkbox_state( msi_dialog
*dialog
,
3152 msi_control
*control
)
3154 WCHAR state
[2] = { 0 };
3157 MSI_GetPropertyW( dialog
->package
, control
->property
, state
, &sz
);
3158 return state
[0] ? 1 : 0;
3161 static void msi_dialog_set_checkbox_state( msi_dialog
*dialog
,
3162 msi_control
*control
, UINT state
)
3164 static const WCHAR szState
[] = { '1', 0 };
3167 /* if uncheck then the property is set to NULL */
3170 MSI_SetPropertyW( dialog
->package
, control
->property
, NULL
);
3174 /* check for a custom state */
3175 if (control
->value
&& control
->value
[0])
3176 val
= control
->value
;
3180 MSI_SetPropertyW( dialog
->package
, control
->property
, val
);
3183 static void msi_dialog_checkbox_sync_state( msi_dialog
*dialog
,
3184 msi_control
*control
)
3188 state
= msi_dialog_get_checkbox_state( dialog
, control
);
3189 SendMessageW( control
->hwnd
, BM_SETCHECK
,
3190 state
? BST_CHECKED
: BST_UNCHECKED
, 0 );
3193 static UINT
msi_dialog_checkbox_handler( msi_dialog
*dialog
,
3194 msi_control
*control
, WPARAM param
)
3198 if( HIWORD(param
) != BN_CLICKED
)
3199 return ERROR_SUCCESS
;
3201 TRACE("clicked checkbox %s, set %s\n", debugstr_w(control
->name
),
3202 debugstr_w(control
->property
));
3204 state
= msi_dialog_get_checkbox_state( dialog
, control
);
3205 state
= state
? 0 : 1;
3206 msi_dialog_set_checkbox_state( dialog
, control
, state
);
3207 msi_dialog_checkbox_sync_state( dialog
, control
);
3209 return msi_dialog_button_handler( dialog
, control
, param
);
3212 static UINT
msi_dialog_edit_handler( msi_dialog
*dialog
,
3213 msi_control
*control
, WPARAM param
)
3217 if( HIWORD(param
) != EN_CHANGE
)
3218 return ERROR_SUCCESS
;
3220 TRACE("edit %s contents changed, set %s\n", debugstr_w(control
->name
),
3221 debugstr_w(control
->property
));
3223 buf
= msi_get_window_text( control
->hwnd
);
3224 MSI_SetPropertyW( dialog
->package
, control
->property
, buf
);
3228 return ERROR_SUCCESS
;
3231 static UINT
msi_dialog_radiogroup_handler( msi_dialog
*dialog
,
3232 msi_control
*control
, WPARAM param
)
3234 if( HIWORD(param
) != BN_CLICKED
)
3235 return ERROR_SUCCESS
;
3237 TRACE("clicked radio button %s, set %s\n", debugstr_w(control
->name
),
3238 debugstr_w(control
->property
));
3240 MSI_SetPropertyW( dialog
->package
, control
->property
, control
->name
);
3242 return msi_dialog_button_handler( dialog
, control
, param
);
3245 static LRESULT
msi_dialog_oncommand( msi_dialog
*dialog
, WPARAM param
, HWND hwnd
)
3247 msi_control
*control
= NULL
;
3249 TRACE("%p %p %08lx\n", dialog
, hwnd
, param
);
3254 control
= msi_dialog_find_control( dialog
, dialog
->control_default
);
3256 case 2: /* escape */
3257 control
= msi_dialog_find_control( dialog
, dialog
->control_cancel
);
3260 control
= msi_dialog_find_control_by_hwnd( dialog
, hwnd
);
3265 if( control
->handler
)
3267 control
->handler( dialog
, control
, param
);
3268 msi_dialog_evaluate_control_conditions( dialog
);
3275 static LRESULT
msi_dialog_onnotify( msi_dialog
*dialog
, LPARAM param
)
3277 LPNMHDR nmhdr
= (LPNMHDR
) param
;
3278 msi_control
*control
= msi_dialog_find_control_by_hwnd( dialog
, nmhdr
->hwndFrom
);
3280 TRACE("%p %p\n", dialog
, nmhdr
->hwndFrom
);
3282 if ( control
&& control
->handler
)
3283 control
->handler( dialog
, control
, param
);
3288 static void msi_dialog_setfocus( msi_dialog
*dialog
)
3290 HWND hwnd
= dialog
->hWndFocus
;
3292 hwnd
= GetNextDlgTabItem( dialog
->hwnd
, hwnd
, TRUE
);
3293 hwnd
= GetNextDlgTabItem( dialog
->hwnd
, hwnd
, FALSE
);
3295 dialog
->hWndFocus
= hwnd
;
3298 static LRESULT WINAPI
MSIDialog_WndProc( HWND hwnd
, UINT msg
,
3299 WPARAM wParam
, LPARAM lParam
)
3301 msi_dialog
*dialog
= (LPVOID
) GetWindowLongPtrW( hwnd
, GWLP_USERDATA
);
3303 TRACE("0x%04x\n", msg
);
3308 dialog
->package
->center_x
= LOWORD(lParam
) + dialog
->size
.cx
/ 2.0;
3309 dialog
->package
->center_y
= HIWORD(lParam
) + dialog
->size
.cy
/ 2.0;
3313 return msi_dialog_oncreate( hwnd
, (LPCREATESTRUCTW
)lParam
);
3316 return msi_dialog_oncommand( dialog
, wParam
, (HWND
)lParam
);
3319 if( LOWORD(wParam
) == WA_INACTIVE
)
3320 dialog
->hWndFocus
= GetFocus();
3322 msi_dialog_setfocus( dialog
);
3326 msi_dialog_setfocus( dialog
);
3329 /* bounce back to our subclassed static control */
3330 case WM_CTLCOLORSTATIC
:
3331 return SendMessageW( (HWND
) lParam
, WM_CTLCOLORSTATIC
, wParam
, lParam
);
3334 dialog
->hwnd
= NULL
;
3337 return msi_dialog_onnotify( dialog
, lParam
);
3339 return DefWindowProcW(hwnd
, msg
, wParam
, lParam
);
3342 static BOOL CALLBACK
msi_radioground_child_enum( HWND hWnd
, LPARAM lParam
)
3344 EnableWindow( hWnd
, lParam
);
3348 static LRESULT WINAPI
MSIRadioGroup_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
3350 WNDPROC oldproc
= (WNDPROC
) GetPropW(hWnd
, szButtonData
);
3353 TRACE("hWnd %p msg %04x wParam 0x%08lx lParam 0x%08lx\n", hWnd
, msg
, wParam
, lParam
);
3355 if (msg
== WM_COMMAND
) /* Forward notifications to dialog */
3356 SendMessageW(GetParent(hWnd
), msg
, wParam
, lParam
);
3358 r
= CallWindowProcW(oldproc
, hWnd
, msg
, wParam
, lParam
);
3360 /* make sure the radio buttons show as disabled if the parent is disabled */
3361 if (msg
== WM_ENABLE
)
3362 EnumChildWindows( hWnd
, msi_radioground_child_enum
, wParam
);
3367 static LRESULT WINAPI
MSIHiddenWindowProc( HWND hwnd
, UINT msg
,
3368 WPARAM wParam
, LPARAM lParam
)
3370 msi_dialog
*dialog
= (msi_dialog
*) lParam
;
3372 TRACE("%d %p\n", msg
, dialog
);
3376 case WM_MSI_DIALOG_CREATE
:
3377 return msi_dialog_run_message_loop( dialog
);
3378 case WM_MSI_DIALOG_DESTROY
:
3379 msi_dialog_destroy( dialog
);
3382 return DefWindowProcW( hwnd
, msg
, wParam
, lParam
);
3385 /* functions that interface to other modules within MSI */
3387 msi_dialog
*msi_dialog_create( MSIPACKAGE
* package
,
3388 LPCWSTR szDialogName
, msi_dialog
*parent
,
3389 msi_dialog_event_handler event_handler
)
3391 MSIRECORD
*rec
= NULL
;
3394 TRACE("%p %s\n", package
, debugstr_w(szDialogName
));
3396 /* allocate the structure for the dialog to use */
3397 dialog
= msi_alloc_zero( sizeof *dialog
+ sizeof(WCHAR
)*strlenW(szDialogName
) );
3400 strcpyW( dialog
->name
, szDialogName
);
3401 dialog
->parent
= parent
;
3402 msiobj_addref( &package
->hdr
);
3403 dialog
->package
= package
;
3404 dialog
->event_handler
= event_handler
;
3405 dialog
->finished
= 0;
3406 list_init( &dialog
->controls
);
3408 /* verify that the dialog exists */
3409 rec
= msi_get_dialog_record( dialog
);
3412 msiobj_release( &package
->hdr
);
3416 dialog
->attributes
= MSI_RecordGetInteger( rec
, 6 );
3417 dialog
->control_default
= strdupW( MSI_RecordGetString( rec
, 9 ) );
3418 dialog
->control_cancel
= strdupW( MSI_RecordGetString( rec
, 10 ) );
3419 msiobj_release( &rec
->hdr
);
3424 static void msi_process_pending_messages( HWND hdlg
)
3428 while( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
) )
3430 if( hdlg
&& IsDialogMessageW( hdlg
, &msg
))
3432 TranslateMessage( &msg
);
3433 DispatchMessageW( &msg
);
3437 void msi_dialog_end_dialog( msi_dialog
*dialog
)
3439 TRACE("%p\n", dialog
);
3440 dialog
->finished
= 1;
3441 PostMessageW(dialog
->hwnd
, WM_NULL
, 0, 0);
3444 void msi_dialog_check_messages( HANDLE handle
)
3448 /* in threads other than the UI thread, block */
3449 if( uiThreadId
!= GetCurrentThreadId() )
3452 WaitForSingleObject( handle
, INFINITE
);
3456 /* there's two choices for the UI thread */
3459 msi_process_pending_messages( NULL
);
3465 * block here until somebody creates a new dialog or
3466 * the handle we're waiting on becomes ready
3468 r
= MsgWaitForMultipleObjects( 1, &handle
, 0, INFINITE
, QS_ALLINPUT
);
3469 if( r
== WAIT_OBJECT_0
)
3474 UINT
msi_dialog_run_message_loop( msi_dialog
*dialog
)
3479 if( uiThreadId
!= GetCurrentThreadId() )
3480 return SendMessageW( hMsiHiddenWindow
, WM_MSI_DIALOG_CREATE
, 0, (LPARAM
) dialog
);
3482 /* create the dialog window, don't show it yet */
3483 style
= WS_OVERLAPPED
;
3484 if( dialog
->attributes
& msidbDialogAttributesVisible
)
3485 style
|= WS_VISIBLE
;
3487 hwnd
= CreateWindowW( szMsiDialogClass
, dialog
->name
, style
,
3488 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
3489 NULL
, NULL
, NULL
, dialog
);
3492 ERR("Failed to create dialog %s\n", debugstr_w( dialog
->name
));
3493 return ERROR_FUNCTION_FAILED
;
3496 ShowWindow( hwnd
, SW_SHOW
);
3497 /* UpdateWindow( hwnd ); - and causes the transparent static controls not to paint */
3499 if( dialog
->attributes
& msidbDialogAttributesModal
)
3501 while( !dialog
->finished
)
3503 MsgWaitForMultipleObjects( 0, NULL
, 0, INFINITE
, QS_ALLINPUT
);
3504 msi_process_pending_messages( dialog
->hwnd
);
3508 return ERROR_IO_PENDING
;
3510 return ERROR_SUCCESS
;
3513 void msi_dialog_do_preview( msi_dialog
*dialog
)
3516 dialog
->attributes
|= msidbDialogAttributesVisible
;
3517 dialog
->attributes
&= ~msidbDialogAttributesModal
;
3518 msi_dialog_run_message_loop( dialog
);
3521 void msi_dialog_destroy( msi_dialog
*dialog
)
3523 if( uiThreadId
!= GetCurrentThreadId() )
3525 SendMessageW( hMsiHiddenWindow
, WM_MSI_DIALOG_DESTROY
, 0, (LPARAM
) dialog
);
3530 ShowWindow( dialog
->hwnd
, SW_HIDE
);
3533 DestroyWindow( dialog
->hwnd
);
3535 /* unsubscribe events */
3536 ControlEvent_CleanupDialogSubscriptions(dialog
->package
, dialog
->name
);
3538 /* destroy the list of controls */
3539 while( !list_empty( &dialog
->controls
) )
3543 t
= LIST_ENTRY( list_head( &dialog
->controls
),
3544 msi_control
, entry
);
3545 msi_destroy_control( t
);
3548 /* destroy the list of fonts */
3549 while( dialog
->font_list
)
3551 msi_font
*t
= dialog
->font_list
;
3552 dialog
->font_list
= t
->next
;
3553 DeleteObject( t
->hfont
);
3556 msi_free( dialog
->default_font
);
3558 msi_free( dialog
->control_default
);
3559 msi_free( dialog
->control_cancel
);
3560 msiobj_release( &dialog
->package
->hdr
);
3561 dialog
->package
= NULL
;
3565 BOOL
msi_dialog_register_class( void )
3569 ZeroMemory( &cls
, sizeof cls
);
3570 cls
.lpfnWndProc
= MSIDialog_WndProc
;
3571 cls
.hInstance
= NULL
;
3572 cls
.hIcon
= LoadIconW(0, (LPWSTR
)IDI_APPLICATION
);
3573 cls
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
3574 cls
.hbrBackground
= (HBRUSH
)(COLOR_3DFACE
+ 1);
3575 cls
.lpszMenuName
= NULL
;
3576 cls
.lpszClassName
= szMsiDialogClass
;
3578 if( !RegisterClassW( &cls
) )
3581 cls
.lpfnWndProc
= MSIHiddenWindowProc
;
3582 cls
.lpszClassName
= szMsiHiddenWindow
;
3584 if( !RegisterClassW( &cls
) )
3587 uiThreadId
= GetCurrentThreadId();
3589 hMsiHiddenWindow
= CreateWindowW( szMsiHiddenWindow
, NULL
, WS_OVERLAPPED
,
3590 0, 0, 100, 100, NULL
, NULL
, NULL
, NULL
);
3591 if( !hMsiHiddenWindow
)
3597 void msi_dialog_unregister_class( void )
3599 DestroyWindow( hMsiHiddenWindow
);
3600 hMsiHiddenWindow
= NULL
;
3601 UnregisterClassW( szMsiDialogClass
, NULL
);
3602 UnregisterClassW( szMsiHiddenWindow
, NULL
);
3606 static UINT
error_dialog_handler(MSIPACKAGE
*package
, LPCWSTR event
,
3607 LPCWSTR argument
, msi_dialog
* dialog
)
3609 static const WCHAR end_dialog
[] = {'E','n','d','D','i','a','l','o','g',0};
3610 static const WCHAR error_abort
[] = {'E','r','r','o','r','A','b','o','r','t',0};
3611 static const WCHAR error_cancel
[] = {'E','r','r','o','r','C','a','n','c','e','l',0};
3612 static const WCHAR error_no
[] = {'E','r','r','o','r','N','o',0};
3613 static const WCHAR result_prop
[] = {
3614 'M','S','I','E','r','r','o','r','D','i','a','l','o','g','R','e','s','u','l','t',0
3617 if ( lstrcmpW( event
, end_dialog
) )
3618 return ERROR_SUCCESS
;
3620 if ( !lstrcmpW( argument
, error_abort
) || !lstrcmpW( argument
, error_cancel
) ||
3621 !lstrcmpW( argument
, error_no
) )
3623 MSI_SetPropertyW( package
, result_prop
, error_abort
);
3626 ControlEvent_CleanupSubscriptions(package
);
3627 msi_dialog_end_dialog( dialog
);
3629 return ERROR_SUCCESS
;
3632 static UINT
msi_error_dialog_set_error( MSIPACKAGE
*package
, LPWSTR error_dialog
, LPWSTR error
)
3636 static const WCHAR update
[] =
3637 {'U','P','D','A','T','E',' ','`','C','o','n','t','r','o','l','`',' ',
3638 'S','E','T',' ','`','T','e','x','t','`',' ','=',' ','\'','%','s','\'',' ',
3639 'W','H','E','R','E', ' ','`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ',
3640 'A','N','D',' ','`','C','o','n','t','r','o','l','`',' ','=',' ',
3641 '\'','E','r','r','o','r','T','e','x','t','\'',0};
3643 row
= MSI_QueryGetRecord( package
->db
, update
, error
, error_dialog
);
3645 return ERROR_FUNCTION_FAILED
;
3647 msiobj_release(&row
->hdr
);
3648 return ERROR_SUCCESS
;
3651 UINT
msi_spawn_error_dialog( MSIPACKAGE
*package
, LPWSTR error_dialog
, LPWSTR error
)
3654 WCHAR result
[MAX_PATH
];
3655 UINT r
= ERROR_SUCCESS
;
3656 DWORD size
= MAX_PATH
;
3659 static const WCHAR szUILevel
[] = {'U','I','L','e','v','e','l',0};
3660 static const WCHAR pn_prop
[] = {'P','r','o','d','u','c','t','N','a','m','e',0};
3661 static const WCHAR title_fmt
[] = {'%','s',' ','W','a','r','n','i','n','g',0};
3662 static const WCHAR error_abort
[] = {'E','r','r','o','r','A','b','o','r','t',0};
3663 static const WCHAR result_prop
[] = {
3664 'M','S','I','E','r','r','o','r','D','i','a','l','o','g','R','e','s','u','l','t',0
3667 if ( (msi_get_property_int(package
, szUILevel
, 0) & INSTALLUILEVEL_MASK
) == INSTALLUILEVEL_NONE
)
3668 return ERROR_SUCCESS
;
3670 if ( !error_dialog
)
3672 LPWSTR product_name
= msi_dup_property( package
, pn_prop
);
3673 WCHAR title
[MAX_PATH
];
3675 sprintfW( title
, title_fmt
, product_name
);
3676 res
= MessageBoxW( NULL
, error
, title
, MB_OKCANCEL
| MB_ICONWARNING
);
3678 msi_free( product_name
);
3681 return ERROR_SUCCESS
;
3683 return ERROR_FUNCTION_FAILED
;
3686 r
= msi_error_dialog_set_error( package
, error_dialog
, error
);
3687 if ( r
!= ERROR_SUCCESS
)
3690 dialog
= msi_dialog_create( package
, error_dialog
, package
->dialog
,
3691 error_dialog_handler
);
3693 return ERROR_FUNCTION_FAILED
;
3695 dialog
->finished
= FALSE
;
3696 r
= msi_dialog_run_message_loop( dialog
);
3697 if ( r
!= ERROR_SUCCESS
)
3700 r
= MSI_GetPropertyW( package
, result_prop
, result
, &size
);
3701 if ( r
!= ERROR_SUCCESS
)
3704 if ( !lstrcmpW( result
, error_abort
) )
3705 r
= ERROR_FUNCTION_FAILED
;
3708 msi_dialog_destroy( dialog
);