Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Static Control (custom draw) Collapse All
Subject Author Date
Francesco A Oct 13, 2003 - 8:21 AM

Hallo,
I’m using your last free version of prof-uis. I tried to subclass a CExtButton to build a custom "CExtStatic" control but I have a lot of problems during repainting. All works great if I’m using this code in a Modal Dialog but if I put a static control in a dialog box displayed in a CExtControlBar I got a lot of "non-sense" lines when, for example, I move another window over the control.
I added to the onPaint function only this code (I want only to display a sort of separator line...):

PaintDC dc(this); // device context for painting
CDC cdc;
cdc.CreateCompatibleDC( &dc ) ;
CString strText;
CSize txtSize;
CRect rc;
DWORD dwFlags;
GetClientRect(rc);
GetWindowText(strText);
txtSize = dc.GetTextExtent(strText);
dc.Draw3dRect (
    txtSize.cx, rc.Height()/2,
    rc.Width()-txtSize.cx, 2,
    ::GetSysColor(COLOR_3DSHADOW),
    ::GetSysColor(COLOR_3DHIGHLIGHT) );

I started to subclass the CExtButton control because this problem appears with all custom controls that I tried (the CLabel from codeproject for example...). I suppose that it can be solved using your paint manager (all your controls looks great in the same dialog :)) but I don’t know how I can do that...
I also tried to fill the background with another color.. and it works great.. but I don’t know how to find the current dialog colour to simulate a sort of transparent control...
Thank’s in advance,
Francesco

Sergiy Lavrynenko Oct 13, 2003 - 11:35 AM

Hi,

Unfortunately you forgot do describe type of your static control (simple text, frame control).

Tips for background painting:

  • with 2000/XP themes just use g_PaintManager->GetColor(CExtPaintManager::CLR_3DFACE_OUT)color as a background color of your control in dialog

  • with Office 2003 theme please use g_PaintManager->PaintDockerBkgnd() method because it provides valid gradient fill

  • you can find the complete and universal painting algorithm in the CExtWS::WindowProc() method (please look for WM_PAINT and WM_ERASEBKGND in this method)

  • of course, you can use CExtWS template in the basic type of your window

Best regards, Sergiy.

Francesco A Oct 13, 2003 - 4:07 PM

Thank you very much... Tomorrow I will try to fix this problem filling the background. Btw the control that I’m using is a label (simple text) but I tried with a picture control also (both with my class derived from CExtButton that using CLabel class from codeproject...) and I always I got the same background problem (with CLabel only if I enable transparency)

Best regards,
Francesco