Click here to Skip to main content
13,052,022 members (62,660 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all
i want to create a round button in my apps-MFC ActiveX Control
in the function ONCREATE of project
i have created a variable _button as CButton
and i use API Create():
_button.Create(_T("button view",WS_VISIABLE,CRect(15,15,20,10), this,1);

after, in the function OnDraw

however, button is show not a round button
can help me
thank so much
Posted 17-Apr-13 16:03pm
Sergey Alexandrovich Kryukov 17-Apr-13 22:28pm
This is an interesting question! But you are trying to do something with graphics, which won't give you "really" non-rectangle window. There is an "absolute" method of doing it.
Please see my answer.
I voted 4 for the question.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

All the magic is done via one important Windows API function SetWindowRgn:[^].

You create a non-rectangular region and call this function on some HWND when a handle of some window is already created. This make "real" non-rectangular window, not only visually, but observable via mouse hits. Don't mix it up with tricks performed on DC clip regions: they only give some visual effect, but the actual window, by a mouse hit test, is still rectangular.

I found a short manual, just to see what's involved:[^].

There is no a problem to do it with MFC, which is tightly coupled with raw Windows API and based on it. Anyway, HWND window handle for controls is always accessible.

dev C plus 17-Apr-13 22:43pm
thanks a lot
so, i have know it.
i have created a object CDC
and object CRect to create a rectangular
after, i use object CDC to create ellipse (in API Create of class CButton)
but, when compile to application thi not used
CDC* pdc;
CRect rect(15,15,20,15);
_button.Create(_T("button view",WS_VISIABLE,rect, this,1);
Why CDC, etc.? You create a region and call the SetWindowRgn, that's it. CDC is the wrapper around device context. This is unrelated thing.

For an ellipse use Window API CreateEllipticRgn. And so on...

Look, you have everything you need, don't get distracted with unrelated aspects.
Did you got it now? If yes, don't forget to accept the answer formally (green button).
nv3 18-Apr-13 3:07am
My 5.
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 17 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100