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
);
53 typedef void (*msi_update
)( msi_dialog
*, msi_control
* );
55 struct msi_control_tag
68 float progress_current
;
74 typedef struct msi_font_tag
76 struct msi_font_tag
*next
;
86 msi_dialog_event_handler event_handler
;
96 LPWSTR control_default
;
97 LPWSTR control_cancel
;
101 typedef UINT (*msi_dialog_control_func
)( msi_dialog
*dialog
, MSIRECORD
*rec
);
102 struct control_handler
104 LPCWSTR control_type
;
105 msi_dialog_control_func func
;
114 } radio_button_group_descr
;
116 static const WCHAR szMsiDialogClass
[] = {
117 'M','s','i','D','i','a','l','o','g','C','l','o','s','e','C','l','a','s','s',0
119 static const WCHAR szMsiHiddenWindow
[] = {
120 'M','s','i','H','i','d','d','e','n','W','i','n','d','o','w',0 };
121 static const WCHAR szStatic
[] = { 'S','t','a','t','i','c',0 };
122 static const WCHAR szButton
[] = { 'B','U','T','T','O','N', 0 };
123 static const WCHAR szButtonData
[] = { 'M','S','I','D','A','T','A',0 };
124 static const WCHAR szProgress
[] = { 'P','r','o','g','r','e','s','s',0 };
125 static const WCHAR szText
[] = { 'T','e','x','t',0 };
126 static const WCHAR szPushButton
[] = { 'P','u','s','h','B','u','t','t','o','n',0 };
127 static const WCHAR szLine
[] = { 'L','i','n','e',0 };
128 static const WCHAR szBitmap
[] = { 'B','i','t','m','a','p',0 };
129 static const WCHAR szCheckBox
[] = { 'C','h','e','c','k','B','o','x',0 };
130 static const WCHAR szScrollableText
[] = {
131 'S','c','r','o','l','l','a','b','l','e','T','e','x','t',0 };
132 static const WCHAR szComboBox
[] = { 'C','o','m','b','o','B','o','x',0 };
133 static const WCHAR szEdit
[] = { 'E','d','i','t',0 };
134 static const WCHAR szMaskedEdit
[] = { 'M','a','s','k','e','d','E','d','i','t',0 };
135 static const WCHAR szPathEdit
[] = { 'P','a','t','h','E','d','i','t',0 };
136 static const WCHAR szProgressBar
[] = {
137 'P','r','o','g','r','e','s','s','B','a','r',0 };
138 static const WCHAR szSetProgress
[] = {
139 'S','e','t','P','r','o','g','r','e','s','s',0 };
140 static const WCHAR szRadioButtonGroup
[] = {
141 'R','a','d','i','o','B','u','t','t','o','n','G','r','o','u','p',0 };
142 static const WCHAR szIcon
[] = { 'I','c','o','n',0 };
143 static const WCHAR szSelectionTree
[] = {
144 'S','e','l','e','c','t','i','o','n','T','r','e','e',0 };
145 static const WCHAR szGroupBox
[] = { 'G','r','o','u','p','B','o','x',0 };
146 static const WCHAR szListBox
[] = { 'L','i','s','t','B','o','x',0 };
147 static const WCHAR szDirectoryCombo
[] = { 'D','i','r','e','c','t','o','r','y','C','o','m','b','o',0 };
148 static const WCHAR szDirectoryList
[] = { 'D','i','r','e','c','t','o','r','y','L','i','s','t',0 };
149 static const WCHAR szVolumeCostList
[] = { 'V','o','l','u','m','e','C','o','s','t','L','i','s','t',0 };
150 static const WCHAR szVolumeSelectCombo
[] = { 'V','o','l','u','m','e','S','e','l','e','c','t','C','o','m','b','o',0 };
151 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};
152 static const WCHAR szSelectionPath
[] = {'S','e','l','e','c','t','i','o','n','P','a','t','h',0};
153 static const WCHAR szProperty
[] = {'P','r','o','p','e','r','t','y',0};
155 static UINT
msi_dialog_checkbox_handler( msi_dialog
*, msi_control
*, WPARAM
);
156 static void msi_dialog_checkbox_sync_state( msi_dialog
*, msi_control
* );
157 static UINT
msi_dialog_button_handler( msi_dialog
*, msi_control
*, WPARAM
);
158 static UINT
msi_dialog_edit_handler( msi_dialog
*, msi_control
*, WPARAM
);
159 static UINT
msi_dialog_radiogroup_handler( msi_dialog
*, msi_control
*, WPARAM
);
160 static UINT
msi_dialog_evaluate_control_conditions( msi_dialog
*dialog
);
161 static LRESULT WINAPI
MSIRadioGroup_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
162 static MSIFEATURE
*msi_seltree_get_selected_feature( msi_control
*control
);
164 /* dialog sequencing */
166 #define WM_MSI_DIALOG_CREATE (WM_USER+0x100)
167 #define WM_MSI_DIALOG_DESTROY (WM_USER+0x101)
169 #define USER_INSTALLSTATE_ALL 0x1000
171 static DWORD uiThreadId
;
172 static HWND hMsiHiddenWindow
;
174 static INT
msi_dialog_scale_unit( msi_dialog
*dialog
, INT val
)
176 return MulDiv( val
, dialog
->scale
, 12 );
179 static msi_control
*msi_dialog_find_control( msi_dialog
*dialog
, LPCWSTR name
)
181 msi_control
*control
;
187 LIST_FOR_EACH_ENTRY( control
, &dialog
->controls
, msi_control
, entry
)
188 if( !strcmpW( control
->name
, name
) ) /* FIXME: case sensitive? */
193 static msi_control
*msi_dialog_find_control_by_type( msi_dialog
*dialog
, LPCWSTR type
)
195 msi_control
*control
;
201 LIST_FOR_EACH_ENTRY( control
, &dialog
->controls
, msi_control
, entry
)
202 if( !strcmpW( control
->type
, type
) ) /* FIXME: case sensitive? */
207 static msi_control
*msi_dialog_find_control_by_hwnd( msi_dialog
*dialog
, HWND hwnd
)
209 msi_control
*control
;
213 LIST_FOR_EACH_ENTRY( control
, &dialog
->controls
, msi_control
, entry
)
214 if( hwnd
== control
->hwnd
)
219 static LPWSTR
msi_get_deformatted_field( MSIPACKAGE
*package
, MSIRECORD
*rec
, int field
)
221 LPCWSTR str
= MSI_RecordGetString( rec
, field
);
225 deformat_string( package
, str
, &ret
);
229 static LPWSTR
msi_dialog_dup_property( msi_dialog
*dialog
, LPCWSTR property
, BOOL indirect
)
237 prop
= msi_dup_property( dialog
->package
, property
);
240 prop
= strdupW( property
);
245 msi_dialog
*msi_dialog_get_parent( msi_dialog
*dialog
)
247 return dialog
->parent
;
250 LPWSTR
msi_dialog_get_name( msi_dialog
*dialog
)
256 * msi_dialog_get_style
258 * Extract the {\style} string from the front of the text to display and
259 * update the pointer. Only the last style in a list is applied.
261 static LPWSTR
msi_dialog_get_style( LPCWSTR p
, LPCWSTR
*rest
)
272 while ((first
= strchrW( p
, '{' )) && (q
= strchrW( first
+ 1, '}' )))
275 if( *p
!= '\\' && *p
!= '&' )
278 /* little bit of sanity checking to stop us getting confused with RTF */
279 for( i
=++p
; i
<q
; i
++ )
280 if( *i
== '}' || *i
== '\\' )
290 ret
= msi_alloc( len
*sizeof(WCHAR
) );
293 memcpy( ret
, p
, len
*sizeof(WCHAR
) );
298 static UINT
msi_dialog_add_font( MSIRECORD
*rec
, LPVOID param
)
300 msi_dialog
*dialog
= param
;
307 /* create a font and add it to the list */
308 name
= MSI_RecordGetString( rec
, 1 );
309 font
= msi_alloc( sizeof *font
+ strlenW( name
)*sizeof (WCHAR
) );
310 strcpyW( font
->name
, name
);
311 font
->next
= dialog
->font_list
;
312 dialog
->font_list
= font
;
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
)
349 for( font
= dialog
->font_list
; font
; font
= font
->next
)
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
);
520 static HANDLE
msi_load_image( MSIDATABASE
*db
, LPCWSTR name
, UINT type
,
521 UINT cx
, UINT cy
, UINT flags
)
523 MSIRECORD
*rec
= NULL
;
524 HANDLE himage
= NULL
;
528 TRACE("%p %s %u %u %08x\n", db
, debugstr_w(name
), cx
, cy
, flags
);
530 tmp
= msi_create_tmp_path();
534 rec
= msi_get_binary_record( db
, name
);
537 r
= MSI_RecordStreamToFile( rec
, 2, tmp
);
538 if( r
== ERROR_SUCCESS
)
540 himage
= LoadImageW( 0, tmp
, type
, cx
, cy
, flags
);
542 msiobj_release( &rec
->hdr
);
550 static HICON
msi_load_icon( MSIDATABASE
*db
, LPCWSTR text
, UINT attributes
)
552 DWORD cx
= 0, cy
= 0, flags
;
554 flags
= LR_LOADFROMFILE
| LR_DEFAULTSIZE
;
555 if( attributes
& msidbControlAttributesFixedSize
)
557 flags
&= ~LR_DEFAULTSIZE
;
558 if( attributes
& msidbControlAttributesIconSize16
)
563 if( attributes
& msidbControlAttributesIconSize32
)
568 /* msidbControlAttributesIconSize48 handled by above logic */
570 return msi_load_image( db
, text
, IMAGE_ICON
, cx
, cy
, flags
);
573 static void msi_dialog_update_controls( msi_dialog
*dialog
, LPCWSTR property
)
575 msi_control
*control
;
577 LIST_FOR_EACH_ENTRY( control
, &dialog
->controls
, msi_control
, entry
)
579 if ( !lstrcmpW( control
->property
, property
) && control
->update
)
580 control
->update( dialog
, control
);
584 /* called from the Control Event subscription code */
585 void msi_dialog_handle_event( msi_dialog
* dialog
, LPCWSTR control
,
586 LPCWSTR attribute
, MSIRECORD
*rec
)
589 LPCWSTR font_text
, text
= NULL
;
592 ctrl
= msi_dialog_find_control( dialog
, control
);
595 if( !lstrcmpW(attribute
, szText
) )
597 font_text
= MSI_RecordGetString( rec
, 1 );
598 font
= msi_dialog_get_style( font_text
, &text
);
599 if (!text
) text
= szEmpty
;
600 SetWindowTextW( ctrl
->hwnd
, text
);
602 msi_dialog_check_messages( NULL
);
604 else if( !lstrcmpW(attribute
, szProgress
) )
608 func
= MSI_RecordGetInteger( rec
, 1 );
609 val
= MSI_RecordGetInteger( rec
, 2 );
611 TRACE("progress: func %u, val %u\n", func
, val
);
616 ctrl
->progress_max
= val
;
617 ctrl
->progress_current
= 0;
618 SendMessageW(ctrl
->hwnd
, PBM_SETRANGE
, 0, MAKELPARAM(0,100));
619 SendMessageW(ctrl
->hwnd
, PBM_SETPOS
, 0, 0);
621 case 1: /* FIXME: not sure what this is supposed to do */
624 ctrl
->progress_current
+= val
;
625 if (ctrl
->progress_current
> ctrl
->progress_max
)
626 ctrl
->progress_current
= ctrl
->progress_max
;
627 SendMessageW(ctrl
->hwnd
, PBM_SETPOS
, MulDiv(100, ctrl
->progress_current
, ctrl
->progress_max
), 0);
630 FIXME("Unknown progress message %u\n", func
);
634 else if ( !lstrcmpW(attribute
, szProperty
) )
636 MSIFEATURE
*feature
= msi_seltree_get_selected_feature( ctrl
);
637 MSI_SetPropertyW( dialog
->package
, ctrl
->property
, feature
->Directory
);
639 else if ( !lstrcmpW(attribute
, szSelectionPath
) )
641 LPWSTR prop
= msi_dialog_dup_property( dialog
, ctrl
->property
, TRUE
);
644 path
= msi_dup_property( dialog
->package
, prop
);
645 SetWindowTextW( ctrl
->hwnd
, path
);
651 FIXME("Attribute %s not being set\n", debugstr_w(attribute
));
656 static void msi_dialog_map_events(msi_dialog
* dialog
, LPCWSTR control
)
658 static const WCHAR Query
[] = {
659 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
660 '`','E','v','e','n','t','M','a','p','p','i','n','g','`',' ',
661 'W','H','E','R','E',' ',
662 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ',
664 '`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',0
667 LPCWSTR event
, attribute
;
669 row
= MSI_QueryGetRecord( dialog
->package
->db
, Query
, dialog
->name
, control
);
673 event
= MSI_RecordGetString( row
, 3 );
674 attribute
= MSI_RecordGetString( row
, 4 );
675 ControlEvent_SubscribeToEvent( dialog
->package
, dialog
, event
, control
, attribute
);
676 msiobj_release( &row
->hdr
);
679 /* everything except radio buttons */
680 static msi_control
*msi_dialog_add_control( msi_dialog
*dialog
,
681 MSIRECORD
*rec
, LPCWSTR szCls
, DWORD style
)
687 name
= MSI_RecordGetString( rec
, 2 );
688 attributes
= MSI_RecordGetInteger( rec
, 8 );
689 text
= MSI_RecordGetString( rec
, 10 );
691 TRACE("%s, %s, %08x, %s, %08x\n", debugstr_w(szCls
), debugstr_w(name
),
692 attributes
, debugstr_w(text
), style
);
694 if( attributes
& msidbControlAttributesVisible
)
696 if( ~attributes
& msidbControlAttributesEnabled
)
697 style
|= WS_DISABLED
;
698 if( attributes
& msidbControlAttributesSunken
)
699 exstyle
|= WS_EX_CLIENTEDGE
;
701 msi_dialog_map_events(dialog
, name
);
703 return msi_dialog_create_window( dialog
, rec
, exstyle
, szCls
, name
,
704 text
, style
, dialog
->hwnd
);
715 * we don't erase our own background,
716 * so we have to make sure that the parent window redraws first
718 static void msi_text_on_settext( HWND hWnd
)
723 hParent
= GetParent( hWnd
);
724 GetWindowRect( hWnd
, &rc
);
725 MapWindowPoints( NULL
, hParent
, (LPPOINT
) &rc
, 2 );
726 InvalidateRect( hParent
, &rc
, TRUE
);
729 static LRESULT WINAPI
730 MSIText_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
732 struct msi_text_info
*info
;
735 TRACE("%p %04x %08lx %08lx\n", hWnd
, msg
, wParam
, lParam
);
737 info
= GetPropW(hWnd
, szButtonData
);
739 if( msg
== WM_CTLCOLORSTATIC
&&
740 ( info
->attributes
& msidbControlAttributesTransparent
) )
742 SetBkMode( (HDC
)wParam
, TRANSPARENT
);
743 return (LRESULT
) GetStockObject(NULL_BRUSH
);
746 r
= CallWindowProcW(info
->oldproc
, hWnd
, msg
, wParam
, lParam
);
748 SetTextColor( (HDC
)wParam
, info
->font
->color
);
753 msi_text_on_settext( hWnd
);
757 RemovePropW( hWnd
, szButtonData
);
764 static UINT
msi_dialog_text_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
766 msi_control
*control
;
767 struct msi_text_info
*info
;
768 LPCWSTR text
, ptr
, prop
;
771 TRACE("%p %p\n", dialog
, rec
);
773 control
= msi_dialog_add_control( dialog
, rec
, szStatic
, SS_LEFT
| WS_GROUP
);
775 return ERROR_FUNCTION_FAILED
;
777 info
= msi_alloc( sizeof *info
);
779 return ERROR_SUCCESS
;
781 control
->attributes
= MSI_RecordGetInteger( rec
, 8 );
782 prop
= MSI_RecordGetString( rec
, 9 );
783 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
785 text
= MSI_RecordGetString( rec
, 10 );
786 font_name
= msi_dialog_get_style( text
, &ptr
);
787 info
->font
= ( font_name
) ? msi_dialog_find_font( dialog
, font_name
) : NULL
;
788 msi_free( font_name
);
790 info
->attributes
= MSI_RecordGetInteger( rec
, 8 );
791 if( info
->attributes
& msidbControlAttributesTransparent
)
792 SetWindowLongPtrW( control
->hwnd
, GWL_EXSTYLE
, WS_EX_TRANSPARENT
);
794 info
->oldproc
= (WNDPROC
) SetWindowLongPtrW( control
->hwnd
, GWLP_WNDPROC
,
795 (LONG_PTR
)MSIText_WndProc
);
796 SetPropW( control
->hwnd
, szButtonData
, info
);
798 ControlEvent_SubscribeToEvent( dialog
->package
, dialog
,
799 szSelectionPath
, control
->name
, szSelectionPath
);
801 return ERROR_SUCCESS
;
804 /* strip any leading text style label from text field */
805 static WCHAR
*msi_get_binary_name( MSIPACKAGE
*package
, MSIRECORD
*rec
)
809 text
= msi_get_deformatted_field( package
, rec
, 10 );
814 while (*p
&& *p
!= '{') p
++;
815 if (!*p
++) return text
;
817 while (*p
&& *p
!= '}') p
++;
818 if (!*p
++) return text
;
825 static UINT
msi_dialog_button_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
827 msi_control
*control
;
828 UINT attributes
, style
;
830 TRACE("%p %p\n", dialog
, rec
);
833 attributes
= MSI_RecordGetInteger( rec
, 8 );
834 if( attributes
& msidbControlAttributesIcon
)
837 control
= msi_dialog_add_control( dialog
, rec
, szButton
, style
);
839 return ERROR_FUNCTION_FAILED
;
841 control
->handler
= msi_dialog_button_handler
;
843 if (attributes
& msidbControlAttributesIcon
)
846 LPWSTR name
= msi_get_binary_name( dialog
->package
, rec
);
847 control
->hIcon
= msi_load_icon( dialog
->package
->db
, name
, attributes
);
850 SendMessageW( control
->hwnd
, BM_SETIMAGE
, IMAGE_ICON
, (LPARAM
) control
->hIcon
);
853 ERR("Failed to load icon %s\n", debugstr_w(name
));
857 return ERROR_SUCCESS
;
860 static LPWSTR
msi_get_checkbox_value( msi_dialog
*dialog
, LPCWSTR prop
)
862 static const WCHAR query
[] = {
863 'S','E','L','E','C','T',' ','*',' ',
864 'F','R','O','M',' ','`','C','h','e','c','k','B','o','x','`',' ',
865 'W','H','E','R','E',' ',
866 '`','P','r','o','p','e','r','t','y','`',' ','=',' ',
869 MSIRECORD
*rec
= NULL
;
872 /* find if there is a value associated with the checkbox */
873 rec
= MSI_QueryGetRecord( dialog
->package
->db
, query
, prop
);
877 ret
= msi_get_deformatted_field( dialog
->package
, rec
, 2 );
883 msiobj_release( &rec
->hdr
);
887 ret
= msi_dup_property( dialog
->package
, prop
);
897 static UINT
msi_dialog_checkbox_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
899 msi_control
*control
;
902 TRACE("%p %p\n", dialog
, rec
);
904 control
= msi_dialog_add_control( dialog
, rec
, szButton
,
905 BS_CHECKBOX
| BS_MULTILINE
| WS_TABSTOP
);
906 control
->handler
= msi_dialog_checkbox_handler
;
907 control
->update
= msi_dialog_checkbox_sync_state
;
908 prop
= MSI_RecordGetString( rec
, 9 );
911 control
->property
= strdupW( prop
);
912 control
->value
= msi_get_checkbox_value( dialog
, prop
);
913 TRACE("control %s value %s\n", debugstr_w(control
->property
),
914 debugstr_w(control
->value
));
916 msi_dialog_checkbox_sync_state( dialog
, control
);
918 return ERROR_SUCCESS
;
921 static UINT
msi_dialog_line_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
925 DWORD style
, exstyle
= 0;
926 DWORD x
, y
, width
, height
;
927 msi_control
*control
;
929 TRACE("%p %p\n", dialog
, rec
);
931 style
= WS_CHILD
| SS_ETCHEDHORZ
| SS_SUNKEN
;
933 name
= MSI_RecordGetString( rec
, 2 );
934 attributes
= MSI_RecordGetInteger( rec
, 8 );
936 if( attributes
& msidbControlAttributesVisible
)
938 if( ~attributes
& msidbControlAttributesEnabled
)
939 style
|= WS_DISABLED
;
940 if( attributes
& msidbControlAttributesSunken
)
941 exstyle
|= WS_EX_CLIENTEDGE
;
943 msi_dialog_map_events(dialog
, name
);
945 control
= msi_alloc( sizeof(*control
) + strlenW(name
) * sizeof(WCHAR
) );
947 return ERROR_OUTOFMEMORY
;
949 strcpyW( control
->name
, name
);
950 list_add_head( &dialog
->controls
, &control
->entry
);
951 control
->handler
= NULL
;
952 control
->property
= NULL
;
953 control
->value
= NULL
;
954 control
->hBitmap
= NULL
;
955 control
->hIcon
= NULL
;
956 control
->hDll
= NULL
;
957 control
->tabnext
= strdupW( MSI_RecordGetString( rec
, 11) );
958 control
->type
= strdupW( MSI_RecordGetString( rec
, 3 ) );
959 control
->progress_current
= 0;
960 control
->progress_max
= 100;
962 x
= MSI_RecordGetInteger( rec
, 4 );
963 y
= MSI_RecordGetInteger( rec
, 5 );
964 width
= MSI_RecordGetInteger( rec
, 6 );
966 x
= msi_dialog_scale_unit( dialog
, x
);
967 y
= msi_dialog_scale_unit( dialog
, y
);
968 width
= msi_dialog_scale_unit( dialog
, width
);
969 height
= 2; /* line is exactly 2 units in height */
971 control
->hwnd
= CreateWindowExW( exstyle
, szStatic
, NULL
, style
,
972 x
, y
, width
, height
, dialog
->hwnd
, NULL
, NULL
, NULL
);
974 TRACE("Dialog %s control %s hwnd %p\n",
975 debugstr_w(dialog
->name
), debugstr_w(name
), control
->hwnd
);
977 return ERROR_SUCCESS
;
980 /******************** Scroll Text ********************************************/
982 struct msi_scrolltext_info
985 msi_control
*control
;
989 static LRESULT WINAPI
990 MSIScrollText_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
992 struct msi_scrolltext_info
*info
;
995 TRACE("%p %04x %08lx %08lx\n", hWnd
, msg
, wParam
, lParam
);
997 info
= GetPropW( hWnd
, szButtonData
);
999 r
= CallWindowProcW( info
->oldproc
, hWnd
, msg
, wParam
, lParam
);
1005 RemovePropW( hWnd
, szButtonData
);
1008 /* native MSI sets a wait cursor here */
1009 msi_dialog_button_handler( info
->dialog
, info
->control
, BN_CLICKED
);
1015 struct msi_streamin_info
1022 static DWORD CALLBACK
1023 msi_richedit_stream_in( DWORD_PTR arg
, LPBYTE buffer
, LONG count
, LONG
*pcb
)
1025 struct msi_streamin_info
*info
= (struct msi_streamin_info
*) arg
;
1027 if( (count
+ info
->offset
) > info
->length
)
1028 count
= info
->length
- info
->offset
;
1029 memcpy( buffer
, &info
->string
[ info
->offset
], count
);
1031 info
->offset
+= count
;
1033 TRACE("%d/%d\n", info
->offset
, info
->length
);
1038 static void msi_scrolltext_add_text( msi_control
*control
, LPCWSTR text
)
1040 struct msi_streamin_info info
;
1043 info
.string
= strdupWtoA( text
);
1045 info
.length
= lstrlenA( info
.string
) + 1;
1047 es
.dwCookie
= (DWORD_PTR
) &info
;
1049 es
.pfnCallback
= msi_richedit_stream_in
;
1051 SendMessageW( control
->hwnd
, EM_STREAMIN
, SF_RTF
, (LPARAM
) &es
);
1053 msi_free( info
.string
);
1056 static UINT
msi_dialog_scrolltext_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1058 static const WCHAR szRichEdit20W
[] = {
1059 'R','i','c','h','E','d','i','t','2','0','W',0
1061 struct msi_scrolltext_info
*info
;
1062 msi_control
*control
;
1067 info
= msi_alloc( sizeof *info
);
1069 return ERROR_FUNCTION_FAILED
;
1071 hRichedit
= LoadLibraryA("riched20");
1073 style
= WS_BORDER
| ES_MULTILINE
| WS_VSCROLL
|
1074 ES_READONLY
| ES_AUTOVSCROLL
| WS_TABSTOP
;
1075 control
= msi_dialog_add_control( dialog
, rec
, szRichEdit20W
, style
);
1078 FreeLibrary( hRichedit
);
1080 return ERROR_FUNCTION_FAILED
;
1083 control
->hDll
= hRichedit
;
1085 info
->dialog
= dialog
;
1086 info
->control
= control
;
1088 /* subclass the static control */
1089 info
->oldproc
= (WNDPROC
) SetWindowLongPtrW( control
->hwnd
, GWLP_WNDPROC
,
1090 (LONG_PTR
)MSIScrollText_WndProc
);
1091 SetPropW( control
->hwnd
, szButtonData
, info
);
1093 /* add the text into the richedit */
1094 text
= MSI_RecordGetString( rec
, 10 );
1096 msi_scrolltext_add_text( control
, text
);
1098 return ERROR_SUCCESS
;
1101 static HBITMAP
msi_load_picture( MSIDATABASE
*db
, LPCWSTR name
,
1102 INT cx
, INT cy
, DWORD flags
)
1104 HBITMAP hOleBitmap
= 0, hBitmap
= 0, hOldSrcBitmap
, hOldDestBitmap
;
1105 MSIRECORD
*rec
= NULL
;
1106 IStream
*stm
= NULL
;
1107 IPicture
*pic
= NULL
;
1112 rec
= msi_get_binary_record( db
, name
);
1116 r
= MSI_RecordGetIStream( rec
, 2, &stm
);
1117 msiobj_release( &rec
->hdr
);
1118 if( r
!= ERROR_SUCCESS
)
1121 r
= OleLoadPicture( stm
, 0, TRUE
, &IID_IPicture
, (LPVOID
*) &pic
);
1122 IStream_Release( stm
);
1125 ERR("failed to load picture\n");
1129 r
= IPicture_get_Handle( pic
, (OLE_HANDLE
*) &hOleBitmap
);
1132 ERR("failed to get bitmap handle\n");
1136 /* make the bitmap the desired size */
1137 r
= GetObjectW( hOleBitmap
, sizeof bm
, &bm
);
1138 if (r
!= sizeof bm
)
1140 ERR("failed to get bitmap size\n");
1144 if (flags
& LR_DEFAULTSIZE
)
1150 srcdc
= CreateCompatibleDC( NULL
);
1151 hOldSrcBitmap
= SelectObject( srcdc
, hOleBitmap
);
1152 destdc
= CreateCompatibleDC( NULL
);
1153 hBitmap
= CreateCompatibleBitmap( srcdc
, cx
, cy
);
1154 hOldDestBitmap
= SelectObject( destdc
, hBitmap
);
1155 StretchBlt( destdc
, 0, 0, cx
, cy
,
1156 srcdc
, 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
1157 SelectObject( srcdc
, hOldSrcBitmap
);
1158 SelectObject( destdc
, hOldDestBitmap
);
1164 IPicture_Release( pic
);
1168 static UINT
msi_dialog_bitmap_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1170 UINT cx
, cy
, flags
, style
, attributes
;
1171 msi_control
*control
;
1174 flags
= LR_LOADFROMFILE
;
1175 style
= SS_BITMAP
| SS_LEFT
| WS_GROUP
;
1177 attributes
= MSI_RecordGetInteger( rec
, 8 );
1178 if( attributes
& msidbControlAttributesFixedSize
)
1180 flags
|= LR_DEFAULTSIZE
;
1181 style
|= SS_CENTERIMAGE
;
1184 control
= msi_dialog_add_control( dialog
, rec
, szStatic
, style
);
1185 cx
= MSI_RecordGetInteger( rec
, 6 );
1186 cy
= MSI_RecordGetInteger( rec
, 7 );
1187 cx
= msi_dialog_scale_unit( dialog
, cx
);
1188 cy
= msi_dialog_scale_unit( dialog
, cy
);
1190 name
= msi_get_binary_name( dialog
->package
, rec
);
1191 control
->hBitmap
= msi_load_picture( dialog
->package
->db
, name
, cx
, cy
, flags
);
1192 if( control
->hBitmap
)
1193 SendMessageW( control
->hwnd
, STM_SETIMAGE
,
1194 IMAGE_BITMAP
, (LPARAM
) control
->hBitmap
);
1196 ERR("Failed to load bitmap %s\n", debugstr_w(name
));
1200 return ERROR_SUCCESS
;
1203 static UINT
msi_dialog_icon_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1205 msi_control
*control
;
1211 control
= msi_dialog_add_control( dialog
, rec
, szStatic
,
1212 SS_ICON
| SS_CENTERIMAGE
| WS_GROUP
);
1214 attributes
= MSI_RecordGetInteger( rec
, 8 );
1215 name
= msi_get_binary_name( dialog
->package
, rec
);
1216 control
->hIcon
= msi_load_icon( dialog
->package
->db
, name
, attributes
);
1217 if( control
->hIcon
)
1218 SendMessageW( control
->hwnd
, STM_SETICON
, (WPARAM
) control
->hIcon
, 0 );
1220 ERR("Failed to load bitmap %s\n", debugstr_w(name
));
1222 return ERROR_SUCCESS
;
1225 static UINT
msi_dialog_combo_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1227 static const WCHAR szCombo
[] = { 'C','O','M','B','O','B','O','X',0 };
1228 DWORD attributes
, style
;
1230 style
= CBS_AUTOHSCROLL
| WS_TABSTOP
| WS_GROUP
| WS_CHILD
;
1231 attributes
= MSI_RecordGetInteger( rec
, 8 );
1232 if ( ~attributes
& msidbControlAttributesSorted
)
1234 if ( attributes
& msidbControlAttributesComboList
)
1235 style
|= CBS_DROPDOWNLIST
;
1237 style
|= CBS_DROPDOWN
;
1239 msi_dialog_add_control( dialog
, rec
, szCombo
, style
);
1240 return ERROR_SUCCESS
;
1243 /* length of 2^32 + 1 */
1244 #define MAX_NUM_DIGITS 11
1246 static UINT
msi_dialog_edit_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1248 msi_control
*control
;
1250 LPWSTR val
, begin
, end
;
1251 WCHAR num
[MAX_NUM_DIGITS
];
1254 control
= msi_dialog_add_control( dialog
, rec
, szEdit
,
1255 WS_BORDER
| WS_TABSTOP
| ES_AUTOHSCROLL
);
1256 control
->handler
= msi_dialog_edit_handler
;
1258 text
= MSI_RecordGetString( rec
, 10 );
1261 begin
= strchrW( text
, '{' );
1262 end
= strchrW( text
, '}' );
1264 if ( begin
&& end
&& end
> begin
&&
1265 begin
[0] >= '0' && begin
[0] <= '9' &&
1266 end
- begin
< MAX_NUM_DIGITS
)
1268 lstrcpynW( num
, begin
+ 1, end
- begin
);
1269 limit
= atolW( num
);
1271 SendMessageW( control
->hwnd
, EM_SETLIMITTEXT
, limit
, 0 );
1275 prop
= MSI_RecordGetString( rec
, 9 );
1277 control
->property
= strdupW( prop
);
1279 val
= msi_dup_property( dialog
->package
, control
->property
);
1280 SetWindowTextW( control
->hwnd
, val
);
1282 return ERROR_SUCCESS
;
1285 /******************** Masked Edit ********************************************/
1287 #define MASK_MAX_GROUPS 20
1289 struct msi_mask_group
1297 struct msi_maskedit_info
1305 struct msi_mask_group group
[MASK_MAX_GROUPS
];
1308 static BOOL
msi_mask_editable( WCHAR type
)
1323 static void msi_mask_control_change( struct msi_maskedit_info
*info
)
1328 val
= msi_alloc( (info
->num_chars
+1)*sizeof(WCHAR
) );
1329 for( i
=0, n
=0; i
<info
->num_groups
; i
++ )
1331 if( (info
->group
[i
].len
+ n
) > info
->num_chars
)
1333 ERR("can't fit control %d text into template\n",i
);
1336 if (!msi_mask_editable(info
->group
[i
].type
))
1338 for(r
=0; r
<info
->group
[i
].len
; r
++)
1339 val
[n
+r
] = info
->group
[i
].type
;
1344 r
= GetWindowTextW( info
->group
[i
].hwnd
, &val
[n
], info
->group
[i
].len
+1 );
1345 if( r
!= info
->group
[i
].len
)
1351 TRACE("%d/%d controls were good\n", i
, info
->num_groups
);
1353 if( i
== info
->num_groups
)
1355 TRACE("Set property %s to %s\n",
1356 debugstr_w(info
->prop
), debugstr_w(val
) );
1357 CharUpperBuffW( val
, info
->num_chars
);
1358 MSI_SetPropertyW( info
->dialog
->package
, info
->prop
, val
);
1359 msi_dialog_evaluate_control_conditions( info
->dialog
);
1364 /* now move to the next control if necessary */
1365 static VOID
msi_mask_next_control( struct msi_maskedit_info
*info
, HWND hWnd
)
1370 for( i
=0; i
<info
->num_groups
; i
++ )
1371 if( info
->group
[i
].hwnd
== hWnd
)
1374 /* don't move from the last control */
1375 if( i
>= (info
->num_groups
-1) )
1378 len
= SendMessageW( hWnd
, WM_GETTEXTLENGTH
, 0, 0 );
1379 if( len
< info
->group
[i
].len
)
1382 hWndNext
= GetNextDlgTabItem( GetParent( hWnd
), hWnd
, FALSE
);
1383 SetFocus( hWndNext
);
1386 static LRESULT WINAPI
1387 MSIMaskedEdit_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1389 struct msi_maskedit_info
*info
;
1392 TRACE("%p %04x %08lx %08lx\n", hWnd
, msg
, wParam
, lParam
);
1394 info
= GetPropW(hWnd
, szButtonData
);
1396 r
= CallWindowProcW(info
->oldproc
, hWnd
, msg
, wParam
, lParam
);
1401 if (HIWORD(wParam
) == EN_CHANGE
)
1403 msi_mask_control_change( info
);
1404 msi_mask_next_control( info
, (HWND
) lParam
);
1408 msi_free( info
->prop
);
1410 RemovePropW( hWnd
, szButtonData
);
1417 /* fish the various bits of the property out and put them in the control */
1419 msi_maskedit_set_text( struct msi_maskedit_info
*info
, LPCWSTR text
)
1425 for( i
= 0; i
< info
->num_groups
; i
++ )
1427 if( info
->group
[i
].len
< strlenW( p
) )
1429 LPWSTR chunk
= strdupW( p
);
1430 chunk
[ info
->group
[i
].len
] = 0;
1431 SetWindowTextW( info
->group
[i
].hwnd
, chunk
);
1436 SetWindowTextW( info
->group
[i
].hwnd
, p
);
1439 p
+= info
->group
[i
].len
;
1443 static struct msi_maskedit_info
* msi_dialog_parse_groups( LPCWSTR mask
)
1445 struct msi_maskedit_info
* info
= NULL
;
1446 int i
= 0, n
= 0, total
= 0;
1449 TRACE("masked control, template %s\n", debugstr_w(mask
));
1454 info
= msi_alloc_zero( sizeof *info
);
1458 p
= strchrW(mask
, '<');
1464 for( i
=0; i
<MASK_MAX_GROUPS
; i
++ )
1466 /* stop at the end of the string */
1467 if( p
[0] == 0 || p
[0] == '>' )
1470 /* count the number of the same identifier */
1471 for( n
=0; p
[n
] == p
[0]; n
++ )
1473 info
->group
[i
].ofs
= total
;
1474 info
->group
[i
].type
= p
[0];
1478 total
++; /* an extra not part of the group */
1480 info
->group
[i
].len
= n
;
1485 TRACE("%d characters in %d groups\n", total
, i
);
1486 if( i
== MASK_MAX_GROUPS
)
1487 ERR("too many groups in PIDTemplate %s\n", debugstr_w(mask
));
1489 info
->num_chars
= total
;
1490 info
->num_groups
= i
;
1496 msi_maskedit_create_children( struct msi_maskedit_info
*info
, LPCWSTR font
)
1498 DWORD width
, height
, style
, wx
, ww
;
1503 style
= WS_CHILD
| WS_BORDER
| WS_VISIBLE
| WS_TABSTOP
| ES_AUTOHSCROLL
;
1505 GetClientRect( info
->hwnd
, &rect
);
1507 width
= rect
.right
- rect
.left
;
1508 height
= rect
.bottom
- rect
.top
;
1510 for( i
= 0; i
< info
->num_groups
; i
++ )
1512 if (!msi_mask_editable( info
->group
[i
].type
))
1514 wx
= (info
->group
[i
].ofs
* width
) / info
->num_chars
;
1515 ww
= (info
->group
[i
].len
* width
) / info
->num_chars
;
1517 hwnd
= CreateWindowW( szEdit
, NULL
, style
, wx
, 0, ww
, height
,
1518 info
->hwnd
, NULL
, NULL
, NULL
);
1521 ERR("failed to create mask edit sub window\n");
1525 SendMessageW( hwnd
, EM_LIMITTEXT
, info
->group
[i
].len
, 0 );
1527 msi_dialog_set_font( info
->dialog
, hwnd
,
1528 font
?font
:info
->dialog
->default_font
);
1529 info
->group
[i
].hwnd
= hwnd
;
1534 * office 2003 uses "73931<````=````=````=````=`````>@@@@@"
1535 * delphi 7 uses "<????-??????-??????-????>" and "<???-???>"
1536 * filemaker pro 7 uses "<^^^^=^^^^=^^^^=^^^^=^^^^=^^^^=^^^^^>"
1538 static UINT
msi_dialog_maskedit_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1540 LPWSTR font_mask
, val
= NULL
, font
;
1541 struct msi_maskedit_info
*info
= NULL
;
1542 UINT ret
= ERROR_SUCCESS
;
1543 msi_control
*control
;
1548 font_mask
= msi_get_deformatted_field( dialog
->package
, rec
, 10 );
1549 font
= msi_dialog_get_style( font_mask
, &mask
);
1552 ERR("mask template is empty\n");
1556 info
= msi_dialog_parse_groups( mask
);
1559 ERR("template %s is invalid\n", debugstr_w(mask
));
1563 info
->dialog
= dialog
;
1565 control
= msi_dialog_add_control( dialog
, rec
, szStatic
,
1566 SS_OWNERDRAW
| WS_GROUP
| WS_VISIBLE
);
1569 ERR("Failed to create maskedit container\n");
1570 ret
= ERROR_FUNCTION_FAILED
;
1573 SetWindowLongPtrW( control
->hwnd
, GWL_EXSTYLE
, WS_EX_CONTROLPARENT
);
1575 info
->hwnd
= control
->hwnd
;
1577 /* subclass the static control */
1578 info
->oldproc
= (WNDPROC
) SetWindowLongPtrW( info
->hwnd
, GWLP_WNDPROC
,
1579 (LONG_PTR
)MSIMaskedEdit_WndProc
);
1580 SetPropW( control
->hwnd
, szButtonData
, info
);
1582 prop
= MSI_RecordGetString( rec
, 9 );
1584 info
->prop
= strdupW( prop
);
1586 msi_maskedit_create_children( info
, font
);
1590 val
= msi_dup_property( dialog
->package
, prop
);
1593 msi_maskedit_set_text( info
, val
);
1599 if( ret
!= ERROR_SUCCESS
)
1601 msi_free( font_mask
);
1606 /******************** Progress Bar *****************************************/
1608 static UINT
msi_dialog_progress_bar( msi_dialog
*dialog
, MSIRECORD
*rec
)
1610 msi_control
*control
;
1611 DWORD attributes
, style
;
1614 attributes
= MSI_RecordGetInteger( rec
, 8 );
1615 if( !(attributes
& msidbControlAttributesProgress95
) )
1616 style
|= PBS_SMOOTH
;
1618 control
= msi_dialog_add_control( dialog
, rec
, PROGRESS_CLASSW
, style
);
1620 return ERROR_FUNCTION_FAILED
;
1622 ControlEvent_SubscribeToEvent( dialog
->package
, dialog
,
1623 szSetProgress
, control
->name
, szProgress
);
1624 return ERROR_SUCCESS
;
1627 /******************** Path Edit ********************************************/
1629 struct msi_pathedit_info
1632 msi_control
*control
;
1636 static LPWSTR
msi_get_window_text( HWND hwnd
)
1642 buf
= msi_alloc( sz
*sizeof(WCHAR
) );
1645 r
= GetWindowTextW( hwnd
, buf
, sz
);
1649 buf
= msi_realloc( buf
, sz
*sizeof(WCHAR
) );
1655 static void msi_dialog_update_pathedit( msi_dialog
*dialog
, msi_control
*control
)
1660 if (!control
&& !(control
= msi_dialog_find_control_by_type( dialog
, szPathEdit
)))
1663 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
1664 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
1665 path
= msi_dialog_dup_property( dialog
, prop
, TRUE
);
1667 SetWindowTextW( control
->hwnd
, path
);
1668 SendMessageW( control
->hwnd
, EM_SETSEL
, 0, -1 );
1674 /* FIXME: test when this should fail */
1675 static BOOL
msi_dialog_verify_path( LPWSTR path
)
1677 if ( !lstrlenW( path
) )
1680 if ( PathIsRelativeW( path
) )
1686 /* returns TRUE if the path is valid, FALSE otherwise */
1687 static BOOL
msi_dialog_onkillfocus( msi_dialog
*dialog
, msi_control
*control
)
1693 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
1694 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
1696 buf
= msi_get_window_text( control
->hwnd
);
1698 if ( !msi_dialog_verify_path( buf
) )
1700 /* FIXME: display an error message box */
1701 ERR("Invalid path %s\n", debugstr_w( buf
));
1703 SetFocus( control
->hwnd
);
1708 MSI_SetPropertyW( dialog
->package
, prop
, buf
);
1711 msi_dialog_update_pathedit( dialog
, control
);
1713 TRACE("edit %s contents changed, set %s\n", debugstr_w(control
->name
),
1722 static LRESULT WINAPI
MSIPathEdit_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1724 struct msi_pathedit_info
*info
= GetPropW(hWnd
, szButtonData
);
1727 TRACE("%p %04x %08lx %08lx\n", hWnd
, msg
, wParam
, lParam
);
1729 if ( msg
== WM_KILLFOCUS
)
1731 /* if the path is invalid, don't handle this message */
1732 if ( !msi_dialog_onkillfocus( info
->dialog
, info
->control
) )
1736 r
= CallWindowProcW(info
->oldproc
, hWnd
, msg
, wParam
, lParam
);
1738 if ( msg
== WM_NCDESTROY
)
1741 RemovePropW( hWnd
, szButtonData
);
1747 static UINT
msi_dialog_pathedit_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1749 struct msi_pathedit_info
*info
;
1750 msi_control
*control
;
1753 info
= msi_alloc( sizeof *info
);
1755 return ERROR_FUNCTION_FAILED
;
1757 control
= msi_dialog_add_control( dialog
, rec
, szEdit
,
1758 WS_BORDER
| WS_TABSTOP
);
1759 control
->attributes
= MSI_RecordGetInteger( rec
, 8 );
1760 prop
= MSI_RecordGetString( rec
, 9 );
1761 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
1763 info
->dialog
= dialog
;
1764 info
->control
= control
;
1765 info
->oldproc
= (WNDPROC
) SetWindowLongPtrW( control
->hwnd
, GWLP_WNDPROC
,
1766 (LONG_PTR
)MSIPathEdit_WndProc
);
1767 SetPropW( control
->hwnd
, szButtonData
, info
);
1769 msi_dialog_update_pathedit( dialog
, control
);
1771 return ERROR_SUCCESS
;
1774 /* radio buttons are a bit different from normal controls */
1775 static UINT
msi_dialog_create_radiobutton( MSIRECORD
*rec
, LPVOID param
)
1777 radio_button_group_descr
*group
= param
;
1778 msi_dialog
*dialog
= group
->dialog
;
1779 msi_control
*control
;
1780 LPCWSTR prop
, text
, name
;
1781 DWORD style
, attributes
= group
->attributes
;
1783 style
= WS_CHILD
| BS_AUTORADIOBUTTON
| BS_MULTILINE
| WS_TABSTOP
;
1784 name
= MSI_RecordGetString( rec
, 3 );
1785 text
= MSI_RecordGetString( rec
, 8 );
1786 if( attributes
& msidbControlAttributesVisible
)
1787 style
|= WS_VISIBLE
;
1788 if( ~attributes
& msidbControlAttributesEnabled
)
1789 style
|= WS_DISABLED
;
1791 control
= msi_dialog_create_window( dialog
, rec
, 0, szButton
, name
, text
,
1792 style
, group
->parent
->hwnd
);
1794 return ERROR_FUNCTION_FAILED
;
1795 control
->handler
= msi_dialog_radiogroup_handler
;
1797 if (!lstrcmpW(control
->name
, group
->propval
))
1798 SendMessageW(control
->hwnd
, BM_SETCHECK
, BST_CHECKED
, 0);
1800 prop
= MSI_RecordGetString( rec
, 1 );
1802 control
->property
= strdupW( prop
);
1804 return ERROR_SUCCESS
;
1807 static UINT
msi_dialog_radiogroup_control( msi_dialog
*dialog
, MSIRECORD
*rec
)
1809 static const WCHAR query
[] = {
1810 'S','E','L','E','C','T',' ','*',' ',
1811 'F','R','O','M',' ','R','a','d','i','o','B','u','t','t','o','n',' ',
1812 'W','H','E','R','E',' ',
1813 '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
1816 msi_control
*control
;
1817 MSIQUERY
*view
= NULL
;
1818 radio_button_group_descr group
;
1819 MSIPACKAGE
*package
= dialog
->package
;
1821 DWORD attr
, style
= WS_GROUP
;
1823 prop
= MSI_RecordGetString( rec
, 9 );
1825 TRACE("%p %p %s\n", dialog
, rec
, debugstr_w( prop
));
1827 attr
= MSI_RecordGetInteger( rec
, 8 );
1828 if (attr
& msidbControlAttributesHasBorder
)
1829 style
|= BS_GROUPBOX
;
1831 style
|= BS_OWNERDRAW
;
1833 /* Create parent group box to hold radio buttons */
1834 control
= msi_dialog_add_control( dialog
, rec
, szButton
, style
);
1836 return ERROR_FUNCTION_FAILED
;
1838 oldproc
= (WNDPROC
) SetWindowLongPtrW( control
->hwnd
, GWLP_WNDPROC
,
1839 (LONG_PTR
)MSIRadioGroup_WndProc
);
1840 SetPropW(control
->hwnd
, szButtonData
, oldproc
);
1841 SetWindowLongPtrW( control
->hwnd
, GWL_EXSTYLE
, WS_EX_CONTROLPARENT
);
1844 control
->property
= strdupW( prop
);
1846 /* query the Radio Button table for all control in this group */
1847 r
= MSI_OpenQuery( package
->db
, &view
, query
, prop
);
1848 if( r
!= ERROR_SUCCESS
)
1850 ERR("query failed for dialog %s radio group %s\n",
1851 debugstr_w(dialog
->name
), debugstr_w(prop
));
1852 return ERROR_INVALID_PARAMETER
;
1855 group
.dialog
= dialog
;
1856 group
.parent
= control
;
1857 group
.attributes
= MSI_RecordGetInteger( rec
, 8 );
1858 group
.propval
= msi_dup_property( dialog
->package
, control
->property
);
1860 r
= MSI_IterateRecords( view
, 0, msi_dialog_create_radiobutton
, &group
);
1861 msiobj_release( &view
->hdr
);
1862 msi_free( group
.propval
);
1867 /******************** Selection Tree ***************************************/
1869 struct msi_selection_tree_info
1878 msi_seltree_sync_item_state( HWND hwnd
, MSIFEATURE
*feature
, HTREEITEM hItem
)
1881 DWORD index
= feature
->Action
;
1883 TRACE("Feature %s -> %d %d %d\n", debugstr_w(feature
->Title
),
1884 feature
->Installed
, feature
->Action
, feature
->ActionRequest
);
1886 if (index
== INSTALLSTATE_UNKNOWN
)
1887 index
= INSTALLSTATE_ABSENT
;
1889 tvi
.mask
= TVIF_STATE
;
1891 tvi
.state
= INDEXTOSTATEIMAGEMASK( index
);
1892 tvi
.stateMask
= TVIS_STATEIMAGEMASK
;
1894 SendMessageW( hwnd
, TVM_SETITEMW
, 0, (LPARAM
) &tvi
);
1898 msi_seltree_popup_menu( HWND hwnd
, INT x
, INT y
)
1903 /* create a menu to display */
1904 hMenu
= CreatePopupMenu();
1906 /* FIXME: load strings from resources */
1907 AppendMenuA( hMenu
, MF_ENABLED
, INSTALLSTATE_LOCAL
, "Install feature locally");
1908 AppendMenuA( hMenu
, MF_ENABLED
, USER_INSTALLSTATE_ALL
, "Install entire feature");
1909 AppendMenuA( hMenu
, MF_ENABLED
, INSTALLSTATE_ADVERTISED
, "Install on demand");
1910 AppendMenuA( hMenu
, MF_ENABLED
, INSTALLSTATE_ABSENT
, "Don't install");
1911 r
= TrackPopupMenu( hMenu
, TPM_LEFTALIGN
| TPM_TOPALIGN
| TPM_RETURNCMD
,
1912 x
, y
, 0, hwnd
, NULL
);
1913 DestroyMenu( hMenu
);
1918 msi_seltree_feature_from_item( HWND hwnd
, HTREEITEM hItem
)
1922 /* get the feature from the item */
1923 memset( &tvi
, 0, sizeof tvi
);
1925 tvi
.mask
= TVIF_PARAM
| TVIF_HANDLE
;
1926 SendMessageW( hwnd
, TVM_GETITEMW
, 0, (LPARAM
) &tvi
);
1928 return (MSIFEATURE
*) tvi
.lParam
;
1932 msi_seltree_update_feature_installstate( HWND hwnd
, HTREEITEM hItem
,
1933 MSIPACKAGE
*package
, MSIFEATURE
*feature
, INSTALLSTATE state
)
1935 msi_feature_set_state( package
, feature
, state
);
1936 msi_seltree_sync_item_state( hwnd
, feature
, hItem
);
1937 ACTION_UpdateComponentStates( package
, feature
->Feature
);
1941 msi_seltree_update_siblings_and_children_installstate( HWND hwnd
, HTREEITEM curr
,
1942 MSIPACKAGE
*package
, INSTALLSTATE state
)
1944 /* update all siblings */
1947 MSIFEATURE
*feature
;
1950 feature
= msi_seltree_feature_from_item( hwnd
, curr
);
1951 msi_seltree_update_feature_installstate( hwnd
, curr
, package
, feature
, state
);
1953 /* update this sibling's children */
1954 child
= (HTREEITEM
)SendMessageW( hwnd
, TVM_GETNEXTITEM
, (WPARAM
)TVGN_CHILD
, (LPARAM
)curr
);
1956 msi_seltree_update_siblings_and_children_installstate( hwnd
, child
,
1959 while ((curr
= (HTREEITEM
)SendMessageW( hwnd
, TVM_GETNEXTITEM
, (WPARAM
)TVGN_NEXT
, (LPARAM
)curr
)));
1963 msi_seltree_menu( HWND hwnd
, HTREEITEM hItem
)
1965 struct msi_selection_tree_info
*info
;
1966 MSIFEATURE
*feature
;
1967 MSIPACKAGE
*package
;
1975 info
= GetPropW(hwnd
, szButtonData
);
1976 package
= info
->dialog
->package
;
1978 feature
= msi_seltree_feature_from_item( hwnd
, hItem
);
1981 ERR("item %p feature was NULL\n", hItem
);
1985 /* get the item's rectangle to put the menu just below it */
1987 SendMessageW( hwnd
, TVM_GETITEMRECT
, 0, (LPARAM
) &u
.rc
);
1988 MapWindowPoints( hwnd
, NULL
, u
.pt
, 2 );
1990 r
= msi_seltree_popup_menu( hwnd
, u
.rc
.left
, u
.rc
.top
);
1994 case USER_INSTALLSTATE_ALL
:
1995 r
= INSTALLSTATE_LOCAL
;
1997 case INSTALLSTATE_ADVERTISED
:
1998 case INSTALLSTATE_ABSENT
:
2001 child
= (HTREEITEM
)SendMessageW( hwnd
, TVM_GETNEXTITEM
, (WPARAM
)TVGN_CHILD
, (LPARAM
)hItem
);
2003 msi_seltree_update_siblings_and_children_installstate( hwnd
, child
, package
, r
);
2006 case INSTALLSTATE_LOCAL
:
2007 msi_seltree_update_feature_installstate( hwnd
, hItem
, package
, feature
, r
);
2014 static MSIFEATURE
*msi_seltree_get_selected_feature( msi_control
*control
)
2016 struct msi_selection_tree_info
*info
= GetPropW(control
->hwnd
, szButtonData
);
2017 return msi_seltree_feature_from_item( control
->hwnd
, info
->selected
);
2020 static LRESULT WINAPI
2021 MSISelectionTree_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
2023 struct msi_selection_tree_info
*info
;
2024 TVHITTESTINFO tvhti
;
2027 TRACE("%p %04x %08lx %08lx\n", hWnd
, msg
, wParam
, lParam
);
2029 info
= GetPropW(hWnd
, szButtonData
);
2033 case WM_LBUTTONDOWN
:
2034 tvhti
.pt
.x
= (short)LOWORD( lParam
);
2035 tvhti
.pt
.y
= (short)HIWORD( lParam
);
2038 r
= CallWindowProcW(info
->oldproc
, hWnd
, TVM_HITTEST
, 0, (LPARAM
) &tvhti
);
2039 if (tvhti
.flags
& TVHT_ONITEMSTATEICON
)
2040 return msi_seltree_menu( hWnd
, tvhti
.hItem
);
2044 r
= CallWindowProcW(info
->oldproc
, hWnd
, msg
, wParam
, lParam
);
2050 RemovePropW( hWnd
, szButtonData
);
2057 msi_seltree_add_child_features( MSIPACKAGE
*package
, HWND hwnd
,
2058 LPCWSTR parent
, HTREEITEM hParent
)
2060 struct msi_selection_tree_info
*info
= GetPropW( hwnd
, szButtonData
);
2061 MSIFEATURE
*feature
;
2062 TVINSERTSTRUCTW tvis
;
2063 HTREEITEM hitem
, hfirst
= NULL
;
2065 LIST_FOR_EACH_ENTRY( feature
, &package
->features
, MSIFEATURE
, entry
)
2067 if ( lstrcmpW( parent
, feature
->Feature_Parent
) )
2070 if ( !feature
->Title
)
2073 if ( !feature
->Display
)
2076 memset( &tvis
, 0, sizeof tvis
);
2077 tvis
.hParent
= hParent
;
2078 tvis
.hInsertAfter
= TVI_LAST
;
2079 tvis
.u
.item
.mask
= TVIF_TEXT
| TVIF_PARAM
;
2080 tvis
.u
.item
.pszText
= feature
->Title
;
2081 tvis
.u
.item
.lParam
= (LPARAM
) feature
;
2083 hitem
= (HTREEITEM
) SendMessageW( hwnd
, TVM_INSERTITEMW
, 0, (LPARAM
) &tvis
);
2090 msi_seltree_sync_item_state( hwnd
, feature
, hitem
);
2091 msi_seltree_add_child_features( package
, hwnd
,
2092 feature
->Feature
, hitem
);
2094 /* the node is expanded if Display is odd */
2095 if ( feature
->Display
% 2 != 0 )
2096 SendMessageW( hwnd
, TVM_EXPAND
, TVE_EXPAND
, (LPARAM
) hitem
);
2099 /* select the first item */
2100 SendMessageW( hwnd
, TVM_SELECTITEM
, TVGN_CARET
| TVGN_DROPHILITE
, (LPARAM
) hfirst
);
2101 info
->selected
= hfirst
;
2104 static void msi_seltree_create_imagelist( HWND hwnd
)
2106 const int bm_width
= 32, bm_height
= 16, bm_count
= 3;
2107 const int bm_resource
= 0x1001;
2112 himl
= ImageList_Create( bm_width
, bm_height
, FALSE
, 4, 0 );
2115 ERR("failed to create image list\n");
2119 for (i
=0; i
<bm_count
; i
++)
2121 hbmp
= LoadBitmapW( msi_hInstance
, MAKEINTRESOURCEW(i
+bm_resource
) );
2124 ERR("failed to load bitmap %d\n", i
);
2129 * Add a dummy bitmap at offset zero because the treeview
2130 * can't use it as a state mask (zero means no user state).
2133 ImageList_Add( himl
, hbmp
, NULL
);
2135 ImageList_Add( himl
, hbmp
, NULL
);
2138 SendMessageW( hwnd
, TVM_SETIMAGELIST
, TVSIL_STATE
, (LPARAM
)himl
);
2141 static UINT
msi_dialog_seltree_handler( msi_dialog
*dialog
,
2142 msi_control
*control
, WPARAM param
)
2144 struct msi_selection_tree_info
*info
= GetPropW( control
->hwnd
, szButtonData
);
2145 LPNMTREEVIEWW tv
= (LPNMTREEVIEWW
)param
;
2146 MSIRECORD
*row
, *rec
;
2148 MSIFEATURE
*feature
;
2149 LPCWSTR dir
, title
= NULL
;
2150 UINT r
= ERROR_SUCCESS
;
2152 static const WCHAR select
[] = {
2153 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2154 '`','F','e','a','t','u','r','e','`',' ','W','H','E','R','E',' ',
2155 '`','T','i','t','l','e','`',' ','=',' ','\'','%','s','\'',0
2158 if (tv
->hdr
.code
!= TVN_SELCHANGINGW
)
2159 return ERROR_SUCCESS
;
2161 info
->selected
= tv
->itemNew
.hItem
;
2163 if (!(tv
->itemNew
.mask
& TVIF_TEXT
))
2165 feature
= msi_seltree_feature_from_item( control
->hwnd
, tv
->itemNew
.hItem
);
2167 title
= feature
->Title
;
2170 title
= tv
->itemNew
.pszText
;
2172 row
= MSI_QueryGetRecord( dialog
->package
->db
, select
, title
);
2174 return ERROR_FUNCTION_FAILED
;
2176 rec
= MSI_CreateRecord( 1 );
2178 MSI_RecordSetStringW( rec
, 1, MSI_RecordGetString( row
, 4 ) );
2179 ControlEvent_FireSubscribedEvent( dialog
->package
, szSelectionDescription
, rec
);
2181 dir
= MSI_RecordGetString( row
, 7 );
2182 folder
= get_loaded_folder( dialog
->package
, dir
);
2185 r
= ERROR_FUNCTION_FAILED
;
2189 MSI_RecordSetStringW( rec
, 1, folder
->ResolvedTarget
);
2190 ControlEvent_FireSubscribedEvent( dialog
->package
, szSelectionPath
, rec
);
2193 msiobj_release(&row
->hdr
);
2194 msiobj_release(&rec
->hdr
);
2199 static UINT
msi_dialog_selection_tree( msi_dialog
*dialog
, MSIRECORD
*rec
)
2201 msi_control
*control
;
2203 MSIPACKAGE
*package
= dialog
->package
;
2205 struct msi_selection_tree_info
*info
;
2207 info
= msi_alloc( sizeof *info
);
2209 return ERROR_FUNCTION_FAILED
;
2211 /* create the treeview control */
2212 style
= TVS_HASLINES
| TVS_HASBUTTONS
| TVS_LINESATROOT
;
2213 style
|= WS_GROUP
| WS_VSCROLL
;
2214 control
= msi_dialog_add_control( dialog
, rec
, WC_TREEVIEWW
, style
);
2218 return ERROR_FUNCTION_FAILED
;
2221 control
->handler
= msi_dialog_seltree_handler
;
2222 control
->attributes
= MSI_RecordGetInteger( rec
, 8 );
2223 prop
= MSI_RecordGetString( rec
, 9 );
2224 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
2227 info
->dialog
= dialog
;
2228 info
->hwnd
= control
->hwnd
;
2229 info
->oldproc
= (WNDPROC
) SetWindowLongPtrW( control
->hwnd
, GWLP_WNDPROC
,
2230 (LONG_PTR
)MSISelectionTree_WndProc
);
2231 SetPropW( control
->hwnd
, szButtonData
, info
);
2233 ControlEvent_SubscribeToEvent( dialog
->package
, dialog
,
2234 szSelectionPath
, control
->name
, szProperty
);
2237 msi_seltree_create_imagelist( control
->hwnd
);
2238 msi_seltree_add_child_features( package
, control
->hwnd
, NULL
, NULL
);
2240 return ERROR_SUCCESS
;
2243 /******************** Group Box ***************************************/
2245 static UINT
msi_dialog_group_box( msi_dialog
*dialog
, MSIRECORD
*rec
)
2247 msi_control
*control
;
2250 style
= BS_GROUPBOX
| WS_CHILD
| WS_GROUP
;
2251 control
= msi_dialog_add_control( dialog
, rec
, WC_BUTTONW
, style
);
2253 return ERROR_FUNCTION_FAILED
;
2255 return ERROR_SUCCESS
;
2258 /******************** List Box ***************************************/
2260 struct msi_listbox_info
2270 static LRESULT WINAPI
MSIListBox_WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
2272 struct msi_listbox_info
*info
;
2276 TRACE("%p %04x %08lx %08lx\n", hWnd
, msg
, wParam
, lParam
);
2278 info
= GetPropW( hWnd
, szButtonData
);
2282 r
= CallWindowProcW( info
->oldproc
, hWnd
, msg
, wParam
, lParam
);
2287 for (j
= 0; j
< info
->num_items
; j
++)
2288 msi_free( info
->items
[j
] );
2289 msi_free( info
->items
);
2291 RemovePropW( hWnd
, szButtonData
);
2298 static UINT
msi_listbox_add_item( MSIRECORD
*rec
, LPVOID param
)
2300 struct msi_listbox_info
*info
= param
;
2301 LPCWSTR value
, text
;
2304 value
= MSI_RecordGetString( rec
, 3 );
2305 text
= MSI_RecordGetString( rec
, 4 );
2307 info
->items
[info
->addpos_items
] = strdupW( value
);
2309 pos
= SendMessageW( info
->hwnd
, LB_ADDSTRING
, 0, (LPARAM
)text
);
2310 SendMessageW( info
->hwnd
, LB_SETITEMDATA
, pos
, (LPARAM
)info
->items
[info
->addpos_items
] );
2311 info
->addpos_items
++;
2312 return ERROR_SUCCESS
;
2315 static UINT
msi_listbox_add_items( struct msi_listbox_info
*info
, LPCWSTR property
)
2318 MSIQUERY
*view
= NULL
;
2321 static const WCHAR query
[] = {
2322 'S','E','L','E','C','T',' ','*',' ',
2323 'F','R','O','M',' ','`','L','i','s','t','B','o','x','`',' ',
2324 'W','H','E','R','E',' ',
2325 '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',' ',
2326 'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','`',0
2329 r
= MSI_OpenQuery( info
->dialog
->package
->db
, &view
, query
, property
);
2330 if ( r
!= ERROR_SUCCESS
)
2333 /* just get the number of records */
2335 r
= MSI_IterateRecords( view
, &count
, NULL
, NULL
);
2337 info
->num_items
= count
;
2338 info
->items
= msi_alloc( sizeof(*info
->items
) * count
);
2340 r
= MSI_IterateRecords( view
, NULL
, msi_listbox_add_item
, info
);
2341 msiobj_release( &view
->hdr
);
2346 static UINT
msi_dialog_listbox_handler( msi_dialog
*dialog
,
2347 msi_control
*control
, WPARAM param
)
2349 struct msi_listbox_info
*info
;
2353 if( HIWORD(param
) != LBN_SELCHANGE
)
2354 return ERROR_SUCCESS
;
2356 info
= GetPropW( control
->hwnd
, szButtonData
);
2357 index
= SendMessageW( control
->hwnd
, LB_GETCURSEL
, 0, 0 );
2358 value
= (LPCWSTR
) SendMessageW( control
->hwnd
, LB_GETITEMDATA
, index
, 0 );
2360 MSI_SetPropertyW( info
->dialog
->package
,
2361 control
->property
, value
);
2362 msi_dialog_evaluate_control_conditions( info
->dialog
);
2364 return ERROR_SUCCESS
;
2367 static UINT
msi_dialog_list_box( msi_dialog
*dialog
, MSIRECORD
*rec
)
2369 struct msi_listbox_info
*info
;
2370 msi_control
*control
;
2371 DWORD attributes
, style
;
2374 info
= msi_alloc( sizeof *info
);
2376 return ERROR_FUNCTION_FAILED
;
2378 style
= WS_TABSTOP
| WS_GROUP
| WS_CHILD
| LBS_NOTIFY
| WS_VSCROLL
| WS_BORDER
;
2379 attributes
= MSI_RecordGetInteger( rec
, 8 );
2380 if (~attributes
& msidbControlAttributesSorted
)
2383 control
= msi_dialog_add_control( dialog
, rec
, WC_LISTBOXW
, style
);
2387 return ERROR_FUNCTION_FAILED
;
2390 control
->handler
= msi_dialog_listbox_handler
;
2392 prop
= MSI_RecordGetString( rec
, 9 );
2393 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
2396 info
->dialog
= dialog
;
2397 info
->hwnd
= control
->hwnd
;
2399 info
->addpos_items
= 0;
2400 info
->oldproc
= (WNDPROC
)SetWindowLongPtrW( control
->hwnd
, GWLP_WNDPROC
,
2401 (LONG_PTR
)MSIListBox_WndProc
);
2402 SetPropW( control
->hwnd
, szButtonData
, info
);
2404 if ( control
->property
)
2405 msi_listbox_add_items( info
, control
->property
);
2407 return ERROR_SUCCESS
;
2410 /******************** Directory Combo ***************************************/
2412 static void msi_dialog_update_directory_combo( msi_dialog
*dialog
, msi_control
*control
)
2417 if (!control
&& !(control
= msi_dialog_find_control_by_type( dialog
, szDirectoryCombo
)))
2420 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
2421 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
2422 path
= msi_dialog_dup_property( dialog
, prop
, TRUE
);
2424 PathStripPathW( path
);
2425 PathRemoveBackslashW( path
);
2427 SendMessageW( control
->hwnd
, CB_INSERTSTRING
, 0, (LPARAM
)path
);
2428 SendMessageW( control
->hwnd
, CB_SETCURSEL
, 0, 0 );
2434 static UINT
msi_dialog_directory_combo( msi_dialog
*dialog
, MSIRECORD
*rec
)
2436 msi_control
*control
;
2440 /* FIXME: use CBS_OWNERDRAWFIXED and add owner draw code */
2441 style
= CBS_DROPDOWNLIST
| CBS_HASSTRINGS
| WS_CHILD
|
2442 WS_GROUP
| WS_TABSTOP
| WS_VSCROLL
;
2443 control
= msi_dialog_add_control( dialog
, rec
, WC_COMBOBOXW
, style
);
2445 return ERROR_FUNCTION_FAILED
;
2447 control
->attributes
= MSI_RecordGetInteger( rec
, 8 );
2448 prop
= MSI_RecordGetString( rec
, 9 );
2449 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
2451 msi_dialog_update_directory_combo( dialog
, control
);
2453 return ERROR_SUCCESS
;
2456 /******************** Directory List ***************************************/
2458 static void msi_dialog_update_directory_list( msi_dialog
*dialog
, msi_control
*control
)
2460 WCHAR dir_spec
[MAX_PATH
];
2461 WIN32_FIND_DATAW wfd
;
2467 static const WCHAR asterisk
[] = {'*',0};
2469 if (!control
&& !(control
= msi_dialog_find_control_by_type( dialog
, szDirectoryList
)))
2472 /* clear the list-view */
2473 SendMessageW( control
->hwnd
, LVM_DELETEALLITEMS
, 0, 0 );
2475 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
2476 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
2477 path
= msi_dialog_dup_property( dialog
, prop
, TRUE
);
2479 lstrcpyW( dir_spec
, path
);
2480 lstrcatW( dir_spec
, asterisk
);
2482 file
= FindFirstFileW( dir_spec
, &wfd
);
2483 if ( file
== INVALID_HANDLE_VALUE
)
2488 if ( wfd
.dwFileAttributes
!= FILE_ATTRIBUTE_DIRECTORY
)
2491 if ( !lstrcmpW( wfd
.cFileName
, szDot
) || !lstrcmpW( wfd
.cFileName
, szDotDot
) )
2494 item
.mask
= LVIF_TEXT
;
2495 item
.cchTextMax
= MAX_PATH
;
2498 item
.pszText
= wfd
.cFileName
;
2500 SendMessageW( control
->hwnd
, LVM_INSERTITEMW
, 0, (LPARAM
)&item
);
2501 } while ( FindNextFileW( file
, &wfd
) );
2508 UINT
msi_dialog_directorylist_up( msi_dialog
*dialog
)
2510 msi_control
*control
;
2511 LPWSTR prop
, path
, ptr
;
2514 control
= msi_dialog_find_control_by_type( dialog
, szDirectoryList
);
2515 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
2516 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
2517 path
= msi_dialog_dup_property( dialog
, prop
, TRUE
);
2519 /* strip off the last directory */
2520 ptr
= PathFindFileNameW( path
);
2521 if (ptr
!= path
) *(ptr
- 1) = '\0';
2522 PathAddBackslashW( path
);
2524 MSI_SetPropertyW( dialog
->package
, prop
, path
);
2526 msi_dialog_update_directory_list( dialog
, NULL
);
2527 msi_dialog_update_directory_combo( dialog
, NULL
);
2528 msi_dialog_update_pathedit( dialog
, NULL
);
2533 return ERROR_SUCCESS
;
2536 static UINT
msi_dialog_dirlist_handler( msi_dialog
*dialog
,
2537 msi_control
*control
, WPARAM param
)
2539 LPNMHDR nmhdr
= (LPNMHDR
)param
;
2540 WCHAR new_path
[MAX_PATH
];
2541 WCHAR text
[MAX_PATH
];
2547 if (nmhdr
->code
!= LVN_ITEMACTIVATE
)
2548 return ERROR_SUCCESS
;
2550 index
= SendMessageW( control
->hwnd
, LVM_GETNEXTITEM
, -1, LVNI_SELECTED
);
2553 ERR("No list-view item selected!\n");
2554 return ERROR_FUNCTION_FAILED
;
2558 item
.pszText
= text
;
2559 item
.cchTextMax
= MAX_PATH
;
2560 SendMessageW( control
->hwnd
, LVM_GETITEMTEXTW
, index
, (LPARAM
)&item
);
2562 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
2563 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
2564 path
= msi_dialog_dup_property( dialog
, prop
, TRUE
);
2566 lstrcpyW( new_path
, path
);
2567 lstrcatW( new_path
, text
);
2568 lstrcatW( new_path
, szBackSlash
);
2570 MSI_SetPropertyW( dialog
->package
, prop
, new_path
);
2572 msi_dialog_update_directory_list( dialog
, NULL
);
2573 msi_dialog_update_directory_combo( dialog
, NULL
);
2574 msi_dialog_update_pathedit( dialog
, NULL
);
2578 return ERROR_SUCCESS
;
2581 static UINT
msi_dialog_directory_list( msi_dialog
*dialog
, MSIRECORD
*rec
)
2583 msi_control
*control
;
2587 style
= LVS_LIST
| WS_VSCROLL
| LVS_SHAREIMAGELISTS
|
2588 LVS_AUTOARRANGE
| LVS_SINGLESEL
| WS_BORDER
|
2589 LVS_SORTASCENDING
| WS_CHILD
| WS_GROUP
| WS_TABSTOP
;
2590 control
= msi_dialog_add_control( dialog
, rec
, WC_LISTVIEWW
, style
);
2592 return ERROR_FUNCTION_FAILED
;
2594 control
->attributes
= MSI_RecordGetInteger( rec
, 8 );
2595 control
->handler
= msi_dialog_dirlist_handler
;
2596 prop
= MSI_RecordGetString( rec
, 9 );
2597 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
2599 /* double click to activate an item in the list */
2600 SendMessageW( control
->hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
,
2601 0, LVS_EX_TWOCLICKACTIVATE
);
2603 msi_dialog_update_directory_list( dialog
, control
);
2605 return ERROR_SUCCESS
;
2608 /******************** VolumeCost List ***************************************/
2610 static BOOL
str_is_number( LPCWSTR str
)
2614 for (i
= 0; i
< lstrlenW( str
); i
++)
2615 if (!isdigitW(str
[i
]))
2621 static const WCHAR column_keys
[][80] =
2623 {'V','o','l','u','m','e','C','o','s','t','V','o','l','u','m','e',0},
2624 {'V','o','l','u','m','e','C','o','s','t','S','i','z','e',0},
2625 {'V','o','l','u','m','e','C','o','s','t','A','v','a','i','l','a','b','l','e',0},
2626 {'V','o','l','u','m','e','C','o','s','t','R','e','q','u','i','r','e','d',0},
2627 {'V','o','l','u','m','e','C','o','s','t','D','i','f','f','e','r','e','n','c','e',0}
2630 static void msi_dialog_vcl_add_columns( msi_dialog
*dialog
, msi_control
*control
, MSIRECORD
*rec
)
2632 LPCWSTR text
= MSI_RecordGetString( rec
, 10 );
2633 LPCWSTR begin
= text
, end
;
2638 static const WCHAR negative
[] = {'-',0};
2642 while ((begin
= strchrW( begin
, '{' )) && count
< 5)
2644 if (!(end
= strchrW( begin
, '}' )))
2647 num
= msi_alloc( (end
-begin
+1)*sizeof(WCHAR
) );
2651 lstrcpynW( num
, begin
+ 1, end
- begin
);
2652 begin
+= end
- begin
+ 1;
2654 /* empty braces or '0' hides the column */
2655 if ( !num
[0] || !lstrcmpW( num
, szZero
) )
2662 /* the width must be a positive number
2663 * if a width is invalid, all remaining columns are hidden
2665 if ( !strncmpW( num
, negative
, 1 ) || !str_is_number( num
) ) {
2670 ZeroMemory( &lvc
, sizeof(lvc
) );
2671 lvc
.mask
= LVCF_TEXT
| LVCF_WIDTH
| LVCF_SUBITEM
;
2672 lvc
.cx
= atolW( num
);
2673 lvc
.pszText
= msi_dialog_get_uitext( dialog
, column_keys
[count
] );
2675 SendMessageW( control
->hwnd
, LVM_INSERTCOLUMNW
, count
++, (LPARAM
)&lvc
);
2676 msi_free( lvc
.pszText
);
2681 static LONGLONG
msi_vcl_get_cost( msi_dialog
*dialog
)
2683 MSIFEATURE
*feature
;
2685 LONGLONG total_cost
= 0;
2687 LIST_FOR_EACH_ENTRY( feature
, &dialog
->package
->features
, MSIFEATURE
, entry
)
2689 if (ERROR_SUCCESS
== (MSI_GetFeatureCost(dialog
->package
, feature
,
2690 MSICOSTTREE_SELFONLY
, INSTALLSTATE_LOCAL
, &each_cost
)))
2692 /* each_cost is in 512-byte units */
2693 total_cost
+= each_cost
* 512;
2695 if (ERROR_SUCCESS
== (MSI_GetFeatureCost(dialog
->package
, feature
,
2696 MSICOSTTREE_SELFONLY
, INSTALLSTATE_ABSENT
, &each_cost
)))
2698 /* each_cost is in 512-byte units */
2699 total_cost
-= each_cost
* 512;
2705 static void msi_dialog_vcl_add_drives( msi_dialog
*dialog
, msi_control
*control
)
2707 ULARGE_INTEGER total
, free
;
2708 LONGLONG difference
, cost
;
2709 WCHAR size_text
[MAX_PATH
];
2710 WCHAR cost_text
[MAX_PATH
];
2716 cost
= msi_vcl_get_cost(dialog
);
2717 StrFormatByteSizeW(cost
, cost_text
, MAX_PATH
);
2719 size
= GetLogicalDriveStringsW( 0, NULL
);
2720 if ( !size
) return;
2722 drives
= msi_alloc( (size
+ 1) * sizeof(WCHAR
) );
2723 if ( !drives
) return;
2725 GetLogicalDriveStringsW( size
, drives
);
2730 lvitem
.mask
= LVIF_TEXT
;
2732 lvitem
.iSubItem
= 0;
2733 lvitem
.pszText
= ptr
;
2734 lvitem
.cchTextMax
= lstrlenW(ptr
) + 1;
2735 SendMessageW( control
->hwnd
, LVM_INSERTITEMW
, 0, (LPARAM
)&lvitem
);
2737 GetDiskFreeSpaceExW(ptr
, &free
, &total
, NULL
);
2738 difference
= free
.QuadPart
- cost
;
2740 StrFormatByteSizeW(total
.QuadPart
, size_text
, MAX_PATH
);
2741 lvitem
.iSubItem
= 1;
2742 lvitem
.pszText
= size_text
;
2743 lvitem
.cchTextMax
= lstrlenW(size_text
) + 1;
2744 SendMessageW( control
->hwnd
, LVM_SETITEMW
, 0, (LPARAM
)&lvitem
);
2746 StrFormatByteSizeW(free
.QuadPart
, size_text
, MAX_PATH
);
2747 lvitem
.iSubItem
= 2;
2748 lvitem
.pszText
= size_text
;
2749 lvitem
.cchTextMax
= lstrlenW(size_text
) + 1;
2750 SendMessageW( control
->hwnd
, LVM_SETITEMW
, 0, (LPARAM
)&lvitem
);
2752 lvitem
.iSubItem
= 3;
2753 lvitem
.pszText
= cost_text
;
2754 lvitem
.cchTextMax
= lstrlenW(cost_text
) + 1;
2755 SendMessageW( control
->hwnd
, LVM_SETITEMW
, 0, (LPARAM
)&lvitem
);
2757 StrFormatByteSizeW(difference
, size_text
, MAX_PATH
);
2758 lvitem
.iSubItem
= 4;
2759 lvitem
.pszText
= size_text
;
2760 lvitem
.cchTextMax
= lstrlenW(size_text
) + 1;
2761 SendMessageW( control
->hwnd
, LVM_SETITEMW
, 0, (LPARAM
)&lvitem
);
2763 ptr
+= lstrlenW(ptr
) + 1;
2770 static UINT
msi_dialog_volumecost_list( msi_dialog
*dialog
, MSIRECORD
*rec
)
2772 msi_control
*control
;
2775 style
= LVS_REPORT
| WS_VSCROLL
| WS_HSCROLL
| LVS_SHAREIMAGELISTS
|
2776 LVS_AUTOARRANGE
| LVS_SINGLESEL
| WS_BORDER
|
2777 WS_CHILD
| WS_TABSTOP
| WS_GROUP
;
2778 control
= msi_dialog_add_control( dialog
, rec
, WC_LISTVIEWW
, style
);
2780 return ERROR_FUNCTION_FAILED
;
2782 msi_dialog_vcl_add_columns( dialog
, control
, rec
);
2783 msi_dialog_vcl_add_drives( dialog
, control
);
2785 return ERROR_SUCCESS
;
2788 /******************** VolumeSelect Combo ***************************************/
2790 static UINT
msi_dialog_volsel_handler( msi_dialog
*dialog
,
2791 msi_control
*control
, WPARAM param
)
2793 WCHAR text
[MAX_PATH
];
2798 if (HIWORD(param
) != CBN_SELCHANGE
)
2799 return ERROR_SUCCESS
;
2801 index
= SendMessageW( control
->hwnd
, CB_GETCURSEL
, 0, 0 );
2802 if ( index
== CB_ERR
)
2804 ERR("No ComboBox item selected!\n");
2805 return ERROR_FUNCTION_FAILED
;
2808 SendMessageW( control
->hwnd
, CB_GETLBTEXT
, index
, (LPARAM
)text
);
2810 indirect
= control
->attributes
& msidbControlAttributesIndirect
;
2811 prop
= msi_dialog_dup_property( dialog
, control
->property
, indirect
);
2813 MSI_SetPropertyW( dialog
->package
, prop
, text
);
2816 return ERROR_SUCCESS
;
2819 static void msi_dialog_vsc_add_drives( msi_dialog
*dialog
, msi_control
*control
)
2824 size
= GetLogicalDriveStringsW( 0, NULL
);
2825 if ( !size
) return;
2827 drives
= msi_alloc( (size
+ 1) * sizeof(WCHAR
) );
2828 if ( !drives
) return;
2830 GetLogicalDriveStringsW( size
, drives
);
2835 SendMessageW( control
->hwnd
, CB_ADDSTRING
, 0, (LPARAM
)ptr
);
2836 ptr
+= lstrlenW(ptr
) + 1;
2842 static UINT
msi_dialog_volumeselect_combo( msi_dialog
*dialog
, MSIRECORD
*rec
)
2844 msi_control
*control
;
2848 /* FIXME: CBS_OWNERDRAWFIXED */
2849 style
= WS_CHILD
| WS_VISIBLE
| WS_GROUP
| WS_TABSTOP
|
2850 CBS_DROPDOWNLIST
| CBS_SORT
| CBS_HASSTRINGS
|
2851 WS_EX_LEFT
| WS_EX_LTRREADING
| WS_EX_RIGHTSCROLLBAR
;
2852 control
= msi_dialog_add_control( dialog
, rec
, WC_COMBOBOXW
, style
);
2854 return ERROR_FUNCTION_FAILED
;
2856 control
->attributes
= MSI_RecordGetInteger( rec
, 8 );
2857 control
->handler
= msi_dialog_volsel_handler
;
2858 prop
= MSI_RecordGetString( rec
, 9 );
2859 control
->property
= msi_dialog_dup_property( dialog
, prop
, FALSE
);
2861 msi_dialog_vsc_add_drives( dialog
, control
);
2863 return ERROR_SUCCESS
;
2866 static const struct control_handler msi_dialog_handler
[] =
2868 { szText
, msi_dialog_text_control
},
2869 { szPushButton
, msi_dialog_button_control
},
2870 { szLine
, msi_dialog_line_control
},
2871 { szBitmap
, msi_dialog_bitmap_control
},
2872 { szCheckBox
, msi_dialog_checkbox_control
},
2873 { szScrollableText
, msi_dialog_scrolltext_control
},
2874 { szComboBox
, msi_dialog_combo_control
},
2875 { szEdit
, msi_dialog_edit_control
},
2876 { szMaskedEdit
, msi_dialog_maskedit_control
},
2877 { szPathEdit
, msi_dialog_pathedit_control
},
2878 { szProgressBar
, msi_dialog_progress_bar
},
2879 { szRadioButtonGroup
, msi_dialog_radiogroup_control
},
2880 { szIcon
, msi_dialog_icon_control
},
2881 { szSelectionTree
, msi_dialog_selection_tree
},
2882 { szGroupBox
, msi_dialog_group_box
},
2883 { szListBox
, msi_dialog_list_box
},
2884 { szDirectoryCombo
, msi_dialog_directory_combo
},
2885 { szDirectoryList
, msi_dialog_directory_list
},
2886 { szVolumeCostList
, msi_dialog_volumecost_list
},
2887 { szVolumeSelectCombo
, msi_dialog_volumeselect_combo
},
2890 #define NUM_CONTROL_TYPES (sizeof msi_dialog_handler/sizeof msi_dialog_handler[0])
2892 static UINT
msi_dialog_create_controls( MSIRECORD
*rec
, LPVOID param
)
2894 msi_dialog
*dialog
= param
;
2895 LPCWSTR control_type
;
2898 /* find and call the function that can create this type of control */
2899 control_type
= MSI_RecordGetString( rec
, 3 );
2900 for( i
=0; i
<NUM_CONTROL_TYPES
; i
++ )
2901 if (!strcmpiW( msi_dialog_handler
[i
].control_type
, control_type
))
2903 if( i
!= NUM_CONTROL_TYPES
)
2904 msi_dialog_handler
[i
].func( dialog
, rec
);
2906 ERR("no handler for element type %s\n", debugstr_w(control_type
));
2908 return ERROR_SUCCESS
;
2911 static UINT
msi_dialog_fill_controls( msi_dialog
*dialog
)
2913 static const WCHAR query
[] = {
2914 'S','E','L','E','C','T',' ','*',' ',
2915 'F','R','O','M',' ','C','o','n','t','r','o','l',' ',
2916 'W','H','E','R','E',' ',
2917 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0};
2919 MSIQUERY
*view
= NULL
;
2920 MSIPACKAGE
*package
= dialog
->package
;
2922 TRACE("%p %s\n", dialog
, debugstr_w(dialog
->name
) );
2924 /* query the Control table for all the elements of the control */
2925 r
= MSI_OpenQuery( package
->db
, &view
, query
, dialog
->name
);
2926 if( r
!= ERROR_SUCCESS
)
2928 ERR("query failed for dialog %s\n", debugstr_w(dialog
->name
));
2929 return ERROR_INVALID_PARAMETER
;
2932 r
= MSI_IterateRecords( view
, 0, msi_dialog_create_controls
, dialog
);
2933 msiobj_release( &view
->hdr
);
2938 static UINT
msi_dialog_set_control_condition( MSIRECORD
*rec
, LPVOID param
)
2940 static const WCHAR szHide
[] = { 'H','i','d','e',0 };
2941 static const WCHAR szShow
[] = { 'S','h','o','w',0 };
2942 static const WCHAR szDisable
[] = { 'D','i','s','a','b','l','e',0 };
2943 static const WCHAR szEnable
[] = { 'E','n','a','b','l','e',0 };
2944 static const WCHAR szDefault
[] = { 'D','e','f','a','u','l','t',0 };
2945 msi_dialog
*dialog
= param
;
2946 msi_control
*control
;
2947 LPCWSTR name
, action
, condition
;
2950 name
= MSI_RecordGetString( rec
, 2 );
2951 action
= MSI_RecordGetString( rec
, 3 );
2952 condition
= MSI_RecordGetString( rec
, 4 );
2953 r
= MSI_EvaluateConditionW( dialog
->package
, condition
);
2954 control
= msi_dialog_find_control( dialog
, name
);
2955 if( r
== MSICONDITION_TRUE
&& control
)
2957 TRACE("%s control %s\n", debugstr_w(action
), debugstr_w(name
));
2959 /* FIXME: case sensitive? */
2960 if(!lstrcmpW(action
, szHide
))
2961 ShowWindow(control
->hwnd
, SW_HIDE
);
2962 else if(!strcmpW(action
, szShow
))
2963 ShowWindow(control
->hwnd
, SW_SHOW
);
2964 else if(!strcmpW(action
, szDisable
))
2965 EnableWindow(control
->hwnd
, FALSE
);
2966 else if(!strcmpW(action
, szEnable
))
2967 EnableWindow(control
->hwnd
, TRUE
);
2968 else if(!strcmpW(action
, szDefault
))
2969 SetFocus(control
->hwnd
);
2971 FIXME("Unhandled action %s\n", debugstr_w(action
));
2974 return ERROR_SUCCESS
;
2977 static UINT
msi_dialog_evaluate_control_conditions( msi_dialog
*dialog
)
2979 static const WCHAR query
[] = {
2980 'S','E','L','E','C','T',' ','*',' ',
2981 'F','R','O','M',' ',
2982 'C','o','n','t','r','o','l','C','o','n','d','i','t','i','o','n',' ',
2983 'W','H','E','R','E',' ',
2984 '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0
2987 MSIQUERY
*view
= NULL
;
2988 MSIPACKAGE
*package
= dialog
->package
;
2990 TRACE("%p %s\n", dialog
, debugstr_w(dialog
->name
) );
2992 /* query the Control table for all the elements of the control */
2993 r
= MSI_OpenQuery( package
->db
, &view
, query
, dialog
->name
);
2994 if( r
!= ERROR_SUCCESS
)
2995 return ERROR_SUCCESS
;
2997 r
= MSI_IterateRecords( view
, 0, msi_dialog_set_control_condition
, dialog
);
2998 msiobj_release( &view
->hdr
);
3003 UINT
msi_dialog_reset( msi_dialog
*dialog
)
3005 /* FIXME: should restore the original values of any properties we changed */
3006 return msi_dialog_evaluate_control_conditions( dialog
);
3009 /* figure out the height of 10 point MS Sans Serif */
3010 static INT
msi_dialog_get_sans_serif_height( HWND hwnd
)
3012 static const WCHAR szSansSerif
[] = {
3013 'M','S',' ','S','a','n','s',' ','S','e','r','i','f',0 };
<