Link to home
Start Free TrialLog in
Avatar of shaun_hester
shaun_hester

asked on

PropertySheet Tab CustomDraw

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
Avatar of sarabande
sarabande
Flag of Luxembourg image

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
Avatar of shaun_hester
shaun_hester

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of sarabande
sarabande
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.