Alex Sokolek
Member
- Joined
- Apr 5, 2024
- Messages
- 44
- Thread Author
- #1
Hi. I think I found a bug in GetWindow{Placement().
I save and restore the window placement using the registry as an intermidiary.
For save...
```
(In WndProc)case WM_DESTROY:
{
WINDOWPLACEMENT wp;
ZeroMemory(&wp, sizeof(wp));
wp.length = sizeof(wp);
GetWindowPlacement(hWnd, &wp);
pAppReg->SaveMemoryBlock(_T("WindowPlacement"), (LPBYTE)&wp, sizeof(wp));
}
```
And for restore...
```
(In InitInstance)
WINDOWPLACEMENT wp;
if (pAppReg->LoadMemoryBlock(_T("WindowPlacement"), (LPBYTE)&wp, sizeof(wp)))
{
if (wp.flags == 0 && wp.showCmd == SW_MINIMIZE) wp.flags = WPF_SETMINPOSITION; // This is the bug fix
SetWindowPlacement(hWnd, &wp);
}
```
pAppReg is a pointer to a class that saves and restores memory blocks to and from the registry. See the line that says // This is the bug fix. If I omit the line and the window was minimized, it becomes hidden when I do the restore. My question: Is this a bug? Thank you.