Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to create resizeable non rectangular Window

9 views
Skip to first unread message

Truninger Reto

unread,
Apr 20, 2000, 3:00:00 AM4/20/00
to
Hi all

I'd like to create a Window (main frame window) with rounded corners and
bitmap style borders. I use the following code to create the round
corners:

void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CRgn rgn;
CRect rect;
GetWindowRect(&rect);
rgn.CreateRoundRectRgn(0,0,rect.Width()+1, rect.Height()+1, 20, 20);
SetWindowRgn(HRGN(rgn),FALSE);

CFrameWnd::OnSize(nType, cx, cy);
}

And this code to draw the borders (yust a prototype, only gray borders):

void CMainFrame::OnPaint()
{
CDC* dc=GetWindowDC();
// TODO: Add your message handler code here
CDC dcImage;
dcImage.CreateCompatibleDC(dc);

CRect rect,clientRect;
GetWindowRect(&rect);

rect.OffsetRect(-rect.TopLeft());

dc->FillRect(&CRect(0,0,3,rect.bottom),&CBrush((COLORREF)0x7f7f7f));
dc->FillRect(&CRect(0,0,rect.right,3),&CBrush((COLORREF)0x7f7f7f));

dc->FillRect(&CRect(rect.right-3,0,rect.right,rect.bottom),&CBrush((COLORREF)0x7f7f7f));


dc->FillRect(&CRect(0,rect.bottom-3,rect.right,rect.bottom),&CBrush((COLORREF)0x7f7f7f));


// Do not call CSplitterWnd::OnNcPaint() for painting messages

ReleaseDC(dc);
}

This works fine, however when resize the window, it leves marks from the
corners on the screen. It looks like Windows is first drawing the border
as usual and then my drawing code draws over this border. The marks also
look like bit's of the original windows border.

I tried also to handle WM_NCPAINT, this results in the caption bar is
not drawn and after minimizing and maximizing the app, the whole client
are of the frame wnd isn't drawn until you rezie the window. However the
marks are still here.

Any Ideas or a pointer to a working sample of a non rectangular window
that is resizeable?

Thanks very much

-------------------------------
reto at truninger dot com


0 new messages