Solved

PropertySheet Tab CustomDraw

Posted on 2013-05-20
4
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 34

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 34

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

705 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