Merge branch 'master' of https://github.com/Vortesys/Program-Manager-II
This commit is contained in:
3
.github/workflows/msbuild.yml
vendored
3
.github/workflows/msbuild.yml
vendored
@@ -14,7 +14,8 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
# Path to the solution file relative to the root of the project.
|
# Path to the solution file relative to the root of the project.
|
||||||
SOLUTION_FILE_PATH: .
|
# SOLUTION_FILE_PATH: .
|
||||||
|
SOLUTION_FILE_PATH: Program-Manager-II.sln
|
||||||
|
|
||||||
# Configuration type to build.
|
# Configuration type to build.
|
||||||
# You can convert this to a build matrix if you need coverage of multiple configuration types.
|
# You can convert this to a build matrix if you need coverage of multiple configuration types.
|
||||||
|
|||||||
140
progmgr/group.c
140
progmgr/group.c
@@ -77,8 +77,12 @@ BOOL InitializeGroups(VOID)
|
|||||||
|
|
||||||
if (!RegisterClassEx(&wce))
|
if (!RegisterClassEx(&wce))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
// Now we can create the groups
|
||||||
|
if(LoadConfig(FALSE, FALSE, TRUE) != RCE_SUCCESS)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
// TODO: go thru registry and load all saved groups here
|
// TODO: if loading groups fails, throw an error
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -112,8 +116,7 @@ HWND CreateGroup(_In_ PGROUP pg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// allocate memory for a new group
|
// allocate memory for a new group
|
||||||
pGroup = (PGROUP)malloc(CalculateGroupMemory(pg, 0, 0));
|
pGroup = (PGROUP)malloc(CalculateGroupMemory(pg, 1, 0));
|
||||||
|
|
||||||
if (pGroup == NULL)
|
if (pGroup == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -171,8 +174,7 @@ HWND CreateGroup(_In_ PGROUP pg)
|
|||||||
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
|
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
|
||||||
LVS_ICON | LVS_SINGLESEL | LVS_AUTOARRANGE,
|
LVS_ICON | LVS_SINGLESEL | LVS_AUTOARRANGE,
|
||||||
mcs.x, mcs.y, mcs.cx, mcs.cy,
|
mcs.x, mcs.y, mcs.cx, mcs.cy,
|
||||||
hWndGroup, NULL, hAppInstance,
|
hWndGroup, NULL, hAppInstance, NULL)) == NULL)
|
||||||
NULL)) == NULL)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// ((LVS_AUTOARRANGE & bAutoArrange) * LVS_AUTOARRANGE)
|
// ((LVS_AUTOARRANGE & bAutoArrange) * LVS_AUTOARRANGE)
|
||||||
@@ -193,6 +195,10 @@ HWND CreateGroup(_In_ PGROUP pg)
|
|||||||
GetSystemMetrics(SM_CYICON), ILC_COLOR32, 0, 1);
|
GetSystemMetrics(SM_CYICON), ILC_COLOR32, 0, 1);
|
||||||
ListView_SetImageList(hWndListView, hImageList, LVSIL_NORMAL);
|
ListView_SetImageList(hWndListView, hImageList, LVSIL_NORMAL);
|
||||||
|
|
||||||
|
// since the list is viewing we can load items if applicable
|
||||||
|
if (pGroup->cItemArray > 0)
|
||||||
|
LoadItems(hWndGroup);
|
||||||
|
|
||||||
// TODO: make sure the groups delete their icons upon destruction!
|
// TODO: make sure the groups delete their icons upon destruction!
|
||||||
// AND IMAGE LIST!!!!!!!!? i think it's nuked w/ listview though
|
// AND IMAGE LIST!!!!!!!!? i think it's nuked w/ listview though
|
||||||
return hWndGroup;
|
return hWndGroup;
|
||||||
@@ -240,18 +246,16 @@ BOOL RemoveGroup(_In_ HWND hWndGroup, _In_ BOOL bEliminate)
|
|||||||
\* * * */
|
\* * * */
|
||||||
PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi)
|
PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi)
|
||||||
{
|
{
|
||||||
HIMAGELIST hImageList = NULL;
|
|
||||||
HICON hIcon = NULL;
|
|
||||||
LVITEM lvi = { 0 };
|
|
||||||
PGROUP pGroup = NULL;
|
PGROUP pGroup = NULL;
|
||||||
PGROUP pNewGroup = NULL;
|
PGROUP pNewGroup = NULL;
|
||||||
PITEM pItem = NULL;
|
PITEM pItem = NULL;
|
||||||
UINT uiTest = 0;
|
|
||||||
HWND hWndListView = NULL;
|
HWND hWndListView = NULL;
|
||||||
|
HIMAGELIST hImageList = NULL;
|
||||||
|
HICON hIcon = NULL;
|
||||||
|
LVITEM lvi = { 0 };
|
||||||
|
|
||||||
// we actually just want the group pointer lol
|
// we actually just want the group pointer lol
|
||||||
pGroup = (PGROUP)GetWindowLongPtr(hWndGroup, GWLP_USERDATA);
|
pGroup = (PGROUP)GetWindowLongPtr(hWndGroup, GWLP_USERDATA);
|
||||||
uiTest = pGroup->cItemArray;
|
|
||||||
|
|
||||||
// return NULL if we can't get to the group or item
|
// return NULL if we can't get to the group or item
|
||||||
if (hWndGroup == NULL)
|
if (hWndGroup == NULL)
|
||||||
@@ -306,6 +310,79 @@ PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi)
|
|||||||
return pItem;
|
return pItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* * * *\
|
||||||
|
LoadItems -
|
||||||
|
Loads all of the items in a group structure
|
||||||
|
RETURNS -
|
||||||
|
TRUE if successful
|
||||||
|
FALSE otherwise
|
||||||
|
\* * * */
|
||||||
|
BOOL LoadItems(_In_ HWND hWndGroup)
|
||||||
|
{
|
||||||
|
PGROUP pGroup = NULL;
|
||||||
|
PGROUP pNewGroup = NULL;
|
||||||
|
PITEM pItem = NULL;
|
||||||
|
HWND hWndListView = NULL;
|
||||||
|
HIMAGELIST hImageList = NULL;
|
||||||
|
LVITEM lvi = { 0 };
|
||||||
|
UINT cItemIndex = 0;
|
||||||
|
HICON hIcon = NULL;
|
||||||
|
|
||||||
|
// return NULL if we can't get to the group
|
||||||
|
if (hWndGroup == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// retrieve the group pointer
|
||||||
|
pGroup = (PGROUP)GetWindowLongPtr(hWndGroup, GWLP_USERDATA);
|
||||||
|
if (pGroup == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// get the listview window
|
||||||
|
hWndListView = FindWindowEx(hWndGroup, NULL, WC_LISTVIEW, NULL);
|
||||||
|
if (hWndListView == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// make sure we have enough memory for the items
|
||||||
|
pNewGroup = realloc(pGroup, CalculateGroupMemory(pGroup, 0, 1));
|
||||||
|
if (pNewGroup != NULL)
|
||||||
|
{
|
||||||
|
pGroup = pNewGroup;
|
||||||
|
SetWindowLongPtr(hWndGroup, GWLP_USERDATA, (LONG_PTR)pGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
// then get the pointer to the group's image list
|
||||||
|
hImageList = ListView_GetImageList(hWndListView, LVSIL_NORMAL);
|
||||||
|
|
||||||
|
while (pGroup->cItemArray > cItemIndex)
|
||||||
|
{
|
||||||
|
pItem = pGroup->pItemArray + cItemIndex;
|
||||||
|
|
||||||
|
// extract that icon son!!
|
||||||
|
hIcon = ExtractIcon(hAppInstance, (LPWSTR)pItem->szIconPath, pItem->iIconIndex);
|
||||||
|
|
||||||
|
// populate the listview with the relevant information
|
||||||
|
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
|
||||||
|
lvi.iItem = cItemIndex;
|
||||||
|
lvi.iSubItem = 0;
|
||||||
|
lvi.pszText = pItem->szName;
|
||||||
|
lvi.cchTextMax = ARRAYSIZE(pItem->szName);
|
||||||
|
lvi.iImage = ImageList_AddIcon(hImageList, hIcon);
|
||||||
|
lvi.lParam = (LPARAM)pItem;
|
||||||
|
|
||||||
|
// copy that bad boy into the listview
|
||||||
|
ListView_InsertItem(hWndListView, &lvi);
|
||||||
|
|
||||||
|
cItemIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hIcon)
|
||||||
|
// get that hicon outta here
|
||||||
|
DestroyIcon(hIcon);
|
||||||
|
|
||||||
|
// TODO: fail if the listview item isn't added
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* * * *\
|
/* * * *\
|
||||||
RemoveItem -
|
RemoveItem -
|
||||||
Removes a program item
|
Removes a program item
|
||||||
@@ -315,6 +392,7 @@ PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi)
|
|||||||
\* * * */
|
\* * * */
|
||||||
BOOL RemoveItem(_In_ PITEM pi)
|
BOOL RemoveItem(_In_ PITEM pi)
|
||||||
{
|
{
|
||||||
|
// TODO: implement this
|
||||||
// return NULL if we can't get to the group
|
// return NULL if we can't get to the group
|
||||||
if (pi == NULL)
|
if (pi == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -358,6 +436,7 @@ BOOL ExecuteItem(_In_ PITEM pi)
|
|||||||
\* * * */
|
\* * * */
|
||||||
VOID UpdateGroup(_In_ PGROUP pg)
|
VOID UpdateGroup(_In_ PGROUP pg)
|
||||||
{
|
{
|
||||||
|
DWORD dwFlags = 0;
|
||||||
// Set the important flags
|
// Set the important flags
|
||||||
pg->dwSignature = GRP_SIGNATURE;
|
pg->dwSignature = GRP_SIGNATURE;
|
||||||
pg->wVersion = GRP_VERSION;
|
pg->wVersion = GRP_VERSION;
|
||||||
@@ -371,10 +450,47 @@ VOID UpdateGroup(_In_ PGROUP pg)
|
|||||||
|
|
||||||
// Set FILETIME
|
// Set FILETIME
|
||||||
GetSystemTimeAsFileTime(&pg->ftLastWrite);
|
GetSystemTimeAsFileTime(&pg->ftLastWrite);
|
||||||
|
|
||||||
|
// Get the group window rect
|
||||||
|
// GetClientRect(hWndGroup, &rcGroupWindow);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* * * *\
|
||||||
|
VerifyGroup -
|
||||||
|
Verifies that a group contains the
|
||||||
|
correct information about itself.
|
||||||
|
ABSTRACT -
|
||||||
|
This function will check the checksum,
|
||||||
|
verify the number of items, check other
|
||||||
|
parts of the strucutre. If requested,
|
||||||
|
it will repair the group if it is damaged.
|
||||||
|
RETURNS -
|
||||||
|
TRUE if group appears to be fine
|
||||||
|
FALSE if the group is damaged
|
||||||
|
\* * * */
|
||||||
|
BOOL VerifyGroup(_In_ PGROUP pg, _In_ BOOL bRepair)
|
||||||
|
{
|
||||||
|
if (pg->dwSignature != GRP_SIGNATURE)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// if (pg->wVersion != GRP_VERSION)
|
||||||
|
// some sort of version difference handling
|
||||||
|
|
||||||
|
if (pg->wChecksum == 1234)
|
||||||
|
// TODO: calculate checksum function
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// TODO: use ftlastwrite to throw an error
|
||||||
|
// if system clock is in the future
|
||||||
|
|
||||||
|
// calculate the size of the group based on item of numbers
|
||||||
|
|
||||||
|
// TODO: change to return a dword error value
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* * * *\
|
/* * * *\
|
||||||
CalculateGroupMemory -
|
CalculateGroupMemory -
|
||||||
Calculates the memory needed by a group.
|
Calculates the memory needed by a group.
|
||||||
@@ -391,9 +507,7 @@ UINT CalculateGroupMemory(_In_ PGROUP pGroup, _In_ UINT cItems, _In_ BOOL bLean)
|
|||||||
// first add the size of a group strucutre
|
// first add the size of a group strucutre
|
||||||
cbGroupSize += sizeof(GROUP);
|
cbGroupSize += sizeof(GROUP);
|
||||||
|
|
||||||
// calculate the total amount of items wanted, set
|
// calculate the total amount of items wanted
|
||||||
// to 16 if there's less than 16 items so we always
|
|
||||||
// have some memory ready
|
|
||||||
cItemBlock = pGroup->cItemArray + cItems;
|
cItemBlock = pGroup->cItemArray + cItems;
|
||||||
|
|
||||||
if (!bLean)
|
if (!bLean)
|
||||||
|
|||||||
@@ -80,10 +80,12 @@ HWND CreateGroup(_In_ PGROUP pg);
|
|||||||
BOOL RemoveGroup(_In_ HWND hWndGroup, _In_ BOOL bEliminate);
|
BOOL RemoveGroup(_In_ HWND hWndGroup, _In_ BOOL bEliminate);
|
||||||
// Item Management
|
// Item Management
|
||||||
PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi);
|
PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi);
|
||||||
|
BOOL LoadItems(_In_ HWND hWndGroup);
|
||||||
BOOL RemoveItem(_In_ PITEM pi);
|
BOOL RemoveItem(_In_ PITEM pi);
|
||||||
BOOL ExecuteItem(_In_ PITEM pi);
|
BOOL ExecuteItem(_In_ PITEM pi);
|
||||||
// Save/Load helper functions
|
// Save/Load helper functions
|
||||||
VOID UpdateGroup(_In_ PGROUP pg);
|
VOID UpdateGroup(_In_ PGROUP pg);
|
||||||
|
BOOL VerifyGroup(_In_ PGROUP pg, _In_ BOOL bRepair);
|
||||||
// Helper functions
|
// Helper functions
|
||||||
UINT CalculateGroupMemory(_In_ PGROUP pGroup, _In_ UINT cItems, _In_ BOOL bLean);
|
UINT CalculateGroupMemory(_In_ PGROUP pGroup, _In_ UINT cItems, _In_ BOOL bLean);
|
||||||
// Group Window
|
// Group Window
|
||||||
|
|||||||
@@ -35,11 +35,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
{
|
{
|
||||||
// Now we can create the groups
|
|
||||||
if(LoadConfig(FALSE, FALSE, TRUE) != RCE_SUCCESS)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
// TODO: if loading groups fails, throw an error
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user