简体   繁体   中英

winapi c++ window not less than

I created a main window for my program in c++ and I use mingw

hwnd = CreateWindowExW(
        WS_EX_CLIENTEDGE,
        (LPCWSTR)szClassName,
        title,
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        1250,       // width
        700,        // height
        HWND_DESKTOP,
        NULL,
        hInstance,
        NULL
    );

This window is sizeable, and it's ok. But how can I make a window that has min widht and min height. So I mean that window hasn't been less than, for example: 500*500.

Handle WM_GETMINMAXINFO, sample code:

LRESULT HandledWidget::onGetMinMaxInfo( WPARAM wParam, LPARAM lParam, bool &bHandled )
{
    MINMAXINFO* mmi = (MINMAXINFO*)lParam;
    bHandled = false;
    if (m_minWidth != -1) {
        bHandled = true;
        mmi->ptMinTrackSize.x = m_minWidth;
    }
    if (m_minHeight != -1) {
        bHandled = true;
        mmi->ptMinTrackSize.y = m_minHeight;
    }
    return 0;
}

Handle WM_GETMINMAXINFO message: http://msdn.microsoft.com/en-us/library/windows/desktop/ms632626%28v=vs.85%29.aspx

In the message handler, lParam points to MINMAXINFO structure, which contains POINT ptMinTrackSize member. Fill it with desired size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM