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 » Draw and Create on Windows Non Client Area Collapse All
Subject Author Date
Michael chang Dec 6, 2011 - 4:24 AM

Hi.


I’m implementing skinable project using Prof-UIS library 2.87 and ProfSkin.


I have two questions.


1.  Draw the text on Title bar


     In skin sample, Title bar is non client area and has some buttons(Close, Minimize, Maxmize) and SW Name.


     Can i draw another text on title bar?


 


2. Create button on CExtTabMdiWnd area.


     In your skin sample, CExtTabMdiWnd has some buttons(Close, Help, Scroll home......) and several tabs(Button, Color....)


     Can i create another button on this area?


 


Please reply to me about questions.


 

Technical Support Dec 6, 2011 - 12:36 PM

1. If you need to change text, you should simply invoke SetWindowText() API. If you need to re-paint caption (or caption text only), then you should implement your CExtPaintManagerSkin-derived paint manager class which implements the CExtPaintManagerSkin::NcFrame_Paint() virtual method. You can copy source code from the original method and draw caption text in your own manner. We are using the CExtRichContentLayout::stat_DrawText() API for painting text everywhere. It supports HTML as well as plain text. This is demonstrated in the RichContentFeatures sample application.

2. Please take a look at the following test project:
http://www.prof-uis.com/download/forums/MdiTabsCustomButton.zip

Michael chang Dec 7, 2011 - 4:12 AM

2. In test project, Compile is ok. but Can not excute the programe. "Unable to start program --path:MdiTabsCustomButton.exe"


 I compiled the project with visual studio 2008

Michael chang Dec 7, 2011 - 12:04 AM

 


I’m using CExtPaintManagerSkin class to implement my skin project already. So, I did not implement my skin class-derived paint manager class and I called CExtPaintManagerSkin::NcFrame_Paint() method in CMainFrame::OnPaint() in my project.


But, the caption is not changed. What’s wrong?


void CMainFrame::OnPaint()

{

 CPaintDC dc(this); // device context for painting

 // TODO: Add your message handler code here

 // Do not call __super::OnPaint() for painting messages

 // frame

 //COLORREF clr3dHilight = ::GetSysColor(COLOR_3DHILIGHT); // pPM->GetColor( COLOR_3DHILIGHT, this );

 //COLORREF clr3dFace = ::GetSysColor(COLOR_3DFACE); // pPM->GetColor( COLOR_3DFACE, this );

 //COLORREF clr3dShadow = ::GetSysColor(COLOR_3DSHADOW); // pPM->GetColor( COLOR_3DSHADOW, this );

 //COLORREF clr3dDkShadow = ::GetSysColor(COLOR_3DDKSHADOW); // pPM->GetColor( COLOR_3DDKSHADOW, this );

 COLORREF clr3dHilight = g_pclsSkin->GetColor( COLOR_3DHILIGHT, this );

 COLORREF clr3dFace = g_pclsSkin->GetColor( COLOR_3DFACE, this );

 COLORREF clr3dShadow = g_pclsSkin->GetColor( COLOR_3DSHADOW, this );

 COLORREF clr3dDkShadow = g_pclsSkin->GetColor( COLOR_3DDKSHADOW, this );


 RECT rcIcon, rcText, rcHelp, rcMinimize, rcMaximizeRestore,rcClose;


 CRect rcClient;

 GetClientRect( &rcClient );

 CPoint ptScrollPos(

  GetScrollPos( SB_HORZ ),

  GetScrollPos( SB_VERT )

  );


CRect rcMrg = CRect(0,0, 500, 100);// = CalcActualViewRect();

//rcMrg.OffsetRect( -ptScrollPos );


 // rcClient.OffsetRect( -ptScrollPos );

 //CExtMemoryDC dc(

 // pDC,

 // &rcClient,

 // CExtMemoryDC::MDCOPT_TO_MEMORY

 // |CExtMemoryDC::MDCOPT_NO_COPY_OPT

 // );


 //CRect rcMrg = CalcActualViewRect();

 //rcMrg.OffsetRect( -ptScrollPos );


 //CExtPaintManager * pPM = g_PaintManager.GetPM();

 //ASSERT_VALID( pPM );


 bool bNcFrameSupported = false;

 INT nCaptionHeight = 23;


//g_pclsSkin is an instance of CExtPaintManagerSkin class.

 if( g_pclsSkin->NcFrame_IsSupported( this ) )

 {

  bNcFrameSupported = true;

  nCaptionHeight = g_pclsSkin->NcFrame_GetCaptionHeight( true, ::AfxGetMainWnd() ) + 4;


  g_pclsSkin->NcFrame_GetRects(NULL, _T("Test"), 0, rcIcon, rcText, rcHelp, rcMinimize, rcMaximizeRestore, rcClose, ::AfxGetMainWnd(), NULL, 0);

 }


 CRect rcFrame( &rcMrg );

 rcFrame.InflateRect( 3, nCaptionHeight, 3, 0 );


 g_pclsSkin->PaintDocumentClientAreaBkgnd( dc, this );


 CRect rcDesignerWindowBk = rcFrame;

 rcDesignerWindowBk.OffsetRect( ptScrollPos );

 CRect rcDesignerClient( rcFrame );

 if( bNcFrameSupported )

 {

  CRect rcClientReal;

  GetClientRect( &rcClientReal );

  rcDesignerClient.top = rcMrg.top - 1;

  HRGN hRgn = g_pclsSkin->NcFrame_GenerateSkinFrameRGN( rcFrame, ::AfxGetMainWnd() );

  if( hRgn != NULL )

   ::SelectClipRgn( dc.m_hDC, hRgn );

  if( ! g_pclsSkin->PaintDockerBkgnd( true, dc, this ) )

   dc.FillSolidRect( &rcFrame, clr3dFace );

  CRect rcIcon( 0, 0, 0, 0 );

  //CRect rcText( 0, 0, 500, 23 );

  CRect rcHelp( 0, 0, 0, 0 );

  CRect rcMinimize( 0, 0, 0, 0 );

  CRect rcMaximizeRestore( 0, 0, 0, 0 );

  CRect rcClose( 0, 0, 0, 0 );

  CExtPaintManager::e_nc_button_state_t eStateButtonHelp = CExtPaintManager::__ENCBS_NORMAL;

  CExtPaintManager::e_nc_button_state_t eStateButtonMinimize = CExtPaintManager::__ENCBS_NORMAL;

  CExtPaintManager::e_nc_button_state_t eStateButtonMaximizeRestore = CExtPaintManager::__ENCBS_NORMAL;

  CExtPaintManager::e_nc_button_state_t eStateButtonClose = CExtPaintManager::__ENCBS_NORMAL;

  g_pclsSkin->NcFrame_Paint(

   dc,

   NULL,

   _T("Test"),

   0,

   rcFrame,

   rcDesignerClient,

   rcIcon,

   rcText,

   rcHelp,

   rcMinimize,

   rcMaximizeRestore,

   rcClose,

   true,

   true,

   false,

   eStateButtonHelp,

   eStateButtonMinimize,

   eStateButtonMaximizeRestore,

   eStateButtonClose,

   ::AfxGetMainWnd()

   );

  if( hRgn != NULL )

  {

   ::SelectClipRgn( dc.m_hDC, NULL );

   ::DeleteObject( hRgn );

  }

 } // if( bNcFrameSupported )

}

Technical Support Dec 8, 2011 - 8:58 AM

We think you should copy the required Prof-UIS DLL file into the same folder where the compiled MdiTabsCustomButton.exe application is located.

Michael chang Dec 8, 2011 - 9:48 PM

Thanks. I have created a button on MyMditab successfully. One more thing, How to skin the button i created like close/help button? is it possible. 

Technical Support Dec 12, 2011 - 1:08 PM

You should override the CExtTabFlatWnd::OnTabWndDrawButton() virtual method to redraw tab button(s).

Technical Support Dec 8, 2011 - 8:57 AM

The WM_PAINT message is sent to paint the window client area. The window caption and borders are part of window non-client area and they can be painted by handling the WM_NCPAINT message.