Click here to Skip to main content
15,942,125 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to change the shape of button without creating button variable.

What I have tried:

I tried the below code on onDraw ,
int nX1 = 0;
int nX2 = 100;
int nY1 = 0;
int nY2 = 100;
m_point = new POINT();
m_point->x = 100;
m_point->y = 100;
pDC->RoundRect(nX1, nY1, nX2, nY2, m_point->x, m_point->y);

but it goes on overwriting, i used the same code on onpaint and it does not work. Please help me.
Updated 29-Mar-16 23:44pm

1 solution

All GUI controls like buttons are just windows which handle the drawing on their own. So drawing something on the area of the control will be overwritten when the control is redrawn which happens upon several conditions.

The common solution is deriving a class using owner-draw which requires the usage of a member variable in the dialog class to link the resource item to your derived class.

If you don't want to use the above method, you can handle the WM_DRAWITEM message (Windows)[^] in your dialog containing the button. When the button has the owner draw style set, the message will be send to the parent window.
Share this answer

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