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 » CExtResizableDialog custom paint problem Collapse All
Subject Author Date
Dominik Braendlin Jun 20, 2008 - 1:16 AM

I have a CExtResizableDialog based dialog where I am trying to draw somthing into the boundaries of a group control.

In order to paint I am using the following code snipped as found on your page:

//---------------------------------------------------------------------------

LRESULT CLithoGroupEditDlg::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )

{

 switch( message )

 {

    case WM_PAINT:

    {

      CPaintDC dc( this );

      DisplayGroupBitmap(&dc);

      return 0;

    }

 }

 return CExtResizableDialog::WindowProc( message, wParam, lParam );

}

 

All works fine as long as I am not calling the SubclassChildControls in OnInitDialog.

 CExtResizableDialog::OnInitDialog();

 ShowSizeGrip(FALSE);

 SubclassChildControls();

 

If I do this I cannot see my drawing within the group control anymore. I suggest that the group control somehow overlaps my painting because it may be drawn after my drawing.

Do you have any suggestion how I could solve this issue.

 

Thanks

 

Dominik Braendlin Jun 23, 2008 - 5:09 AM

I have tested your suggestion and so far it seems to work.

Since I am using the Group Box only as a “picture frame” this new approach seems to me much more work than just copying my bitmap onto the background of that Group Box. I was wondering if there is an easier way that allows the Paint manager to do its thing such as painting the right background and then having me copying my bitmap on top of it. Since I do not need the whole WindowRect of the Group Box there is still that remaining excess space around it. With the new approach it seems to me that I have to provide a bitmap of the size of the WindowRect of the Group Box instead of the ClientRect or smaller.

Technical Support Jun 22, 2008 - 1:16 PM

This approach can be used for repainting the background of a resizable dialog rather than the dialog’s controls. You should use the approach used in the TabbedBars sample application (inherited background painting). It’s possible to the paint background of some window, including a dialog, and the drawn background will be inherited by child windows. First of all, you should invoke the following code to turn the inherited background painting feature on:

g_PaintManager->m_bCustomBackgroundInheritanceEnabled = true;
This code should be invoked both at startup and after selection of a new paint manager. If the inherited background painting feature is turned on, the CExtPaintManager::g_nMsgPaintInheritedBackground message is sent to all the windows and allows you to paint a solid background shared between parent/children windows. This message is handled in the TabbedBars sample where you can turn on the a hurricane-like background in the main frame window and a consistent gradient background in dialog windows inserted as pages into a One Note tab page container window.