|
|
|
|
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.
Subject |
Author |
Date |
|
Ian McIntosh
|
May 17, 2007 - 10:04 AM
|
One of our developers has a control derived from a CWnd that is owner draw - via OnPaint. It is placed on a dialog derived from CExtResizableDialog.
There are also some prof-UIS based controls (CExtButtons) on the dialog.
Before the CWnd based control was placed on the dialog, it drew OK. Now it doesn’t - the buttons are not displayed but are drawn if you click where they should be.
Any suggestions?
|
|
Ian McIntosh
|
May 18, 2007 - 2:10 AM
|
Your reply seems to be explaining how to draw a custom background, which is not what I want to do.
Let me try to explain again.
I have a CExtResizableDialog based dialog that has several controls on it, created in the resource view. When the dialog contains only controls that derive from prof-UIS classes (eg, buttons deriving from CExtButton), the dialog draws as expected. When a control that is not prof-UIS based (ie, derives from CWnd) and that is owner draw (overrides the OnPaint), the dialog no longer draws as expected - now the CExtButton derived buttons are not drawn (but are drawn if you click where they should be).
It seems that having a CWnd derived class that overrides OnPaint as a control on a CExtResizableDialog interferes with the drawing of the controls &/or background of the dialog. Is this the case?
Is it valid to have a non prof-UIS control on a CExtResizableDialog derived dialog? If so, is it valid to have which overrides OnPaint?
Is there a prof-UIS class that should be used as the basis of an owner draw control in place of CWnd?
Any helpful advice much appreciated.
|
|
Technical Support
|
May 18, 2007 - 11:31 AM
|
There are no restrcitons on using CWnd based controls with Prof-UIS ones. Moreover many Prof-UIS controls are based on CWnd itself. There is one importing thing that is worth to be mentioned. Your custom controls should paint a valid background which is compatible with the dialog background and current theme. Here is how your OnPaint may look: void CYourWnd::OnPaint()
{
ASSERT_VALID( this );
CPaintDC dcPaint( this );
CRect rcClient;
GetClientRect( &rcClient );
if( rcClient.IsRectEmpty() )
return;
CExtMemoryDC dc(
&dcPaint,
&rcClient
);
CRgn rgnClient;
if( rgnClient.CreateRectRgnIndirect( &rcClient ) )
dc.SelectClipRgn( &rgnClient );
// draw themed background first
bool bTransparent = false;
if( g_PaintManager->GetCb2DbTransparentMode( this ) )
{
CExtPaintManager::stat_ExcludeChildAreas(
dc,
GetSafeHwnd(),
CExtPaintManager::stat_DefExcludeChildAreaCallback
);
if( g_PaintManager->PaintDockerBkgnd( true, dc, this ) )
bTransparent = true;
}
if( ! bTransparent )
dc.FillSolidRect(
&rcClient,
g_PaintManager->GetColor( CExtPaintManager::CLR_3DFACE_OUT, this )
);
//////////////////////////////////////////////////////////////////////
// PLACE CONTROL PAINTING CODE HERE
//////////////////////////////////////////////////////////////////////
if( rgnClient.GetSafeHandle() != NULL )
dc.SelectClipRgn( &rgnClient );
g_PaintManager->OnPaintSessionComplete( this );
}
|
|
Technical Support
|
May 17, 2007 - 12:18 PM
|
The CExtResizableDialog class is based the CExtWS template class. The latter handles WM_PAINT in its CExtWS::WindowProc() method. If you need to implement a custom background over the default themed background of the dialog window, please override the WindowProc() virtual method in your CExtResizableDialog -derived class: LRESULT CYourDialogClass::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_PAINT:
CPaintDC dcPaint( this );
CRect rcClient;
GetClientRect( &rcClient );
CExtMemoryDC dc( &dcPaint, &rcClient );
//
// FIRST STEP: Draw Prof-UIS themed background here
//
COLORREF clrBackground = GetBkColor();
bool bTransparent = false;
if( PmBridge_GetPM()->GetCb2DbTransparentMode(this)
&& ( clrBackground == COLORREF(-1L) )
)
{
CExtPaintManager::stat_ExcludeChildAreas(
dc,
GetSafeHwnd(),
CExtPaintManager::stat_DefExcludeChildAreaCallback
);
if( PmBridge_GetPM()->PaintDockerBkgnd( true, dc, this ) )
bTransparent = true;
}
if( (! bTransparent)
&& clrBackground != COLORREF(-1L)
)
dc.FillSolidRect(
&rcClient,
clrBackground
);
PmBridge_GetPM()->OnPaintSessionComplete( this );
//
// SECOND STEP: Draw your custom things into dc here
//
return 0L;
}
return CExtWA CExtResizableDialog::WindowProc( message, wParam, lParam );
}
|
|