Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Enable apply now button always

Posted on 1998-07-29
7
Medium Priority
?
353 Views
Last Modified: 2013-11-19
I have an app that uses a property sheet, I want the "Apply" button to always be enabled. It's possible to enable it on the fly, in an event handler for instance, by calling the function CPropertyPage::SetModified(BOOL flag). But when I tried to just call SetModified from the OnInitDialog() function of one my property pages, so that the whole time the property sheet was displayed the apply button would be enabled, it doesn't work.

I suspect that function only works once the dialog has been displayed, so I can't call from OnInitDialog(). Does anyone out there know a way to do what I'm trying to do?

thanks
0
Comment
Question by:nicholso
[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
  • 3
  • 3
7 Comments
 
LVL 1

Expert Comment

by:Andy_Keys
ID: 1319908
You could try doing it in onactivate! but I'm not 100% sure that onactivate work in non wizard mode.
0
 
LVL 6

Accepted Solution

by:
snoegler earned 400 total points
ID: 1319909
I do not know if it work in onactive, but i've had this problem myself a time ago.
I found a rather simple method after a while:
Just implement (using ClassWizard) the OnCmdMsg() handler in your <CPropertySheet>,
like this:

/* CLASS WIZARD GENERATED ---. */
BOOL CMyPropertySheet::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
      // TODO: Add your specialized code here and/or call the base class

/** Add the next two lines */
      if(nID==ID_APPLY_NOW)
            return TRUE;
      
      return CPropertySheet::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

Then the apply button will - once activated - never been disabled. To activate it initially you have
to call in each property pages OnInitDialog() handler SetModified(TRUE).
0
 

Author Comment

by:nicholso
ID: 1319910
I added the code you have, and put the line SetModified(true); in each property page's OnInitDialog() but when the property sheet first displays, the Apply button is still shaded.

Help?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Expert Comment

by:snoegler
ID: 1319911
Okay i am sorry - i mixed up things a little bit. Take a look at this:

1. Add OnApply() to your property page, and add the line SetModified(TRUE);
2. In the OnInitDialog() of your property page add the line SetModified(TRUE);
3. Add OnCmdMsg() to your property sheet (like you have done it already) and insert:
    if(nID==ID_APPLY_NOW) return TRUE;
4. Add to your BEGIN_MESSAGE_MAP/END_MESSAGE_MAP of your CPropertySheet
    ON_MESSAGE(PSM_CHANGED, OnPSMChanged)
5. Insert the following function def in your CPropertySheet.h:
    afx_msg LRESULT OnPSMChanged(WPARAM wP,LPARAM lP);
6. Add the following code to your CPropertySheet.cpp:

LRESULT OnPSMChanged(WPARAM wP,LPARAM lP)
{
GetDlgItem(ID_APPLY_NOW)->EnableWindow(TRUE);
return TRUE;
}

Now it should work, sorry for any inconvenience.
PS: Andy, i have tried this one with OnActivate() and i think in non-wizard mode it does not work
0
 

Author Comment

by:nicholso
ID: 1319912
Well, I can see the Apply button all the time now, but when I hit "Apply" it doesn't run any of the OnApply() handlers...

?
Anthony
0
 
LVL 6

Expert Comment

by:snoegler
ID: 1319913
<grin> sorry i do not know what was going on. I made another little mistake
Please remove the SetModified(TRUE) in your OnApply() handler, and replace it by the
following:

BOOL CMyPropPage::OnApply()
{
   // TODO: ...

  return CPropertyPage::OnApply(); // <--- CHANGE THIS TO return FALSE;
}
This works really. Sorry
0
 

Author Comment

by:nicholso
ID: 1319914
Thanks, it works now. There was one mistake, though--in the OnCmdMsg function, it needs to return FALSE if the message is from the Apply button, not TRUE.

Once I changed that it works great. Thanks!!
Anthony
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

670 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