I Need Help Using SetWindowRgn()?

Status
Not open for further replies.

DarylF2

Ars Tribunus Angusticlavius
6,413
Subscriptor
I have a Windows MFC dialog with a single child, a CTabCtrl. I would like the dialog's window shape to conform to that of its CTabCtrl, so it appears that the CTabCtrl is "floating" on the desktop. I'll add an optional "drag bar" later so that it can be easily repositioned.

I've tried the following code, but it doesn't work (it just causes my window to vanish):
Code:
        HRGN hrgn = CreateRectRgn(0,0,0,0);

        int nRegionType = m_MainTab.GetWindowRgn(hrgn);

        //TODO: This isn't working...
        SetWindowRgn (hrgn, TRUE);

Does anyone see what I am doing wrong?

Where should this code be loaded (in InitDialog(), ShowWindow(), OnCreate(), ...)?

I'm not tied to a CDialog parent, a CFrameWnd or CWnd would be fine. I'd also be happy to have the CTabCtrl (which is derived from CWnd after all) be the toplevel window if that would work properly.

I'm using C++ in Visual Studio .NET. I'm running under Windows XP Pro, but would like to target older OSs, including Windows 98 and NT 4.0, if possible.

Any help would be appreciated. This is for a freeware/ArsWare program I'm developing in my spare time.
 

DarylF2

Ars Tribunus Angusticlavius
6,413
Subscriptor
The above code is being called in my dialog's OnShowWindow() class.

It turns out that m_MainTab.GetWindowRgn(hrgn) is returning 0 (aka ERROR). This is why the dialog is vanishing when SetWindowRgn (hrgn, TRUE) is being called.

Why is MainTab.GetWindowRgn(hrgn) returning 0, though? I know that the tab control has been successfully created, but has its window region not yet been allocated? I think my whole problem may be that I'm calling this code from the wrong message handler...
 
Status
Not open for further replies.