Validating Changes in a Dialog

The cChangeValidate class is a useful tool for validating changes that a user may or may not have made to a dialog. For example, take for instance that a user pops up a dialog that has 3 buttons and an edit box. All 3 buttons are checked, and there is no text in the edit box. If the user does not uncheck ANY of the check boxes AND does not put any text into the edit box, they have in effect made no changes. Now when they press OK (or whichever button performs processing), if you were doing a whole bunch of processing from the root app (such as database calls, updates to activity logs, etc....) that aren't necessary because you have in effect not made any changes, why do it?

cChangeValidate is extremely easy to implement and use. It was written in a very basic form, and anyone should be able to incorporate it into their project with a minimum of difficulty. Note: cChangeValidate only stores the data for Combo Boxes, Edits, Buttons, and List Controls. If you wish to store data for say Static text or a specific class, just add another check in the cChangeValidate CALLBACK functions for your class and perform data storage and checking as necessary. Below is some sample code to actually run the class.

void Foo::Init()
{
 // cChangeValidateClass is a member variable of whichever class 
 // wants to use it. It must be global in scope and not local 
 // otherwise you obviously would not be able to store the data 
 // for later use
 cChangeValidateClass.CycleControls( GetSafeHwnd());
 
 return;
}

void Foo::OnOK()
{
 if( cChangeValidateClass.Compare())
 {
  //data has not been changed
  OnCancel(); 	//Or whichever process you wish to perform
  return;
 }

 //If data has been changed continue with processing
}

Downloads

Download source - 3 Kb


Comments

  • Comments on Validating Changes in a Dialog

    Posted by Legacy on 08/02/2001 12:00am

    Originally posted by: Alvaro Garcia

    Hello,
    I've tried to add this pretty nice files into my project just to check if a Dialog has been change, to skip unnecessary process.
    I found that once I 've included this two files to my Workspace it does not compile, the error were on ...\VC98\Include\NEW file and so on.

    Could you please tell if there is something more that I should know to use this functionability.

    Thanks in advance, Alvaro

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Corporate e-Learning technology has a long and diverse pedigree. As far back as the 1980s, companies were adopting computer-based training to supplement traditional classroom activities. More recently, rich web-based applications have added streaming audio and video, real-time collaboration and other new tools to the e-Learning mix. At the same time, the growing availability of informal learning tools--a category that includes everything from web searches to social media posts--are having a major impact on …

  • Live Event Date: August 14, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Data protection has long been considered "overhead" by many organizations in the past, many chalking it up to an insurance policy or an extended warranty you may never use. The realities of today makes data protection a must-have, as we live in a data-driven society -- the digital assets we create, share, and collaborate with others on must be managed and protected for many purposes. Check out this upcoming eSeminar and join Seagate Cloud …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds