X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9ca4dd06de4376340efca369e65ee1181375d484..01f5f03e7f9c19ca75ae6dbd4050c2b54e52e406:/src/msw/toplevel.cpp diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 7e827494bd..7d0164a3c0 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -6,7 +6,7 @@ // Created: 24.09.01 // RCS-ID: $Id$ // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) -// License: wxWindows license +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -758,6 +758,47 @@ bool wxTopLevelWindowMSW::EnableCloseButton(bool enable) return TRUE; } +bool wxTopLevelWindowMSW::SetShape(const wxRegion& region) +{ + // The empty region signifies that the shape should be removed from the + // window. + if ( region.IsEmpty() ) + { + if (::SetWindowRgn(GetHwnd(), NULL, TRUE) == 0) + { + wxLogLastError(_T("SetWindowRgn")); + return FALSE; + } + return TRUE; + } + + // Windows takes ownership of the region, so + // we'll have to make a copy of the region to give to it. + DWORD noBytes = ::GetRegionData(GetHrgnOf(region), 0, NULL); + RGNDATA *rgnData = (RGNDATA*) new char[noBytes]; + ::GetRegionData(GetHrgnOf(region), noBytes, rgnData); + HRGN hrgn = ::ExtCreateRegion(NULL, noBytes, rgnData); + delete[] (char*) rgnData; + + // SetWindowRgn expects the region to be in coordinants + // relative to the window, not the client area. Figure + // out the offset, if any. + RECT rect; + DWORD dwStyle = ::GetWindowLong(GetHwnd(), GWL_STYLE); + DWORD dwExStyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE); + ::GetClientRect(GetHwnd(), &rect); + ::AdjustWindowRectEx(&rect, dwStyle, FALSE, dwExStyle); + ::OffsetRgn(hrgn, -rect.left, -rect.top); + + // Now call the shape API with the new region. + if (::SetWindowRgn(GetHwnd(), hrgn, TRUE) == 0) + { + wxLogLastError(_T("SetWindowRgn")); + return FALSE; + } + return TRUE; +} + // ---------------------------------------------------------------------------- // wxTopLevelWindow event handling // ---------------------------------------------------------------------------- @@ -912,3 +953,4 @@ HWND wxTLWHiddenParentModule::GetHWND() return ms_hwnd; } +