Hi guys
I am new to MFC programming or may be i cannot find the right answer over internet my bad luck my bad search.
Question: I need to draw a red border around any control displayed on mfc dialog it can be either combobox or spin control or anything else. so what i thought to create a new class derived from CStatic class and implements it OnNcPaint message for drawing border around it.
void CMystatic::OnNcPaint()
{
if(m_bDrawBorder)
{
CDC* pDC = GetWindowDC( );
CRect rect;
GetWindowRect( &rect);
rect.OffsetRect( -rect.left, -rect.top);
CBrush brush( RGB( 255, 0, 0));
pDC->FrameRect( &rect, &brush);
ReleaseDC( pDC);
}
else
{
CStatic::OnNcPaint();
}
}
CMyStatic is derived from CStatic class and m_DrawBorder is a member variable of this class for drawing border. which can set through any class which uses CMyStatic class object.For example while clicking button1 i am setting to draw border and while clicking button2 i am again resetting to original behavior of static control.
Issues
1. If a static text control property
BORDER is true the i run the application.Then i see some border which is like some frame in Z order it looks like some 3d or some depth order border which i do not need. On the other hand i require some 2-d border only like it shows when you do border property TRUE and look at the control at design time not at run time.
2. i don't want Z-order depth i just need 2-D border any buddy can help me and post code here. i have implemented other ways to but not help full.The code below is not helpful.
m_Mystatic.ModifyStyleEx(dwStyle,0,SWP_NOSIZE|SWP_FRAMECHANGED);
m_Mystatic.ModifyStyleEx(dwStyle,0,SWP_FRAMECHANGED);
m_Mystatic.ModifyStyleEx(0,WS_EX_CLIENTEDGE,SWP_FRAMECHANGED);
m_Mystatic.ModifyStyleEx(0,WS_EX_CLIENTEDGE,SWP_FRAMECHANGED);
NOTE: i just need to toggle between border and no border but no other sunken or other Z order border just plain static text
(i don't know how to add image otherwise i could upload it.)
Plzzzzzzzzzzzzzzzz reply