Hi, @Laurie Stearn
Does anything in there explain why the internal MINMAXINFO is always reset to default?
Yes, According to the WM_GETMINMAXINFO documentation:
lParam is A pointer to a
MINMAXINFO
structure that contains the default maximized position and dimensions, and the default minimum and maximum tracking sizes.
You can temporarily override this default value but cannot modify it. The message will be sent to a window when the size or position of the window is about to change, and you will need to process this message every time.
and our window's size smaller than the values set in ptMinTrackSize
I cannot reproduce it, I can set the ptMinTrackSize
and the window minimum tracking size is correct.
Could a minimal sample includes how you set the inputReady and is there any other place that set the defDims
?
Update:
Minimal code snip:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int inputReady = true;
switch (message)
{
case WM_GETMINMAXINFO:
{
// myWidth, myheight initialised e.g 250, 150
MINMAXINFO* mmi = reinterpret_cast<MINMAXINFO*>(lParam);
// mmi reset with Windows default values
static POINT defDims;
if (inputReady)
{
defDims.x = 2 * 250;
defDims.y = 2 * 150;
inputReady = false;
}
// mmi is updated with new values here
mmi->ptMinTrackSize = defDims;
return (LRESULT)FALSE;
}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
WNDCLASSEXW wcex = { 0 };
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.hInstance = hInstance;
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszClassName = L"Window_Class";
if (!RegisterClassExW(&wcex))
{
std::cout << "RegisterClassExW error: " << GetLastError() << std::endl;
return 0;
}
HWND hWnd = CreateWindowW(wcex.lpszClassName, L"Title", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
if (!hWnd)
{
std::cout << "CreateWindowW error: " << GetLastError() << std::endl;
return 0;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
MSG msg;
// Main message loop:
while (GetMessage(&msg, nullptr, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
(I assume you only use inputReady once)
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.