appwiz.cpl: Add column headers to listview.

This commit is contained in:
Owen Rudge 2008-07-21 19:42:12 +01:00 committed by Alexandre Julliard
parent 6d4f3d5d3a
commit 2812a9ecef
3 changed files with 87 additions and 0 deletions

View File

@ -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... */

View File

@ -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;
}

View File

@ -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