?
Solved

Title bar colour

Posted on 2000-02-04
7
Medium Priority
?
312 Views
Last Modified: 2013-11-20
Is it possible to tweak the title bar's colour and set it by ourselves?
0
Comment
Question by:Aphroditus
  • 4
  • 2
7 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 2491414
Use the SetSysColors function with the following elements.

COLOR_ACTIVECAPTION
COLOR_CAPTIONTEXT
COLOR_GRADIENTACTIVECAPTION
COLOR_GRADIENTINACTIVECAPTION
COLOR_INACTIVECAPTION
COLOR_INACTIVECAPTIONTEXT
0
 
LVL 1

Expert Comment

by:mjswart
ID: 2491422
It will take more than a tweak.
I assume that you don't want to change the title bar of _all_ windows.

I found this microsoft article on the subject:
HOWTO: Draw a Custom Window Caption
http://support.microsoft.com/support/kb/articles/Q99/0/46.ASP

explanations, sample code etc...

Good luck, Mike
0
 

Author Comment

by:Aphroditus
ID: 2497305
I am a real beginner and would like further explanation on how to do this on a dialog box's caption bar instead of the mainframe's...
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Accepted Solution

by:
mjswart earned 100 total points
ID: 2497322
There's no one-liner that does this.

You'll have to create a new class of dialog box and override some methods.

Is there something at http://support.microsoft.com/support/kb/articles/Q99/0/46.ASP that you don't understand?
0
 

Author Comment

by:Aphroditus
ID: 2498028
mjswart,
may i know which methods of the dialog box must i override...

I don't understand how dialog boxes handle their caption bar. Hope you could shine some light here.
0
 
LVL 1

Expert Comment

by:mjswart
ID: 2498193
You'll have to add handlers for
WM_NCPAINT and
WM_NCACTIVATE.

Use the class wizard to create OnNcPaint and OnNcActivate for you. Call the default implementations: CDialog::OnNcPaint and CDialog::OnNcActivate and then do your own thing similar to microsoft's page.

Mike
0
 
LVL 1

Expert Comment

by:mjswart
ID: 2498226
Try to expand on the following:

void CTestingDlg::OnNcPaint()
{
    RECT rc1, rc2;

    // Let Windows do what it usually does. Let the window caption
    // be empty to avoid any Windows-initiated caption bar drawing
    CWnd::OnNcPaint();

    CDC *pDC = GetWindowDC();
    GetWindowRect( (LPRECT)&rc2 );

    // Compute the caption bar's origin. This window has a system box
    // a minimize box, a maximize box, and has a resizeable frame

    int x = GetSystemMetrics( SM_CXSIZE ) +
        GetSystemMetrics( SM_CXBORDER ) +
        GetSystemMetrics( SM_CXFRAME );
    int y = GetSystemMetrics( SM_CYFRAME );
        rc1.left = x;
        rc1.top = y;

    // 2*x gives twice the bitmap+border+frame size. Since there are
    // only two bitmaps, two borders, and one frame at the end of the
    // caption bar, subtract a frame to account for this.

    rc1.right = rc2.right - rc2.left - 2*x -
        GetSystemMetrics( SM_CXFRAME );
    rc1.bottom = GetSystemMetrics( SM_CYSIZE );

    // Render the caption. Use your own color...

    COLORREF cr = pDC->SetBkColor( 0x00777777 );
    pDC->DrawText( (LPSTR)"Left Justified Caption", -1,
        (LPRECT)&rc1, DT_LEFT );
    pDC->SetBkColor( cr );
}
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question