Adding a Control to the Property Sheet

WEBINAR:On-demand webcast

How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >

Each property page has its own set of controls. The only control that they share are the standard button in the property sheet itself. If you want to add an edit control, a preview button or any other control, you have to do it at run time. The code below shows you how to add an edit control.

Step 1: Derive your own class from CPropertySheet

We cannot use the CPropertySheet class directly, since we need to add a member variable. If you aren't already using a sub-class of CPropertySheet then derive one.

Step 2: Add member variable

Add member variable to the CPropertySheet derived class. The edit control will be created and accessed using this member.

public:
CEdit m_edit;

Step 3: Create the edit control in OnInitDialog

Override the OnInitDialog() function and add the code to create the edit control to this function. It is a good idea to call the base class version of the function before doing anything specific for the derived class.

The property sheet is first resized to accommodate the new edit control. The edit control is then created at the desired location. The WS_EX_CLIENTEDGE gives it a 3-D look. The edit control is created with a different font than used by other control. We fix this by a call to SetFont() and set the font to be the same as the property sheet.

The text value in the edit control can be set or retrieved using the m_edit object.

Comments

msnu

Posted by Mah wari
on 10/16/2014 01:06pm

Hi
I have a dialog which contains property sheet and this sheet has property pages.
my dialog has pushlike radio button .
now I am adding one more property page which has an editbox cotrol dynamically to property sheet.
every thing added n show properly . Now when I am at my dynamically added page and click on the parent dialog's radio button then my application hung (seems like entered in infinite loop) and I have kill my app.
pls suggest solution apporach.

how to enforce focus on dlg item of another page

I wrote a property sheet with some edit fields and combo boxes on one page. I don't want the user to leave this page by choosing another page or apply or OK if the data of these items are not plausible. I can catch the application killing the focus on these items but I cannot prevent it from leaving the page or the sheet at all. Moreover, if I issue a message "data not correct" on KILLFOCUS, this happens even then, if the user wants to cancel the whole sheet. Do you know a solution?
Thanks in advance.
Stephan

I was wondering if anyone knew how to add the "Connect to Server" property page that comes up when, for example, one clicks on the Computer Management node or other nodes. I am trying to create a customized MMC snapin and I am looking for some help as to how to add on the "Connect to Server" dialog box when the user adds the MMC snapin. I am also using the Visual Basic designer. Any help is much appreciated. Thank you.

Initializing Pages with value in Registry(like Properties)

I am trying to create a property sheet with 3-4 pages for setting options. (just like the ones you get right click desktop, then properties).

My problem is: HOW and where do I initialize the pages with the previous stored values (they are in registry and i can retrieve them).

For example, say the value in memory is 20. i have 4 radio buttons with titles 5, 10, 20, 40. I want the "20" button checked when the pages first shows. There after, that page will show whatever the user clicked just before switching pages.

Controls in Property Page doesnt work

Re sir i have embedde property sheet int the dialog, using CPropertySheet in OninintDialog, Now the Probs, is i have a button in Property page, on whose click, event i want many actions on the dialog, say display of Message Box, but when i have BN_CLICKED event for that button and put my code, the application hangs, plz suggest me some solutions, fast waiting eagerly for reply

How to add Scroll bar to PropertySheet as well as in PropertyPages?

I have enabled Scroll bar using EnableScrollBarCtrl function of PropertyPage but it is difficult to activate it, I cant move the pages up and down.I have even tried out by calling OnVScroll function of respective page and sheet, but iam unable to achieve it. Kindly help me out my problem.

How to use the "Help button" in propertysheet ??

I set
propsheet.m_psh.dwFlags |= PSH_HASHELP;
to enable the Help button in propertysheet,but I cann't use this Help button. Could somenoe tell me how to "highlight" Help button that I can press the Help button. thanks!

How to add control when propert sheet si dynamically created

Hi
Thanks for such useful information.
I have to add one more button to the already set of standard buttons.
My property sheet is dynamically created.
There is no OnInitDialog function.
Where should i put the code and also i get assertion at

GetWindowRect(rectWnd);

I have a derived class already.

IMPLEMENT_DYNAMIC(CPSProcessOptions, CPropertySheet)

It seems that i need to pass in the parent window somehow because rectWnd is empty.
I commented the OnInitDialog line as it was giving me assertion at that also.
I tried to put the code in the domodal function of the derived class and the constructor.
I didn't get any errors but the same assertions.
Do i need to derive another class and then do this in there?
Can you pl. let me know.
thanks
Fawaz

Top White Papers and Webcasts

The software-defined data center (SDDC) and new trends in cloud and virtualization bring increased agility, automation, and intelligent services and management to all areas of the data center. Businesses can now more easily manage the entire lifecycle of their applications and services via the SDDC. This Aberdeen analyst report examines how a strong foundation in both the cloud and internal data centers is empowering organizations to fully leverage their IT infrastructure and is also preparing them to be able …

This case study will highlight the opportunity for mobile and cloud technologies in the Public Sector—specifically for state, local and federal government agencies -where secure mobile application access can offer key productivity gains