Factor out wxTopLevelWindow::MSWEnableCloseButton()
Make it possible to reuse this code for other, non-wx, windows. No real changes, this is just a pure refactoring.
This commit is contained in:
@@ -90,6 +90,9 @@ public:
|
|||||||
// NULL if getting the system menu failed.
|
// NULL if getting the system menu failed.
|
||||||
wxMenu *MSWGetSystemMenu() const;
|
wxMenu *MSWGetSystemMenu() const;
|
||||||
|
|
||||||
|
// Enable or disable the close button of the specified window.
|
||||||
|
static bool MSWEnableCloseButton(WXHWND hwnd, bool enable = true);
|
||||||
|
|
||||||
|
|
||||||
// implementation from now on
|
// implementation from now on
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
@@ -986,10 +986,11 @@ void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons)
|
|||||||
DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG);
|
DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTopLevelWindowMSW::EnableCloseButton(bool enable)
|
// static
|
||||||
|
bool wxTopLevelWindowMSW::MSWEnableCloseButton(WXHWND hwnd, bool enable)
|
||||||
{
|
{
|
||||||
// get system (a.k.a. window) menu
|
// get system (a.k.a. window) menu
|
||||||
HMENU hmenu = GetSystemMenu(GetHwnd(), FALSE /* get it */);
|
HMENU hmenu = GetSystemMenu(hwnd, FALSE /* get it */);
|
||||||
if ( !hmenu )
|
if ( !hmenu )
|
||||||
{
|
{
|
||||||
// no system menu at all -- ok if we want to remove the close button
|
// no system menu at all -- ok if we want to remove the close button
|
||||||
@@ -1008,7 +1009,7 @@ bool wxTopLevelWindowMSW::EnableCloseButton(bool enable)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// update appearance immediately
|
// update appearance immediately
|
||||||
if ( !::DrawMenuBar(GetHwnd()) )
|
if ( !::DrawMenuBar(hwnd) )
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("DrawMenuBar"));
|
wxLogLastError(wxT("DrawMenuBar"));
|
||||||
}
|
}
|
||||||
@@ -1016,6 +1017,11 @@ bool wxTopLevelWindowMSW::EnableCloseButton(bool enable)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxTopLevelWindowMSW::EnableCloseButton(bool enable)
|
||||||
|
{
|
||||||
|
return MSWEnableCloseButton(GetHwnd(), enable);
|
||||||
|
}
|
||||||
|
|
||||||
// Window must have wxCAPTION and either wxCLOSE_BOX or wxSYSTEM_MENU for the
|
// Window must have wxCAPTION and either wxCLOSE_BOX or wxSYSTEM_MENU for the
|
||||||
// button to be visible. Also check for wxMAXIMIZE_BOX because we don't want
|
// button to be visible. Also check for wxMAXIMIZE_BOX because we don't want
|
||||||
// to enable a button that is excluded from the current style.
|
// to enable a button that is excluded from the current style.
|
||||||
|
Reference in New Issue
Block a user