i just want groups to work man PLEASe man well listview looks like it works so that's something i guess but now i gotta really add items to it oh my GOD
This commit is contained in:
@@ -19,6 +19,9 @@
|
|||||||
#include <Shlobj.h>
|
#include <Shlobj.h>
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
|
|
||||||
|
/* Variables */
|
||||||
|
WCHAR szDlgTitle[64];
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
|
|
||||||
/* * * *\
|
/* * * *\
|
||||||
@@ -36,6 +39,8 @@ BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM
|
|||||||
.szName = L"",
|
.szName = L"",
|
||||||
.dwFlags = 0,
|
.dwFlags = 0,
|
||||||
.ftLastWrite = 0,
|
.ftLastWrite = 0,
|
||||||
|
.szIconPath = L"",
|
||||||
|
.iIconIndex = 0,
|
||||||
.cItems = 0,
|
.cItems = 0,
|
||||||
.iItems = NULL
|
.iItems = NULL
|
||||||
};
|
};
|
||||||
@@ -43,7 +48,6 @@ BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM
|
|||||||
WCHAR szBuffer[MAX_TITLE_LENGTH] = { L"\0" };
|
WCHAR szBuffer[MAX_TITLE_LENGTH] = { L"\0" };
|
||||||
HICON hIconDef = NULL;
|
HICON hIconDef = NULL;
|
||||||
HICON hIconDlg = NULL;
|
HICON hIconDlg = NULL;
|
||||||
WCHAR szIconPath[MAX_PATH] = { L"\0" };
|
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
@@ -54,16 +58,20 @@ BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM
|
|||||||
// if permissions are available.
|
// if permissions are available.
|
||||||
// TODO:
|
// TODO:
|
||||||
// fix minor GDI font/region leak
|
// fix minor GDI font/region leak
|
||||||
|
|
||||||
|
// Set the window title
|
||||||
|
LoadString(hAppInstance, IDS_DLT_GRP_NEW, szDlgTitle, ARRAYSIZE(szDlgTitle));
|
||||||
|
SetWindowText(hWndDlg, szDlgTitle);
|
||||||
|
|
||||||
// Populate the icon with the default path and index.
|
// Populate the icon with the default path and index.
|
||||||
GetModuleFileName(NULL, (LPWSTR)&szIconPath, MAX_PATH);
|
GetModuleFileName(hAppInstance, (LPWSTR)&grp.szIconPath, ARRAYSIZE(grp.szIconPath));
|
||||||
grp.iIconIndex = IDI_PROGGRP - 1;
|
grp.iIconIndex = IDI_PROGGRP - 1;
|
||||||
|
|
||||||
// Get the default hIcon so we can delete it later
|
// Get the default hIcon so we can delete it later
|
||||||
hIconDef = (HICON)SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_GETICON, 0, 0);
|
hIconDef = (HICON)SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_GETICON, 0, 0);
|
||||||
|
|
||||||
// Set the icon in the dialog
|
// Set the icon in the dialog
|
||||||
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&szIconPath, grp.iIconIndex);
|
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&grp.szIconPath, grp.iIconIndex);
|
||||||
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
|
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
|
||||||
|
|
||||||
// Set the maximum input length of the text boxes
|
// Set the maximum input length of the text boxes
|
||||||
@@ -81,11 +89,7 @@ BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM
|
|||||||
if (LOWORD(wParam) == IDD_NAME)
|
if (LOWORD(wParam) == IDD_NAME)
|
||||||
{
|
{
|
||||||
// Name text control changed. See what's up...
|
// Name text control changed. See what's up...
|
||||||
if (bOKEnabled = GetDlgItemText(hWndDlg, IDD_NAME, (LPWSTR)&szBuffer, ARRAYSIZE(szBuffer)))
|
bOKEnabled = GetDlgItemText(hWndDlg, IDD_NAME, (LPWSTR)&szBuffer, ARRAYSIZE(szBuffer));
|
||||||
{
|
|
||||||
// Set the name of the group
|
|
||||||
StringCchCopy(grp.szName, ARRAYSIZE(szBuffer), szBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable or disable the OK button based on the information
|
// Enable or disable the OK button based on the information
|
||||||
EnableWindow(GetDlgItem(hWndDlg, IDD_OK), bOKEnabled);
|
EnableWindow(GetDlgItem(hWndDlg, IDD_OK), bOKEnabled);
|
||||||
@@ -96,19 +100,17 @@ BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM
|
|||||||
{
|
{
|
||||||
|
|
||||||
case IDD_CHICON:
|
case IDD_CHICON:
|
||||||
if (PickIconDlg(hWndDlg, (LPWSTR)&szIconPath, ARRAYSIZE(szIconPath), &grp.iIconIndex) == TRUE)
|
if (PickIconDlg(hWndDlg, (LPWSTR)&grp.szIconPath, ARRAYSIZE(grp.szIconPath), &grp.iIconIndex) == TRUE)
|
||||||
{
|
{
|
||||||
// Since we've got the new icon...
|
// Since we've got the new icon...
|
||||||
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&szIconPath, grp.iIconIndex);
|
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&grp.szIconPath, grp.iIconIndex);
|
||||||
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
|
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
|
||||||
|
|
||||||
// Populate the icon varialbes
|
|
||||||
StringCchCopy(grp.szIconPath, ARRAYSIZE(szIconPath), szIconPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDD_OK:
|
case IDD_OK:
|
||||||
|
|
||||||
// Check that all the applicable fields are filled out,
|
// Check that all the applicable fields are filled out,
|
||||||
// and if not then set the focus to the offending field
|
// and if not then set the focus to the offending field
|
||||||
if (!(bOKEnabled = GetDlgItemText(hWndDlg, IDD_NAME, (LPWSTR)&szBuffer, ARRAYSIZE(szBuffer))))
|
if (!(bOKEnabled = GetDlgItemText(hWndDlg, IDD_NAME, (LPWSTR)&szBuffer, ARRAYSIZE(szBuffer))))
|
||||||
@@ -119,6 +121,9 @@ BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM
|
|||||||
|
|
||||||
if (bOKEnabled)
|
if (bOKEnabled)
|
||||||
{
|
{
|
||||||
|
// Set the name of the group
|
||||||
|
StringCchCopy(grp.szName, ARRAYSIZE(szBuffer), szBuffer);
|
||||||
|
|
||||||
// Set the flags of the group
|
// Set the flags of the group
|
||||||
if (SendDlgItemMessage(hWndDlg, IDD_COMMGROUP, BM_GETCHECK, 0, 0) != BST_UNCHECKED)
|
if (SendDlgItemMessage(hWndDlg, IDD_COMMGROUP, BM_GETCHECK, 0, 0) != BST_UNCHECKED)
|
||||||
grp.dwFlags = grp.dwFlags || GRP_FLAG_COMMON;
|
grp.dwFlags = grp.dwFlags || GRP_FLAG_COMMON;
|
||||||
@@ -188,8 +193,6 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l
|
|||||||
WCHAR szBuffer[MAX_TITLE_LENGTH] = { L"\0" };
|
WCHAR szBuffer[MAX_TITLE_LENGTH] = { L"\0" };
|
||||||
HICON hIconDef = NULL;
|
HICON hIconDef = NULL;
|
||||||
HICON hIconDlg = NULL;
|
HICON hIconDlg = NULL;
|
||||||
WCHAR szIconPath[MAX_PATH] = { L"\0" };
|
|
||||||
INT iIconIndex = 0;
|
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
@@ -201,16 +204,20 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l
|
|||||||
// TODO:
|
// TODO:
|
||||||
// require a valid group to be selected or else the dialog won't
|
// require a valid group to be selected or else the dialog won't
|
||||||
// let you press OK
|
// let you press OK
|
||||||
|
|
||||||
|
// Set the window title
|
||||||
|
LoadString(hAppInstance, IDS_DLT_ITEM_NEW, szDlgTitle, ARRAYSIZE(szDlgTitle));
|
||||||
|
SetWindowText(hWndDlg, szDlgTitle);
|
||||||
|
|
||||||
// Populate the icon with the default path and index.
|
// Populate the icon with the default path and index.
|
||||||
GetModuleFileName(NULL, (LPWSTR)&szIconPath, MAX_PATH);
|
GetModuleFileName(NULL, (LPWSTR)&itm.szIconPath, MAX_PATH);
|
||||||
iIconIndex = IDI_PROGITM - 1;
|
itm.iIconIndex = IDI_PROGITM - 1;
|
||||||
|
|
||||||
// Get the default hIcon so we can delete it later
|
// Get the default hIcon so we can delete it later
|
||||||
hIconDef = (HICON)SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_GETICON, 0, 0);
|
hIconDef = (HICON)SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_GETICON, 0, 0);
|
||||||
|
|
||||||
// Set the icon in the dialog
|
// Set the icon in the dialog
|
||||||
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&szIconPath, iIconIndex);
|
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&itm.szIconPath, itm.iIconIndex);
|
||||||
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
|
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
|
||||||
|
|
||||||
// Set the maximum input length of the text boxes
|
// Set the maximum input length of the text boxes
|
||||||
@@ -298,10 +305,10 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l
|
|||||||
|
|
||||||
|
|
||||||
case IDD_CHICON:
|
case IDD_CHICON:
|
||||||
if (PickIconDlg(hWndDlg, (LPWSTR)&szIconPath, ARRAYSIZE(szIconPath), &iIconIndex) == TRUE)
|
if (PickIconDlg(hWndDlg, (LPWSTR)&itm.szIconPath, ARRAYSIZE(itm.szIconPath), &itm.iIconIndex) == TRUE)
|
||||||
{
|
{
|
||||||
// Since we've got the new icon...
|
// Since we've got the new icon...
|
||||||
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&szIconPath, iIconIndex);
|
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&itm.szIconPath, itm.iIconIndex);
|
||||||
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
|
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,6 +347,12 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
// Cleanup
|
||||||
|
if (hIconDef)
|
||||||
|
DestroyIcon(hIconDef);
|
||||||
|
if (hIconDlg)
|
||||||
|
DestroyIcon(hIconDlg);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,12 +88,9 @@ PGROUPWND CreateGroupWindow(PGROUP pgGroup)
|
|||||||
{
|
{
|
||||||
GROUPWND gw = { NULL };
|
GROUPWND gw = { NULL };
|
||||||
MDICREATESTRUCT mcs = { NULL };
|
MDICREATESTRUCT mcs = { NULL };
|
||||||
HICON hIconBig = NULL;
|
HICON hIconLarge = NULL;
|
||||||
HICON hIconSmall = NULL;
|
HICON hIconSmall = NULL;
|
||||||
// BEGIN LISTVIEW TEMP ITEM
|
HICON hIconTemp = NULL;
|
||||||
LVITEM lviTestItem;
|
|
||||||
WCHAR szTestItem[] = L"Test Item";
|
|
||||||
// END LISTVIEW TEMP ITEM
|
|
||||||
|
|
||||||
// Copy group structure to our group window
|
// Copy group structure to our group window
|
||||||
gw.grp = *pgGroup;
|
gw.grp = *pgGroup;
|
||||||
@@ -125,6 +122,15 @@ PGROUPWND CreateGroupWindow(PGROUP pgGroup)
|
|||||||
if ((gw.hWndGroup = (HWND)SendMessage(hWndMDIClient, WM_MDICREATE, 0, (LPARAM)(LPTSTR)&mcs)) == NULL)
|
if ((gw.hWndGroup = (HWND)SendMessage(hWndMDIClient, WM_MDICREATE, 0, (LPARAM)(LPTSTR)&mcs)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
// Load the group icon
|
||||||
|
if (ExtractIconEx(gw.grp.szIconPath, gw.grp.iIconIndex, &hIconLarge, &hIconSmall, 1))
|
||||||
|
{
|
||||||
|
if (hIconTemp = (HICON)SendMessage(gw.hWndGroup, WM_SETICON, ICON_SMALL, (LPARAM)hIconSmall))
|
||||||
|
DestroyIcon(hIconTemp);
|
||||||
|
if (hIconTemp = (HICON)SendMessage(gw.hWndGroup, WM_SETICON, ICON_BIG, (LPARAM)hIconLarge))
|
||||||
|
DestroyIcon(hIconTemp);
|
||||||
|
}
|
||||||
|
|
||||||
// Create the group window ListView control
|
// Create the group window ListView control
|
||||||
if ((gw.hWndListView = CreateWindowEx(WS_EX_LEFT, WC_LISTVIEW, L"ListView",
|
if ((gw.hWndListView = CreateWindowEx(WS_EX_LEFT, WC_LISTVIEW, L"ListView",
|
||||||
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN
|
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN
|
||||||
@@ -134,28 +140,6 @@ PGROUPWND CreateGroupWindow(PGROUP pgGroup)
|
|||||||
NULL)) == NULL)
|
NULL)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// BEGIN LISTVIEW TEMP ITEM
|
|
||||||
ListView_SetBkColor(gw.hWndListView, CLR_NONE);
|
|
||||||
|
|
||||||
lviTestItem.mask = LVIF_STATE | LVIF_TEXT | LVIF_IMAGE;
|
|
||||||
lviTestItem.iItem = 0;
|
|
||||||
lviTestItem.iSubItem = 0;
|
|
||||||
lviTestItem.state = 0;
|
|
||||||
lviTestItem.stateMask = 0;
|
|
||||||
lviTestItem.pszText = (LPWSTR)&szTestItem;
|
|
||||||
lviTestItem.cchTextMax = MAX_TITLE_LENGTH;
|
|
||||||
lviTestItem.iImage = 1;
|
|
||||||
|
|
||||||
ListView_InsertItem(gw.hWndListView, &lviTestItem);
|
|
||||||
// END LISTVIEW TEMP ITEM
|
|
||||||
|
|
||||||
// Load the group icon
|
|
||||||
if (ExtractIconEx(gw.grp.szIconPath, gw.grp.iIconIndex, &hIconBig, &hIconSmall, 1))
|
|
||||||
{
|
|
||||||
SendMessage(gw.hWndGroup, WM_SETICON, ICON_SMALL, (LPARAM)hIconSmall);
|
|
||||||
SendMessage(gw.hWndGroup, WM_SETICON, ICON_BIG, (LPARAM)hIconBig);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: make sure the groups delete their icons upon destruction!
|
// TODO: make sure the groups delete their icons upon destruction!
|
||||||
|
|
||||||
return &gw;
|
return &gw;
|
||||||
@@ -268,12 +252,13 @@ LRESULT CALLBACK GroupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
|
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// GroupProcDefault:
|
|
||||||
return DefMDIChildProc(hWnd, message, wParam, lParam);
|
return DefMDIChildProc(hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user