save groups
This commit is contained in:
@@ -206,7 +206,6 @@ BOOL RemoveGroup(_In_ HWND hWndGroup, _In_ BOOL bEliminate)
|
|||||||
BOOL bReturn = TRUE;
|
BOOL bReturn = TRUE;
|
||||||
|
|
||||||
// TODO: do i have to delete the titlebar icons?
|
// TODO: do i have to delete the titlebar icons?
|
||||||
// TODO: cleanup the image list as well, IMAGELIST_DESTORY
|
|
||||||
|
|
||||||
if (bEliminate == TRUE)
|
if (bEliminate == TRUE)
|
||||||
{
|
{
|
||||||
@@ -217,12 +216,12 @@ BOOL RemoveGroup(_In_ HWND hWndGroup, _In_ BOOL bEliminate)
|
|||||||
|
|
||||||
// get the group struct pointer
|
// get the group struct pointer
|
||||||
if ((pGroup = (PGROUP)GetWindowLongPtr(hWndGroup, GWLP_USERDATA)) == NULL)
|
if ((pGroup = (PGROUP)GetWindowLongPtr(hWndGroup, GWLP_USERDATA)) == NULL)
|
||||||
return FALSE;
|
bReturn = FALSE;
|
||||||
|
else
|
||||||
free(pGroup);
|
free(pGroup);
|
||||||
|
|
||||||
// close the group window
|
// close the group window
|
||||||
DestroyWindow(hWndGroup);
|
SendMessage(hWndMDIClient, WM_MDIDESTROY, (WPARAM)hWndGroup, 0);
|
||||||
|
|
||||||
return bReturn;
|
return bReturn;
|
||||||
}
|
}
|
||||||
@@ -346,17 +345,16 @@ BOOL ExecuteItem(_In_ PITEM pi)
|
|||||||
|
|
||||||
/* * * *\
|
/* * * *\
|
||||||
SaveGroup -
|
SaveGroup -
|
||||||
Saves group from a group window
|
Updates group information to prepare
|
||||||
into a GROUP structure.
|
it for being saved.
|
||||||
ABSTRACT -
|
ABSTRACT -
|
||||||
This function will extract all of the
|
This function will update all of the
|
||||||
necessary information from a group window
|
relevant structures in a group struct
|
||||||
in order to produce a group structure.
|
in preparation for saving the group.
|
||||||
RETURNS -
|
RETURNS -
|
||||||
Formatted GROUP structure.
|
Nothing.
|
||||||
Upon failure, wChecksum will be 0.
|
|
||||||
\* * * */
|
\* * * */
|
||||||
GROUP SaveGroup(_In_ PGROUP pg)
|
VOID UpdateGroup(_In_ PGROUP pg)
|
||||||
{
|
{
|
||||||
GROUP grp = {
|
GROUP grp = {
|
||||||
.dwSignature = GRP_SIGNATURE,
|
.dwSignature = GRP_SIGNATURE,
|
||||||
@@ -368,32 +366,16 @@ GROUP SaveGroup(_In_ PGROUP pg)
|
|||||||
.cItemArray = 0,
|
.cItemArray = 0,
|
||||||
.pItemArray = 0
|
.pItemArray = 0
|
||||||
};
|
};
|
||||||
HWND hWndGrp = NULL;
|
|
||||||
WCHAR szGroupName[MAX_TITLE_LENGTH];
|
|
||||||
|
|
||||||
// Find the group and copy it
|
|
||||||
grp = *pg;
|
|
||||||
|
|
||||||
// Set the group checksum
|
// Set the group checksum
|
||||||
grp.wChecksum = 1; // NOTE: implement this for real later lol
|
pg->wChecksum = 1; // NOTE: implement this for real later lol
|
||||||
|
|
||||||
// Copy group information
|
pg->dwFlags = GRP_FLAG_MAXIMIZED;// GetGroupFlags(pgw);
|
||||||
if (hWndGrp != NULL)
|
|
||||||
{
|
|
||||||
GetWindowText(hWndGrp, szGroupName, MAX_TITLE_LENGTH);
|
|
||||||
StringCchCopy(grp.szName, MAX_TITLE_LENGTH, szGroupName);
|
|
||||||
}
|
|
||||||
|
|
||||||
grp.dwFlags = GRP_FLAG_MAXIMIZED;// GetGroupFlags(pgw);
|
|
||||||
|
|
||||||
// Set FILETIME
|
// Set FILETIME
|
||||||
GetSystemTimeAsFileTime(&grp.ftLastWrite);
|
GetSystemTimeAsFileTime(&pg->ftLastWrite);
|
||||||
|
|
||||||
// Save items...
|
return;
|
||||||
grp.cItemArray = 0;
|
|
||||||
// TODO: iterate through listview to save items
|
|
||||||
|
|
||||||
return grp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* * * *\
|
/* * * *\
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ BOOL RemoveGroup(_In_ HWND hWndGroup, _In_ BOOL bEliminate);
|
|||||||
PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi);
|
PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi);
|
||||||
BOOL RemoveItem(_In_ PITEM pi);
|
BOOL RemoveItem(_In_ PITEM pi);
|
||||||
BOOL ExecuteItem(_In_ PITEM pi);
|
BOOL ExecuteItem(_In_ PITEM pi);
|
||||||
// Import/export functions
|
// Save/Load helper functions
|
||||||
GROUP SaveGroup(_In_ PGROUP pg);
|
VOID UpdateGroup(_In_ PGROUP pg);
|
||||||
// Helper functions
|
// Helper functions
|
||||||
UINT CalculateGroupMemory(_In_ PGROUP pGroup, _In_ UINT cItems);
|
UINT CalculateGroupMemory(_In_ PGROUP pGroup, _In_ UINT cItems);
|
||||||
// Group Window
|
// Group Window
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ BOOL IsProgMgrDefaultShell(VOID)
|
|||||||
RETURNS -
|
RETURNS -
|
||||||
RCE_* configuration error value
|
RCE_* configuration error value
|
||||||
\* * * */
|
\* * * */
|
||||||
DWORD SaveGroupToRegistry(_In_ PGROUP pg)
|
DWORD RegistrySaveGroup(_In_ PGROUP pg)
|
||||||
{
|
{
|
||||||
DWORD dwConfigStatus = RCE_SUCCESS;
|
DWORD dwConfigStatus = RCE_SUCCESS;
|
||||||
|
|
||||||
@@ -127,21 +127,21 @@ DWORD SaveGroupToRegistry(_In_ PGROUP pg)
|
|||||||
return RCE_FAILURE;
|
return RCE_FAILURE;
|
||||||
|
|
||||||
// Save group
|
// Save group
|
||||||
// TODO: save items properly
|
UpdateGroup(pg);
|
||||||
if (!RegSetValueEx(hKeyProgramGroups, pg->szName, 0, REG_BINARY,
|
if (!RegSetValueEx(hKeyProgramGroups, pg->szName, 0, REG_BINARY,
|
||||||
(const BYTE*)pg, (sizeof(*pg) + sizeof(ITEM) * pg->cItemArray)) == ERROR_SUCCESS)
|
(const BYTE*)pg, CalculateGroupMemory(pg, 0)) == ERROR_SUCCESS)
|
||||||
dwConfigStatus = dwConfigStatus && RCE_GROUPS;
|
dwConfigStatus = dwConfigStatus && RCE_GROUPS;
|
||||||
|
|
||||||
return dwConfigStatus;
|
return dwConfigStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* * * *\
|
/* * * *\
|
||||||
LoadGroupFromRegistry -
|
RegistryLoadGroup -
|
||||||
Loads a group structure from the registry.
|
Loads a group structure from the registry.
|
||||||
RETURNS -
|
RETURNS -
|
||||||
RCE_* configuration error value
|
RCE_* configuration error value
|
||||||
\* * * */
|
\* * * */
|
||||||
DWORD LoadGroupFromRegistry(_Inout_ PGROUP pg, _Out_ PDWORD pdwBufferSize)
|
DWORD RegistryLoadGroup(_Inout_ PGROUP pg, _Out_ PDWORD pdwBufferSize)
|
||||||
{
|
{
|
||||||
DWORD dwConfigStatus = RCE_SUCCESS;
|
DWORD dwConfigStatus = RCE_SUCCESS;
|
||||||
DWORD dwType = REG_BINARY;
|
DWORD dwType = REG_BINARY;
|
||||||
@@ -167,7 +167,7 @@ DWORD LoadGroupFromRegistry(_Inout_ PGROUP pg, _Out_ PDWORD pdwBufferSize)
|
|||||||
RETURNS -
|
RETURNS -
|
||||||
RCE_* configuration error value
|
RCE_* configuration error value
|
||||||
\* * * */
|
\* * * */
|
||||||
DWORD SaveConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
DWORD SaveConfig(_In_ BOOL bSettings, _In_ BOOL bPos, _In_ BOOL bGroups, _In_ BOOL bExit)
|
||||||
{
|
{
|
||||||
DWORD dwConfigStatus = RCE_SUCCESS;
|
DWORD dwConfigStatus = RCE_SUCCESS;
|
||||||
|
|
||||||
@@ -205,15 +205,65 @@ DWORD SaveConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
|||||||
|
|
||||||
if (bGroups)
|
if (bGroups)
|
||||||
{
|
{
|
||||||
|
HWND hWndGroup = NULL;
|
||||||
|
|
||||||
// TODO: Get list of groups, iterate through,
|
// TODO: Get list of groups, iterate through,
|
||||||
// save each one as an individual subkey based
|
// save each one as an individual subkey based
|
||||||
// on the name of the group
|
// on the name of the group
|
||||||
|
|
||||||
|
EnumChildWindows(hWndMDIClient, &SaveWindowEnumProc, bExit);
|
||||||
|
|
||||||
|
/*
|
||||||
|
while ((hWndGroup = (HWND)SendMessage(hWndMDIClient,
|
||||||
|
WM_MDIGETACTIVE, 0, (LPARAM)NULL)) != NULL)
|
||||||
|
{
|
||||||
|
// save it...
|
||||||
|
dwConfigStatus = dwConfigStatus &&
|
||||||
|
RegistrySaveGroup((PGROUP)GetWindowLongPtr(hWndGroup,
|
||||||
|
GWLP_USERDATA));
|
||||||
|
|
||||||
|
// close it...
|
||||||
|
if (!RemoveGroup(hWndGroup, FALSE))
|
||||||
dwConfigStatus = dwConfigStatus && RCE_GROUPS;
|
dwConfigStatus = dwConfigStatus && RCE_GROUPS;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
return dwConfigStatus;
|
return dwConfigStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* * * *\
|
||||||
|
SaveWindowEnumProc() -
|
||||||
|
Procedure for enumeration
|
||||||
|
of group windows to save
|
||||||
|
or close them
|
||||||
|
NOTES -
|
||||||
|
lParam is a BOOL that determines
|
||||||
|
whether to close the group or not
|
||||||
|
RETURNS -
|
||||||
|
TRUE to continue
|
||||||
|
FALSE to stop
|
||||||
|
\* * * */
|
||||||
|
BOOL CALLBACK SaveWindowEnumProc(HWND hWndGroup, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if (hWndGroup == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// save it...
|
||||||
|
if (RegistrySaveGroup((PGROUP)GetWindowLongPtr(hWndGroup,
|
||||||
|
GWLP_USERDATA)) != RCE_SUCCESS)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// close it...
|
||||||
|
if ((BOOL)lParam == TRUE)
|
||||||
|
{
|
||||||
|
RemoveGroup(hWndGroup, FALSE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* * * *\
|
/* * * *\
|
||||||
LoadConfig() -
|
LoadConfig() -
|
||||||
Finds all settings and retrieves them
|
Finds all settings and retrieves them
|
||||||
@@ -221,7 +271,7 @@ DWORD SaveConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
|||||||
RETURNS -
|
RETURNS -
|
||||||
RCE_* configuration error value
|
RCE_* configuration error value
|
||||||
\* * * */
|
\* * * */
|
||||||
DWORD LoadConfig(BOOL bSettings, BOOL bPos, BOOL bGroups)
|
DWORD LoadConfig(_In_ BOOL bSettings, _In_ BOOL bPos, _In_ BOOL bGroups)
|
||||||
{
|
{
|
||||||
DWORD dwConfigStatus = RCE_SUCCESS;
|
DWORD dwConfigStatus = RCE_SUCCESS;
|
||||||
|
|
||||||
|
|||||||
@@ -50,8 +50,10 @@ extern RECT rcMainWindow;
|
|||||||
BOOL InitializeRegistryKeys(VOID);
|
BOOL InitializeRegistryKeys(VOID);
|
||||||
BOOL IsProgMgrDefaultShell(VOID);
|
BOOL IsProgMgrDefaultShell(VOID);
|
||||||
// Groups
|
// Groups
|
||||||
DWORD SaveGroupToRegistry(_In_ PGROUP pg);
|
DWORD RegistrySaveGroup(_In_ PGROUP pg);
|
||||||
DWORD LoadGroupFromRegistry(_Inout_ PGROUP pg, _Out_ PDWORD pdwBufferSize);
|
DWORD RegistryLoadGroup(_Inout_ PGROUP pg, _Out_ PDWORD pdwBufferSize);
|
||||||
// Settings
|
// Settings
|
||||||
DWORD SaveConfig(BOOL bSettings, BOOL bPos, BOOL bGroups);
|
DWORD SaveConfig(_In_ BOOL bSettings, _In_ BOOL bPos, _In_ BOOL bGroups, _In_ BOOL bExit);
|
||||||
DWORD LoadConfig(BOOL bSettings, BOOL bPos, BOOL bGroups);
|
DWORD LoadConfig(_In_ BOOL bSettings, _In_ BOOL bPos, _In_ BOOL bGroups);
|
||||||
|
// Miscellaneous
|
||||||
|
BOOL CALLBACK SaveWindowEnumProc(HWND hWndGroup, LPARAM lParam);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
if (bSaveSettings)
|
if (bSaveSettings)
|
||||||
SaveConfig(TRUE, TRUE, TRUE);
|
SaveConfig(TRUE, TRUE, TRUE, TRUE);
|
||||||
|
|
||||||
if (bIsDefaultShell && (GetShellWindow() != NULL))
|
if (bIsDefaultShell && (GetShellWindow() != NULL))
|
||||||
SetShellWindow(0);
|
SetShellWindow(0);
|
||||||
@@ -143,7 +143,7 @@ LRESULT CALLBACK CmdProc(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
case IDM_OPTIONS_SAVENOW:
|
case IDM_OPTIONS_SAVENOW:
|
||||||
SaveConfig:
|
SaveConfig:
|
||||||
SaveConfig(TRUE, TRUE, TRUE);
|
SaveConfig(TRUE, TRUE, TRUE, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_WINDOW_CASCADE:
|
case IDM_WINDOW_CASCADE:
|
||||||
|
|||||||
Reference in New Issue
Block a user