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
Solved

PropertySheet Tab CustomDraw

Posted on 2013-05-20
4
272 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 33

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 33

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Arduino EDI - Programming language 3 103
Path to  STL Map header file 1 69
Super Scope, DHCP 5 91
FMX TEdit KeyUp handler detecting  "enter" key 4 13
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…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

860 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