mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[SNDVOL32] Restore the previous placement data of the window (#2420)
Save the current coordinate data of the window to the Registry when the user closes the Sound Volume applet.
This commit is contained in:
parent
72c51aabba
commit
3af1141a61
3 changed files with 134 additions and 0 deletions
|
@ -158,6 +158,116 @@ CloseAppConfig(VOID)
|
|||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
LoadXYCoordWnd(IN PPREFERENCES_CONTEXT PrefContext)
|
||||
{
|
||||
HKEY hKey;
|
||||
LONG lResult;
|
||||
TCHAR DeviceMixerSettings[256];
|
||||
DWORD dwData;
|
||||
DWORD cbData = sizeof(dwData);
|
||||
|
||||
/* Append the registry key path and device name key into one single string */
|
||||
StringCchPrintf(DeviceMixerSettings, _countof(DeviceMixerSettings), TEXT("%s\\%s"), AppRegSettings, PrefContext->DeviceName);
|
||||
|
||||
lResult = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
DeviceMixerSettings,
|
||||
0,
|
||||
KEY_READ,
|
||||
&hKey);
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
lResult = RegQueryValueEx(hKey,
|
||||
TEXT("X"),
|
||||
0,
|
||||
0,
|
||||
(LPBYTE)&dwData,
|
||||
&cbData);
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Cache the X coordinate point */
|
||||
PrefContext->MixerWindow->WndPosX = dwData;
|
||||
|
||||
lResult = RegQueryValueEx(hKey,
|
||||
TEXT("Y"),
|
||||
0,
|
||||
0,
|
||||
(LPBYTE)&dwData,
|
||||
&cbData);
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Cache the Y coordinate point */
|
||||
PrefContext->MixerWindow->WndPosY = dwData;
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
SaveXYCoordWnd(IN HWND hWnd,
|
||||
IN PPREFERENCES_CONTEXT PrefContext)
|
||||
{
|
||||
HKEY hKey;
|
||||
LONG lResult;
|
||||
TCHAR DeviceMixerSettings[256];
|
||||
WINDOWPLACEMENT wp;
|
||||
|
||||
/* Get the placement coordinate data from the window */
|
||||
wp.length = sizeof(WINDOWPLACEMENT);
|
||||
GetWindowPlacement(hWnd, &wp);
|
||||
|
||||
/* Append the registry key path and device name key into one single string */
|
||||
StringCchPrintf(DeviceMixerSettings, _countof(DeviceMixerSettings), TEXT("%s\\%s"), AppRegSettings, PrefContext->DeviceName);
|
||||
|
||||
lResult = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
DeviceMixerSettings,
|
||||
0,
|
||||
KEY_SET_VALUE,
|
||||
&hKey);
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
lResult = RegSetValueEx(hKey,
|
||||
TEXT("X"),
|
||||
0,
|
||||
REG_DWORD,
|
||||
(LPBYTE)&wp.rcNormalPosition.left,
|
||||
sizeof(wp.rcNormalPosition.left));
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
lResult = RegSetValueEx(hKey,
|
||||
TEXT("Y"),
|
||||
0,
|
||||
REG_DWORD,
|
||||
(LPBYTE)&wp.rcNormalPosition.top,
|
||||
sizeof(wp.rcNormalPosition.top));
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WriteLineConfig(IN LPTSTR szDeviceName,
|
||||
IN LPTSTR szLineName,
|
||||
|
|
|
@ -880,6 +880,7 @@ MainWindowProc(HWND hwnd,
|
|||
{
|
||||
PMIXER_WINDOW MixerWindow;
|
||||
DWORD CtrlID, LineOffset;
|
||||
BOOL bRet;
|
||||
LRESULT Result = 0;
|
||||
SET_VOLUME_CONTEXT Context;
|
||||
|
||||
|
@ -1211,6 +1212,18 @@ MainWindowProc(HWND hwnd,
|
|||
/* Disable the 'Advanced Controls' menu item */
|
||||
EnableMenuItem(GetMenu(hwnd), IDM_ADVANCED_CONTROLS, MF_BYCOMMAND | MF_GRAYED);
|
||||
|
||||
/* Load the placement coordinate data of the window */
|
||||
bRet = LoadXYCoordWnd(&Preferences);
|
||||
if (bRet)
|
||||
{
|
||||
/*
|
||||
* LoadXYCoordWnd() might fail for the first time of opening the application which is normal as
|
||||
* the Sound Control's applet settings haven't been saved yet to the Registry. At this point SetWindowPos()
|
||||
* call is skipped.
|
||||
*/
|
||||
SetWindowPos(hwnd, NULL, MixerWindow->WndPosX, MixerWindow->WndPosY, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
||||
}
|
||||
|
||||
/* create status window */
|
||||
if (MixerWindow->Mode == NORMAL_MODE)
|
||||
{
|
||||
|
@ -1257,6 +1270,7 @@ MainWindowProc(HWND hwnd,
|
|||
|
||||
case WM_CLOSE:
|
||||
{
|
||||
SaveXYCoordWnd(hwnd, &Preferences);
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ typedef struct _MIXER_WINDOW
|
|||
RECT rect;
|
||||
HFONT hFont;
|
||||
SIZE baseUnit;
|
||||
INT WndPosX;
|
||||
INT WndPosY;
|
||||
} MIXER_WINDOW, *PMIXER_WINDOW;
|
||||
|
||||
extern HINSTANCE hAppInstance;
|
||||
|
@ -63,6 +65,7 @@ extern HWND hMainWnd;
|
|||
extern HANDLE hAppHeap;
|
||||
|
||||
#define SZ_APP_CLASS TEXT("Volume Control")
|
||||
#define _countof(array) (sizeof(array) / sizeof(array[0]))
|
||||
|
||||
ULONG DbgPrint(PCH , ...);
|
||||
#define DPRINT DbgPrint("SNDVOL32: %s:%i: ", __FILE__, __LINE__); DbgPrint
|
||||
|
@ -192,6 +195,13 @@ InitAppConfig(VOID);
|
|||
VOID
|
||||
CloseAppConfig(VOID);
|
||||
|
||||
BOOL
|
||||
LoadXYCoordWnd(IN PPREFERENCES_CONTEXT PrefContext);
|
||||
|
||||
BOOL
|
||||
SaveXYCoordWnd(IN HWND hWnd,
|
||||
IN PPREFERENCES_CONTEXT PrefContext);
|
||||
|
||||
INT
|
||||
AllocAndLoadString(OUT LPWSTR *lpTarget,
|
||||
IN HINSTANCE hInst,
|
||||
|
|
Loading…
Reference in a new issue