Module: wine Branch: master Commit: 8f691adf7e4ac27d8ea0f45ca19b9b695244ffc7 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=8f691adf7e4ac27d8ea0f45c...
Author: James Hawkins truiken@gmail.com Date: Fri Sep 1 14:00:19 2006 -0700
msi: Load and display the VolumeCostList control's column headers.
---
dlls/msi/dialog.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/dlls/msi/dialog.c b/dlls/msi/dialog.c index 6785e77..b9163b4 100644 --- a/dlls/msi/dialog.c +++ b/dlls/msi/dialog.c @@ -408,6 +408,24 @@ static msi_control *msi_dialog_create_wi return control; }
+static LPWSTR msi_dialog_get_uitext( msi_dialog *dialog, LPCWSTR key ) +{ + MSIRECORD *rec; + LPWSTR text; + + static const WCHAR query[] = { + 's','e','l','e','c','t',' ','*',' ', + 'f','r','o','m',' ','`','U','I','T','e','x','t','`',' ', + 'w','h','e','r','e',' ','`','K','e','y','`',' ','=',' ',''','%','s',''',0 + }; + + rec = MSI_QueryGetRecord( dialog->package->db, query, key ); + if (!rec) return NULL; + text = strdupW( MSI_RecordGetString( rec, 2 ) ); + msiobj_release( &rec->hdr ); + return text; +} + static MSIRECORD *msi_get_binary_record( MSIDATABASE *db, LPCWSTR name ) { static const WCHAR query[] = { @@ -2138,6 +2156,71 @@ static UINT msi_dialog_directory_list( m
/******************** VolumeCost List ***************************************/
+static BOOL str_is_number( LPCWSTR str ) +{ + int i; + + for (i = 0; i < lstrlenW( str ); i++) + if (!isdigitW(str[i])) + return FALSE; + + return TRUE; +} + +WCHAR column_keys[][80] = +{ + {'V','o','l','u','m','e','C','o','s','t','V','o','l','u','m','e',0}, + {'V','o','l','u','m','e','C','o','s','t','S','i','z','e',0}, + {'V','o','l','u','m','e','C','o','s','t','A','v','a','i','l','a','b','l','e',0}, + {'V','o','l','u','m','e','C','o','s','t','R','e','q','u','i','r','e','d',0}, + {'V','o','l','u','m','e','C','o','s','t','D','i','f','f','e','r','e','n','c','e',0} +}; + +static void msi_dialog_vcl_add_columns( msi_dialog *dialog, msi_control *control, MSIRECORD *rec ) +{ + LPCWSTR text = MSI_RecordGetString( rec, 10 ); + LPCWSTR begin = text, end; + WCHAR num[10]; + LVCOLUMNW lvc; + DWORD count = 0; + LRESULT r; + + static const WCHAR zero[] = {'0',0}; + static const WCHAR negative[] = {'-',0}; + + while ((begin = strchrW( begin, '{' )) && count < 5) + { + if (!(end = strchrW( begin, '}' ))) + return; + + lstrcpynW( num, begin + 1, end - begin ); + begin += end - begin + 1; + + /* empty braces or '0' hides the column */ + if ( !num[0] || !lstrcmpW( num, zero ) ) + { + count++; + continue; + } + + /* the width must be a positive number + * if a width is invalid, all remaining columns are hidden + */ + if ( !strncmpW( num, negative, 1 ) || !str_is_number( num ) ) + return; + + lvc.mask = LVCF_FMT | LVCF_ORDER | LVCF_WIDTH | LVCF_TEXT; + lvc.iOrder = count; + lvc.pszText = msi_dialog_get_uitext( dialog, column_keys[count++] ); + lvc.cx = atolW( num ); + lvc.fmt = LVCFMT_LEFT; + + r = SendMessageW( control->hwnd, LVM_INSERTCOLUMNW, 0, (LPARAM)&lvc ); + msi_free( lvc.pszText ); + if ( r ) return; + } +} + static UINT msi_dialog_volumecost_list( msi_dialog *dialog, MSIRECORD *rec ) { msi_control *control; @@ -2150,6 +2233,8 @@ static UINT msi_dialog_volumecost_list( if (!control) return ERROR_FUNCTION_FAILED;
+ msi_dialog_vcl_add_columns( dialog, control, rec ); + return ERROR_SUCCESS; }