Re: Add localizable strings support for popup menu in selection tree control.
On 2/26/07, Крылов Николай <krna(a)rambler.ru> wrote:
diff --git a/dlls/msi/dialog.c b/dlls/msi/dialog.c index 35a192c..3826326 100644 --- a/dlls/msi/dialog.c +++ b/dlls/msi/dialog.c @@ -1755,17 +1755,41 @@ msi_seltree_popup_menu( HWND hwnd, INT x HMENU hMenu; INT r;
+ static const WCHAR szMenuLocal[] = {'M','e','n','u','L','o','c','a','l',0}; + static const WCHAR szMenuAllLocal[] = {'M','e','n','u','A','l','l','L','o','c','a','l',0}; + static const WCHAR szMenuAdvertise[] = {'M','e','n','u','A','d','v','e','r','t','i','s','e',0}; + static const WCHAR szMenuAbsent[] = {'M','e','n','u','A','b','s','e','n','t',0}; + /* If msi_dialog_get_uitext returns NULL - use default strings: */ + static const WCHAR szMenuLocalDef[] = {'I','n','s','t','a','l','l',' ','f','e','a','t','u','r','e',' ', 'l','o','c','a','l','l','y',0}; + static const WCHAR szMenuAllLocalDef[] = {'I','n','s','t','a','l','l',' ','e','n','t','i','r','e',' ','f','e','a','t','u','r','e',0}; + static const WCHAR szMenuAdvertiseDef[] = {'I','n','s','t','a','l','l',' ','o','n',' ','d','e','m','a','n','d',0}; + static const WCHAR szMenuAbsentDef[] = {'D','o','n','\'','t',' ','i','n','s','t','a','l','l',0}; + + LPWSTR szLocal,szAllLocal,szAdvertise,szAbsent; + struct msi_selection_tree_info *info; + + info = GetPropW(hwnd, szButtonData); + + szLocal= msi_dialog_get_uitext( info->dialog, szMenuLocal ); + szAllLocal= msi_dialog_get_uitext( info->dialog, szMenuAllLocal ); + szAdvertise= msi_dialog_get_uitext( info->dialog, szMenuAdvertise ); + szAbsent= msi_dialog_get_uitext( info->dialog, szMenuAbsent ); + /* create a menu to display */ hMenu = CreatePopupMenu();
- /* FIXME: load strings from resources */ - AppendMenuA( hMenu, MF_ENABLED, INSTALLSTATE_LOCAL, "Install feature locally"); - AppendMenuA( hMenu, MF_GRAYED, 0x1000, "Install entire feature"); - AppendMenuA( hMenu, MF_ENABLED, INSTALLSTATE_ADVERTISED, "Install on demand"); - AppendMenuA( hMenu, MF_ENABLED, INSTALLSTATE_ABSENT, "Don't install"); + /* Use strings from resources */ + AppendMenuW( hMenu, MF_ENABLED, INSTALLSTATE_LOCAL, (szLocal==NULL)?szMenuLocalDef:szLocal ); + AppendMenuW( hMenu, MF_GRAYED, 0x1000, (szAllLocal==NULL)?szMenuAllLocalDef:szAllLocal ); + AppendMenuW( hMenu, MF_ENABLED, INSTALLSTATE_ADVERTISED, (szAdvertise==NULL)?szMenuAdvertiseDef:szAdvertise ); + AppendMenuW( hMenu, MF_ENABLED, INSTALLSTATE_ABSENT, (szAbsent==NULL)?szMenuAbsentDef:szAbsent ); r = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD, x, y, 0, hwnd, NULL ); DestroyMenu( hMenu ); + if(szLocal) msi_free(szLocal); + if(szAllLocal) msi_free(szAllLocal); + if(szAdvertise) msi_free(szAdvertise); + if(szAbsent) msi_free(szAbsent); return r; }
Don't check values for NULL before freeing them. The check is redundant, and we spent a long time removing such checks. -- James Hawkins
participants (1)
-
James Hawkins