?
Solved

PropertySheet Tab CustomDraw

Posted on 2013-05-20
4
Medium Priority
?
277 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 35

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 35

Accepted Solution

by:
sarabande earned 800 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
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.

650 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