Solved

PropertySheet Tab CustomDraw

Posted on 2013-05-20
4
267 Views
Last Modified: 2013-06-06
I want to be able to colour the tabs on the propertysheet, as shown in the jpg. However I can not seem to figure out how to add the customer draw style to the tabs in the propertysheet. I'm creating the property sheet like this.

PROPSHEETPAGE psp[4];
PROPSHEETHEADER psh;

psp[0].dwSize      = sizeof(PROPSHEETPAGE);
psp[0].dwFlags     = PSP_USEICONID | PSP_USETITLE;
psp[0].hInstance   = g_hInstance;
psp[0].pszTemplate = MAKEINTRESOURCE(IDD_DETAILS);
psp[0].pszIcon     = NULL;
psp[0].pfnDlgProc  = DlgProcMemberDetails;
psp[0].pszTitle    = "TabOne";
psp[0].lParam      = (LPARAM) member;
psp[0].pfnCallback = NULL;
/* Repeat replacing [0] -> [3] */

psh.dwSize      = sizeof(PROPSHEETHEADER);
psh.dwFlags     = PSH_PROPSHEETPAGE;
psh.hwndParent  = hDlg;
psh.hInstance   = g_hInstance;
psh.pszIcon     = NULL;
psh.pszCaption  = "Caption";
psh.nPages      = sizeof(psp) / sizeof(PROPSHEETPAGE);
psh.nStartPage  = 0;
psh.ppsp        = (LPCPROPSHEETPAGE) &psp;
psh.pfnCallback = NULL;

PropertySheet(&psh);
PropertySheet.JPG
0
Comment
Question by:shaun_hester
  • 2
  • 2
4 Comments
 
LVL 32

Expert Comment

by:sarabande
ID: 39185844
i don't know in which function you create the above property sheet. but in the moment when the function returned the structure objects psp[4] and psh will go out of scope and therefore all data assigned to those structures become invalid.

you have to change those variables to become members of a class instance which lives longer than the property sheet frame and its property page windows. alternativey you could create the property sheet and property page structures on the heap (by new). but even in that case (which is less recomendable) you need to save the pointers in a class or structure which was created before and was destroyed later than all the windows were closed.

Sara
0
 

Author Comment

by:shaun_hester
ID: 39223603
The property sheet is modal, hence the PropertySheet(&psh); function does not return until the propertysheet is destroyed. So scope is not an issue here.

The simple thing which I just cannot seem to figure out is how to obtain a handle to the tab control within the propertysheet, if I could do that I could then override the window procedure for that control and process the custom draw message for the tab control.
0
 
LVL 32

Accepted Solution

by:
sarabande earned 200 total points
ID: 39225150
the PropSheet_GetTabControl should do what you want.

HWND PropSheet_GetTabControl(
  HWND hPropSheetDlg
);

Open in new window

you may call it in the callback which was called when the property sheet was created and initialized.

int CALLBACK PropSheetProc(HWND hwndDlg,  UINT uMsg,  LPARAM lParam)
{
     switch (uMsg)
     {
     case PSCB_INITIALIZED:
          {    
               HWND hwndTabCtrl = PropSheet_GetTabControl(hwndDlg); 
               ....
}
....
psh.pfnCallback = &PropSheetProc;

Open in new window



Sara
0
 

Author Comment

by:shaun_hester
ID: 39226366
PropSheet_GetTabControl

I can not believe I missed that function, thanks for your help with this one, I think I need to go to spec savers, or just read the msdn pages a bit slower :-)

I now have one of my tabs red and the rest the standard color, thanks again.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

758 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

13 Experts available now in Live!

Get 1:1 Help Now