CtabCtrl Better look...

Posted on 2003-11-25
Last Modified: 2013-11-20
Hi everybody,

In one of my dialogs, I use a CtabCtrl. (I use CTabCtrlSSL from Derek Lakin found at
Everything works nice but I'd like to give to this TabPanel a better look, but for example by setting a bitmap as background, or a color...
CTabCtrlSSL is a subclass of CTabCtrl.
Does anyone could help me doing this?
Question by:vinceTrace
  • 3
  • 3
LVL 44

Expert Comment

ID: 9816825
Provide a handler for the WM_ERASEBKGND message.  In the handler BitBlt your bitmap into place and return TRUE to tell the system you have performed the erase background yourself (else the default is then called).

Author Comment

ID: 9816865
I must provide this handler to my TabPanel or to the dialog which contains the tab?
The dialog is a subclass of BkDialogST also found at codeproject.
When I right click on my dialog or my Tab and choose 'Events',  WM_ERASEBKGND  is not in the list of new events...
LVL 44

Expert Comment

ID: 9816891
Put it into your customised tab control.
From the wizard with the events change the selection of available events to window (child window) so the WM_ERASEBKGND appears in the list.
Try putting a breakpoint in the stub provided to check your tab control does receive the event.
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.


Author Comment

ID: 9817304
I right click in my dialog and choose child window in the events wizard. I had WM_ERASEBKGND handler to my AppDlg.cpp.
In this handler I call BitBlt, but I'm not sure how to instantiate the trwo HDC needed, and I don't know how to find the x and y coordinates of my TabPanel. Are the in App.rc file ?

Author Comment

ID: 9817487
I have found the needed coordinates, but I still don't know how to initiate the two HDC.
I 've tried       HDC hDC = ::GetWindowDC(NULL);
but I have a black rectangle instead of the portion of bitmap expected...
LVL 44

Accepted Solution

AndyAinscow earned 125 total points
ID: 9817984
You get a pDC with the OnEraseBkgnd(CDC* pDC), use that for the BitBlt.
CRect rect;
now you have the width and height of the tab control (assuming this is in your tab control derived class else you need a pointer to that for the GetClientRect fn).

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop in java 3 114
no14 challenge 14 56
Sed question 2 45
Updating statistics with error notification email in SQL server 4 44
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now