Solved

modeless propertysheet with OK and Cancel?

Posted on 2000-04-06
4
447 Views
Last Modified: 2013-11-20
How do I create a modeless property sheet with OK and Cancel buttons?

I've tried it the following way but my property sheet doesn't has OK and Cancel buttons (probably some style flag to set I suppose?)

class CMainFrame {
CMyPropertySheet m_ps;
...
}

CMainFrame::CMainFrame()
:m_ps(_T("Properties"))
{
}

CMyPropertySheet::CMyPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
  AddPage(&m_myPage);
}
void CMainFrame::OnShowProps()
{
  m_ps.Create(this);
}
0
Comment
Question by:searching
4 Comments
 

Accepted Solution

by:
cbursk earned 75 total points
ID: 2691001
I'm assuming that you are using Microsoft Visual Studio.

According to the Microsoft help files:
"Modeless property sheets displayed with a call to Create do not have OK, Cancel, Apply Now, and Help buttons as modal property sheets do. Desired buttons must be created by the user."

I'm assuming that the page you added is a CPropertyPage derived class that is attached to its own dialog resource.  You will need to create your own buttons ( probably using the resource editor in Visual Studio ) and then map each button ( you can use the class wizard ) to your property page's class code to do whatever you want to based on whether the user pressed the Ok or Cancel button.
0
 
LVL 3

Expert Comment

by:mnewton022700
ID: 2691743
I have created a modeless property sheet, complete with buttons, before. I did it by creating the buttons in the OnCreate method of my property sheet and then moving them to where I wanted them to be in the OnInitialUpdate method of the property sheet.

I created them in OnCreate so that the tabbing order was correct.

In the handler methods for the buttons you can simulate the modal buttons by calling PressButton. For example in the OnOK handler you can call "PressButton(PSBTN_OK);"

Another hint is that you should set the font of each button to GetTabControl()->GetFont(). Otherwise they will look ugly.

Hope this helps.

0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2692157
Instead of a modeless propertysheet with buttons, try creating a modal propertysheet in its own UI thread.
0
 

Author Comment

by:searching
ID: 2699451
mnewton also thank you for the tips
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now