Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 531
  • Last Modified:

Title bar will not display in Splitter Window Pane

I have a splitter window with 2 panes.
I cannot get the dialog displayed in one of the panes to display a title bar.  I have set the title bar checkbox on the styles tab of the dialog properties but it does not display. (Other properties for the dialog include a thin border and the style as child)
0
birosra
Asked:
birosra
  • 3
1 Solution
 
danny_pavCommented:
When you create a dialog resource for a CFormView derived object, there are certain styles that must be set and others that must not be set.  

From MSDN:

Design a dialog template.

Use the dialog editor to design the dialog box. Then, in the Styles and More Styles property pages, set the following properties:


•In the Style box, select Child (WS_CHILD on).
•In the Border box, select None (WS_BORDER off).
•Clear the Visible check box (WS_VISIBLE off).
•Clear the Titlebar check box (WS_CAPTION off).


These steps are necessary because a form view is not a true dialog box.

--
The form's caption is given by the parent, usually some CFrameWnd-derivative.  In your case, the CSplitterWnd is its parent.  

No matter what you do (short of rewriting windows) you will not get a title bar inside the splitter pane.

0
 
danny_pavCommented:
That should be my answer, sorry.
0
 
birosraAuthor Commented:
Before I give up on this,
Would any others like to comment on Danny's response
(agree or have some magical resolution to the problem):
"No matter what you do (short of rewriting windows) you will not get a title bar inside the splitter pane. "
0
 
jstolanCommented:
Danny is pretty much correct.  However you can easily simulate the caption area.  Simply leave enough room at the top to draw whatever caption you would like.  Then use the WM_PAINT message to draw over the form view.  The code snippet below draws a header that looks like a windows 3d Caption:

void CMyFormView::DrawCaption(CDC * pDC)
{
    CRect rcClient;
    GetClientRect( &rcClient );
    CRect rcDraw = rcClient;
    rcDraw.bottom = rcDraw.top+GetSystemMetrics(SM_CYCAPTION);
    COLORREF clrOldText = pDC->SetTextColor( GetSysColor(COLOR_WINDOWTEXT));
    pDC->FillSolidRect( &rcDraw,GetSysColor(COLOR_3DFACE));
    CPen cBlackPen;
    cBlackPen.CreatePen( PS_SOLID,1, RGB(0,0,0) );
    CPen cShadowPen;
    cShadowPen.CreatePen( PS_SOLID,1,
GetSysColor(COLOR_3DSHADOW));
    CPen cHighLightPen;
    cHighLightPen.CreatePen( PS_SOLID,1,GetSysColor(COLOR_3DHIGHLIGHT) );
    rcDraw.DeflateRect(1,1);
    CPen* pOldPen = pDC->SelectObject( &cShadowPen );
    pDC->MoveTo(rcDraw.left,rcDraw.bottom);
    pDC->LineTo(rcDraw.right,rcDraw.bottom);
    pDC->LineTo(rcDraw.right,rcDraw.top-1);
    pDC->SelectObject( &cHighLightPen );
    rcDraw.InflateRect(1,1);
    pDC->MoveTo(rcDraw.left,rcDraw.bottom);
    pDC->LineTo(rcDraw.left,rcDraw.top);
    pDC->LineTo(rcDraw.right,rcDraw.top);
    pDC->SelectObject( &cBlackPen );
    pDC->MoveTo(rcDraw.left,rcDraw.bottom);
    pDC->LineTo(rcDraw.right,rcDraw.bottom);
    pDC->LineTo(rcDraw.right,rcDraw.top-1);
    pDC->SelectObject( pOldPen );
    cBlackPen.DeleteObject();
    cShadowPen.DeleteObject();
    cHighLightPen.DeleteObject();

    HFONT hSystemFont = (HFONT)GetStockObject( ANSI_VAR_FONT );
    CFont* pFont = CFont::FromHandle( hSystemFont );
    CFont* pOldFont = pDC->SelectObject( pFont );
    pDC->SetBkMode( TRANSPARENT );
    CRect rcTemp = rcDraw;
    pDC->DrawText( _T("My Caption"),&rcTemp,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
    pDC->SetTextColor( clrOldText);
    pDC->SelectObject( pOldFont );
}

Be warned, I edited this from an application I had that did things slightly differently.  There may be a minor glitch or two, but I think you get the idea.  Also note that this will not give you the minimize, maximize or exit buttons used by some caption styles.
0
 
danny_pavCommented:
What kind of caption will that draw?  Will that draw the old style (Win 3.11, NT 3.51) or the new style (Win 95, NT 4.0)?


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now