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();
int h = 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;
int elipse_height=elipse_width;
SetWindowRgn(NULL, FALSE);
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.