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 Tech Support » Is there a way to draw a themed line? Collapse All
Subject Author Date
Offer Har Feb 27, 2009 - 4:49 AM

Dear Support,


I will like to have a static control that will have a line completing it, much like the one described here:


http://www.codeproject.com/KB/static/cseparator.aspx#@lt;/p>

Or here:


http://www.codeproject.com/KB/static/groupline.aspx#@lt;/p>

For implementing this, I need to draw a line, but of-course I need it to be themed with the current Prof-UIS theme.


What function can I use?


Thanks,


Ron.

Technical Support Feb 28, 2009 - 3:48 AM

Here is how your code should look like:

#if (!defined __EXT_MEMORY_DC_H)
            #include <../Src/ExtMemoryDC.h>
#endif

void CYourClass::OnPaint() 
{
CPaintDC dcPaint( this );
CRect rcClient;
            GetClientRect( &rcClient );
            if( rcClient.IsRectEmpty() )
                        return;
CExtMemoryDC dc( pDC, &rcClient );
bool bDrawDefaultBackground = true;
            if( g_PaintManager->GetCb2DbTransparentMode(this) && g_PaintManager->PaintDockerBkgnd( true, dc, this ) )
                        bDrawDefaultBackground = false;
            if( bDrawDefaultBackground )
                        dc.FillSolidRect( &rcClient, g_PaintManager->GetColor( CExtPaintManager::CLR_3DFACE_OUT, this ) );  
            //
            // Themed background is ready. Draw your control over it here.
            //
}

BOOL CYourClass::OnEraseBkgnd( CDC * pDC ) 
{
            pDC;
            return TRUE;
}


Offer Har Mar 2, 2009 - 7:05 AM

I also need to draw themed text - how do I do this?

Technical Support Mar 2, 2009 - 9:46 AM

You should draw text using the classic MFC’s CDC::DrawText() or Win32 ::DrawText() API and the g_PaintManager->GetColor( CExtPaintManager::CLR_TEXT_OUT, NULL ) text color.

Offer Har Mar 2, 2009 - 7:03 AM

I think you did not understand what I asked... I need to draw a separator line in the themed style, not only the back-ground.


I understand the code you provided above draws the control in the color of the background, but how do I add the themed line onto it?


Thanks,


Ron.

Technical Support Mar 2, 2009 - 9:46 AM

You should invoke the g_PaintManager->PaintSeparator( . . . ) code. Here is the declaration of the CExtPaintManager::PaintSeparator() virtual method:

virtual void PaintSeparator(
            CDC & dc,
            const RECT & rectItem,
            bool bHorz,
            bool bTransparentBk,
            CObject * pHelperSrc,
            LPARAM lParam = 0L
            );

Offer Har Mar 2, 2009 - 7:01 AM

Hi,


This code does not compile - in


CExtMemoryDC dc( pDC, &rcClient );

The pDC is not defined anywhere in the function.


I tried to replace it with &dcPaint, but I don’t see any line (it does not draw anything)


Please note that I am using it in a dialog.


Thanks,


Ron.

Technical Support Mar 2, 2009 - 9:46 AM

We are sorry. The pDC is really &dcPaint:

#if (!defined __EXT_MEMORY_DC_H)
            #include <../Src/ExtMemoryDC.h>
#endif

void CYourClass::OnPaint() 
{
CPaintDC dcPaint( this );
CRect rcClient;
            GetClientRect( &rcClient );
            if( rcClient.IsRectEmpty() )
                        return;
CExtMemoryDC dc( &dcPaint, &rcClient );
bool bDrawDefaultBackground = true;
            if( g_PaintManager->GetCb2DbTransparentMode(this) && g_PaintManager->PaintDockerBkgnd( true, dc, this ) )
                        bDrawDefaultBackground = false;
            if( bDrawDefaultBackground )
                        dc.FillSolidRect( &rcClient, g_PaintManager->GetColor( CExtPaintManager::CLR_3DFACE_OUT, this ) );  
            //
            // Themed background is ready. Draw your control over it here.
            //
}

BOOL CYourClass::OnEraseBkgnd( CDC * pDC ) 
{
            pDC;
            return TRUE;
}