Module: wine Branch: master Commit: 2812a9ecefb547b931c8b953934fe86ab5335f5c URL: http://source.winehq.org/git/wine.git/?a=commit;h=2812a9ecefb547b931c8b95393...
Author: Owen Rudge owen@owenrudge.net Date: Mon Jul 21 19:42:12 2008 +0100
appwiz.cpl: Add column headers to listview.
---
dlls/appwiz.cpl/En.rc | 4 ++ dlls/appwiz.cpl/appwiz.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++ dlls/appwiz.cpl/res.h | 3 ++ 3 files changed, 87 insertions(+), 0 deletions(-)
diff --git a/dlls/appwiz.cpl/En.rc b/dlls/appwiz.cpl/En.rc index ad477e3..1abc788 100644 --- a/dlls/appwiz.cpl/En.rc +++ b/dlls/appwiz.cpl/En.rc @@ -26,6 +26,10 @@ STRINGTABLE IDS_CPL_TITLE, "Add/Remove Programs" IDS_CPL_DESC, "Allows you to install new software, or remove existing software from your computer." IDS_TAB1_TITLE, "Applications" + + IDS_COLUMN_NAME, "Name" + IDS_COLUMN_PUBLISHER, "Publisher" + IDS_COLUMN_VERSION, "Version" }
/* TODO: it's best to use the constant WC_LISTVIEW instead of SysListView32 directly, but the Wine resource compiler doesn't seem to like that... */ diff --git a/dlls/appwiz.cpl/appwiz.c b/dlls/appwiz.cpl/appwiz.c index fd06371..b07c2a7 100644 --- a/dlls/appwiz.cpl/appwiz.c +++ b/dlls/appwiz.cpl/appwiz.c @@ -68,6 +68,76 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, return TRUE; }
+/* Definition of column headers for AddListViewColumns function */ +typedef struct AppWizColumn { + int width; + int fmt; + int title; +} AppWizColumn; + +AppWizColumn columns[] = { + {200, LVCFMT_LEFT, IDS_COLUMN_NAME}, + {150, LVCFMT_LEFT, IDS_COLUMN_PUBLISHER}, + {100, LVCFMT_LEFT, IDS_COLUMN_VERSION}, +}; + +/****************************************************************************** + * Name : AddListViewColumns + * Description: Adds column headers to the list view control. + * Parameters : hWnd - Handle of the list view control. + * Returns : TRUE if completed successfully, FALSE otherwise. + */ +static BOOL AddListViewColumns(HWND hWnd) +{ + WCHAR buf[MAX_STRING_LEN]; + LVCOLUMNW lvc; + int i; + + lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH; + + /* Add the columns */ + for (i = 0; i < sizeof(columns) / sizeof(columns[0]); i++) + { + lvc.iSubItem = i; + lvc.pszText = buf; + + /* set width and format */ + lvc.cx = columns[i].width; + lvc.fmt = columns[i].fmt; + + LoadStringW(hInst, columns[i].title, buf, sizeof(buf) / sizeof(buf[0])); + + if (ListView_InsertColumnW(hWnd, i, &lvc) == -1) + return FALSE; + } + + return TRUE; +} + +/****************************************************************************** + * Name : ResetApplicationList + * Description: Empties the app list, if need be, and recreates it. + * Parameters : bFirstRun - TRUE if this is the first time this is run, FALSE otherwise + * hWnd - handle of the dialog box + * hImageList - handle of the image list + * Returns : New handle of the image list. + */ +static HIMAGELIST ResetApplicationList(BOOL bFirstRun, HWND hWnd, HIMAGELIST hImageList) +{ + HWND hWndListView; + + hWndListView = GetDlgItem(hWnd, IDL_PROGRAMS); + + /* if first run, create the image list and add the listview columns */ + if (bFirstRun) + { + if (!AddListViewColumns(hWndListView)) + return NULL; + } + + return(hImageList); +} + /****************************************************************************** * Name : MainDlgProc * Description: Callback procedure for main tab @@ -79,6 +149,16 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, */ static BOOL CALLBACK MainDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { + static HIMAGELIST hImageList; + + switch(msg) + { + case WM_INITDIALOG: + hImageList = ResetApplicationList(TRUE, hWnd, hImageList); + + return TRUE; + } + return FALSE; }
diff --git a/dlls/appwiz.cpl/res.h b/dlls/appwiz.cpl/res.h index ff23bcb..64b4a5b 100644 --- a/dlls/appwiz.cpl/res.h +++ b/dlls/appwiz.cpl/res.h @@ -38,3 +38,6 @@ #define IDS_CPL_TITLE 1 #define IDS_CPL_DESC 2 #define IDS_TAB1_TITLE 3 +#define IDS_COLUMN_NAME 6 +#define IDS_COLUMN_PUBLISHER 7 +#define IDS_COLUMN_VERSION 8