Click here to Skip to main content
15,911,360 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Dear All,
I have read the article here, and try to custom some Windows Controls by extending it to a new one.

First, I extended a CSliderCtrl class to a new RoundedRectangle one.
And it works!
But when I transplant the method and code to custom a RoundedRectangle CEdit or CButton.
It failed.
Why does it happend?
Below are my code.

I only override the
1. PreCreateWindow
2. PreSubClassWindow
3. OnPaint

below code is for changing the shape of it.
CRect rect;
GetClientRect(&rect);int w = rect.Width();//the rect width
int h = rect.Height();//the rect height
int uper_left_x=rect.TopLeft().x;
int uper_left_y=rect.TopLeft().y;
int lower_right_x=rect.BottomRight().x;
int lower_right_y=rect.BottomRight().y;
int elipse_width=lower_right_y-uper_left_y;//the obtuse angle size
int elipse_height=elipse_width;//the obuse angle sizeCRgn rgn1;
SetWindowRgn(NULL, FALSE);

	//modify this to larger
bool b=rgn1.CreateRoundRectRgn(uper_left_x,uper_left_y,lower_right_x,lower_right_y,elipse_width,elipse_height);
SetWindowRgn(rgn1, TRUE);


Thease code works fine with extended CSliderCtrl, but fail on extended CButton and CEdit,which can't change shape like the exteded CSliderCtrl.

Could someone help me to slove this?^^

Thanks in advance.
Posted

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900