Must CPropertyPage::SetModified be called manually on each change?

The documentation states that the implementor of a property page needs
to call SetModified each time a change occurs on a page to track the
dirty status and enable the Apply button. On a page with many edit
fields, that would mean putting a handler in for each and every
control.

Is this really necessary? Is there no way the framework can track such
a simple thing as whether a page is dirty or not?

0
2/8/2006 2:23:51 PM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
873 Views

Similar Articles

[PageSpeed] 43

On 8 Feb 2006 06:23:51 -0800, "Erik J�levik" <erikjalevik@gmail.com> wrote:

>The documentation states that the implementor of a property page needs
>to call SetModified each time a change occurs on a page to track the
>dirty status and enable the Apply button. On a page with many edit
>fields, that would mean putting a handler in for each and every
>control.
>
>Is this really necessary? Is there no way the framework can track such
>a simple thing as whether a page is dirty or not?

No, it's up to you. For things like auto radio buttons, at least, I've
found ON_COMMAND_RANGE to be useful. I suppose for edit controls, an
alternative would be to override OnCommand in the property page and look
for EN_CHANGE notifications. (You would need to verify the message is
coming from an edit control; you could compare GetClassName() to "EDIT" for
that, which would accommodate controls you haven't bound to MFC objects.)

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
2/8/2006 6:00:59 PM
Doug Harrison [MVP] wrote:

> No, it's up to you. For things like auto radio buttons, at least, I've
> found ON_COMMAND_RANGE to be useful. I suppose for edit controls, an
> alternative would be to override OnCommand in the property page and look
> for EN_CHANGE notifications. (You would need to verify the message is
> coming from an edit control; you could compare GetClassName() to "EDIT" for
> that, which would accommodate controls you haven't bound to MFC objects.)

I just realised I could map the EN_CHANGE for all the controls to the
same OnDirty function so it isn't too bad after all.

Thanks,
Erik

0
2/8/2006 7:16:28 PM
On 8 Feb 2006 11:16:28 -0800, "Erik J�levik" <erikjalevik@gmail.com> wrote:

>I just realised I could map the EN_CHANGE for all the controls to the
>same OnDirty function so it isn't too bad after all.

That'll work, too, and I do it a lot. (I guess I was fixated on suggesting
ways to avoid adding message map entries for all the controls.)

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
2/8/2006 9:15:42 PM
"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:cknku1pjm65ju4ln62s04vli82b38quiur@4ax.com...
> On 8 Feb 2006 11:16:28 -0800, "Erik J�levik" <erikjalevik@gmail.com>
wrote:
>
> >I just realised I could map the EN_CHANGE for all the controls to the
> >same OnDirty function so it isn't too bad after all.
>
> That'll work, too, and I do it a lot. (I guess I was fixated on suggesting
> ways to avoid adding message map entries for all the controls.)

And note that it only seems to work properly for some, not all, controls.

Unless anyone knows any different, I've found no way to get a notification
when a single field of an IP address control changes (you get the
notification when you move the cursor to another field or another control,
but if the user just edits, say, 192.77.66.55 to 192.77.66.54 I've not found
any way of getting the Apply button to light up, which is confusing if
that's the only change the user wanted to make on the dialog and she now
expects to be able to Apply it).

--
Tim Ward
Brett Ward Limited - www.brettward.co.uk


0
tw2 (223)
2/9/2006 3:28:11 PM
There are a couple simpler ways to handle this.  They aren't foolproof, but they're pretty
good and I haven't seen them fail (yet).

What I do is on the OnSetActive command call a function call "ChecksumValues" which I
write, which reads all the values out of the child windows and forms a checksum.  In the
extreme case, I just enumerate every child window, do a GetWindowText, and use the string.
If you have listboxes whose contents change and are part of the "changed state", or
comboboxes whose listbox component change, you have to be smarter about the way you get
the text, but the idea is that you end up with an "unforgeable" value which represents a
hash of the contents.  For extreme reliability, you can use something like SHA-1, but my
typical checksum algorithm is in an essay on my MVP Tips site.  It is simple and does the
job (for example, you can't just add up the character string values, because if you change
"cat" to "cta" or "act" or some other permutation, a simple sum won't detect such a
change, so you need an algorithm where transposition produces a different checksum).  The
function ChecksumValues returns a DWORD checksum, which I store as the current checksum.

On the OnKillActive, I run the function again, and compare the value it returns to the
value I saved from the OnSetActive.  If they are the same, there is no modification,
otherwise something has changed, and I call SetModified(TRUE).  

..... CMyPropertyPage::OnSetActive(...)
   {
     chksum = ChecksumValues();
     ...
   }

.... CMyPropertyPage::OnKillActive(...)
   {
     DWORD newchksum = ChecksumValues();
     if(newchksum != chksum)
          SetModified(TRUE);
     ...
   }

Note: do not do SetModified(newchksum == chksum) because that might clear the modified
flag which had been set on a previous visit to the page.

I've used this technique on a lot of property page applications, and what I often do is
have an icon displayed in the tab that is based on the GetModified() value, so the tabs
with changed parameters are marked with a checkmark.  Then the Apply causes all the
changes to be applied, and the checksums are recomputed and saved, and all the checkmarks
disappear.  

For an example of a set of property pages that use this, see the screen snapshot on page
16 of the manual found at

http://www.extorr.com/Extorr_RGA_UserManual041122.pdf

				joe

On 8 Feb 2006 06:23:51 -0800, "Erik J�levik" <erikjalevik@gmail.com> wrote:

>The documentation states that the implementor of a property page needs
>to call SetModified each time a change occurs on a page to track the
>dirty status and enable the Apply button. On a page with many edit
>fields, that would mean putting a handler in for each and every
>control.
>
>Is this really necessary? Is there no way the framework can track such
>a simple thing as whether a page is dirty or not?
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
2/13/2006 12:23:42 AM
Note that if you use this technique, and change 'cat' to 'act' and back to 'cat', you'll
see a change, even though one didn't exist.  My approach of using the checksum will
actually record real changes.

Another variant of this is to set the initial checksum to 0, which is an impossible value
most of the time (you have one change in 2**32 that you'll hit this by accident) and only
compute the checksum after the controls are loaded and the checksum is 0.  After that, the
checksum is recomputed only on the Apply operation, but checked either in OnKillActive, or
in some cases, in an OnTimer handler (or both), so it is rarely out-of-date.
					joe

On Thu, 9 Feb 2006 15:28:11 -0000, "Tim Ward" <tw2@ipaccess.com> wrote:

>"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
>news:cknku1pjm65ju4ln62s04vli82b38quiur@4ax.com...
>> On 8 Feb 2006 11:16:28 -0800, "Erik J�levik" <erikjalevik@gmail.com>
>wrote:
>>
>> >I just realised I could map the EN_CHANGE for all the controls to the
>> >same OnDirty function so it isn't too bad after all.
>>
>> That'll work, too, and I do it a lot. (I guess I was fixated on suggesting
>> ways to avoid adding message map entries for all the controls.)
>
>And note that it only seems to work properly for some, not all, controls.
>
>Unless anyone knows any different, I've found no way to get a notification
>when a single field of an IP address control changes (you get the
>notification when you move the cursor to another field or another control,
>but if the user just edits, say, 192.77.66.55 to 192.77.66.54 I've not found
>any way of getting the Apply button to light up, which is confusing if
>that's the only change the user wanted to make on the dialog and she now
>expects to be able to Apply it).
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
2/13/2006 12:27:13 AM
Reply:

Similar Artilces:

How to change the string value in the registry?
How to change the "string value" in the registry from the code? As there is a functionality in my application that the user can change the "string value" with some GUI. But I m not able to change it as there is a function RegReplaceKey but its only to take the backup of old file and to replace it with new one and even i dont know how to use this functin to suit my case. RegSetValue/Ex() should do it I think. -Seetharam Look at the Registry APIs. Also, take a look at my Registry class on my MVP Tips site. joe On Sun, 26 Aug 2007 23:59:33 -0700, HItz <hitesh_im...

Comments on Manual Calculation on certain sheets.
I have a sheet in a workbook with array functions that slows down performance with calculation on automatic (which I need for the other sheets). Would it not have been useful to be able to set a single sheet to Manual and update when needed in the same way Pivot Tables work? One way to work around this is to save the Array Formula sheet in another workbook. I have browsed some of the posts on Excel's way of handling Automatic/Manual recalculation and it seems as if there is room for improvement or are there important reasons that I am not aware of? Any comments. Laurence Lombard Hi ...

Name change due to marriage...
I have a user who recently got married and would like to have her new married name for her emails, but also wants external users to be able to send emails to her old address until she has adequate time to inform everyone. Her new email would be something like lastname-newname, firstname instead of lastname, firstname. Should I create a new account with her new name and forward all her emails from the old account to the new one and can I copy her current pst into the new one? THanks for everyone's help. No. Just highlight her account in ADUC, and choose re-name. Make the neede...

Set up a script for a live performance with a cue call sheet
How do I set up a single one-sided sheet to follow a live performance script and be able to write stand-by notes and cues in a column beside the script with a timecode format ...

Unable to Open received PO (change to "change order")
Great Plains will not allow me to change this Purchase Order from Received to Change Order: Here is the message I get: However, if I try to enter a quantity cancelled, I get: How can I re-open this Purchase Order so I can change the price??? Thank you. Unfortunately, the pasted messages did not come through. Once a line item is received, you can change its cost only during invoice matching. The process would be to return the item; add a new row with the correct cost; and receive and invoice the new item. Not an elegant solution, for sure. -- Charles Allen, MVP &quo...

Tracked changes function misbehaving
I have a simple workbook (2002) in which the Track Changes feature is enabled. End users have reported periodic problems with the contents of cells "mysteriously" changing. In process of investigating these, have found that when tracked changes are highlighted, the comments that describe changes are not always associated with the correct cell. Example, comment on cell B114 states "Changed cell B114 from '<blank>' to '12345'". In fact, contents of cell B114 is "67890" and contents of cell B104 is actually "12345". Has anyone...

Changing font size in data validation drop-down lists
In Excel 2003, I created the value list on a separate worksheet and labled the range so I could use it in the data validation wizard on a different worksheet. The list is working fine; however, the font size in the drop-down list is too small to comfortably read. So far, I have tried: Making the font in the list larger. Formatting larger font size in the active cell with the drop-down button And, creating the list on the same worksheet. All three remedies have not increased the size of the font in the drop-down list. Suggestions are welcome. Great Optimism, Dutch Driver There is n...

Could Microsoft create a MSPOS user manual?
My customers are asking for one. Guess we were spoiled by RMS Store Operations having one available after Microsoft updated the SMS Commerce manuals. Makes me expect one for MSPOS even though most software no longer has printed manuals. -- Jeff Faul Merchants Solutions ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and t...

ON_UPDATE_COMMAND_UI handler does not get called
Hello, For some reason, my ON_UPDATE_COMMAND_UI handler does not get called. I am using the usual syntax: in the .cpp file: ON_UPDATE_COMMAND_UI(ID_EDIT_CLEAR, OnUpdateEditClear) void CDrawView::OnUpdateEditClear(CCmdUI* pCmdUI) { pCmdUI->Enable(!m_selection.IsEmpty()); } in the .h file: afx_msg void OnUpdateEditClear(CCmdUI* pCmdUI); The other handlers (for example for ID_EDIT_CUT) work normally Thanks for advice Vaclav "Vaclav" <vjedlicka@atlas.cz> wrote in message news:u5Wc3LKJIHA.2480@TK2MSFTNGP05.phx.gbl... > Hello, > > For some reason, my ON_UPDATE_...

Excel date changes
I have created a spreadsheet using excel which requires the use dates on a monthly basis (similar to a calendar). The problem I have is that every month I have to go in and change the dates on the spreadsheet to reflect those of the current month before printing. Is there a way I can make it so that excel does that for me every month. Thanks, I'd really appreciate the input. Please elaborate on what the spreadsheet looks like. "phonescoop@hotmail.com" wrote: > I have created a spreadsheet using excel which requires the use dates > on a monthly basis (similar to a cal...

Change order of A/R Statements
How can I change the order in which customer statements print out of RMS? I would like to print statements sorted by company name. Currently, the statements print in some random order....I think based on CustomerID. Paul, I agree. I just had a customer tell me the same thing. They need the statements in Alphabetical order. The current order appears to be straight out of the customer table in the order they were entered. It has been posted as a suggestion - vote for it and push it higher on the "list". Claude "Paul Arenson" wrote: > How can I chang...

Changing URL from Ticker Symbol
Many of partners in Japan want to changing URL from Ticker Symbol in order to jump to a web site in Japan instead of http://moneycentral.msn.com/ . ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowse...

can i see the date the last time a cell was changed?
I am trying to figure out a formulla to make the date appear in one cell everytime anouther cell's data is chaged. Use a worksheet_change event to copy the cell address and put in a date stamp. -- Don Guillett SalesAid Software dguillett1@austin.rr.com "JohnNuTek" <JohnNuTek@discussions.microsoft.com> wrote in message news:5085A544-CBF4-4B81-A244-B03DE9A0E9E6@microsoft.com... >I am trying to figure out a formulla to make the date appear in one cell > everytime anouther cell's data is chaged. There really isn't a worksheet formula to do that. Typicall...

Unhandled database exception: A get/change operation on table 'Bat
During Edit Checks, we get the following message: Unhandled database exception: A get/change operation on table 'Batch_Headers' could not find a record. Then we get this message: This transaction was recovered during normal processing. You may continue processing this transaction. Any suggestions? You might want to run Check Links on payables. Before doing this, make sure you have a backup of your dynamics and company databases. Brenner -- www.KlenzmanConsulting.com "GPI" wrote: > During Edit Checks, we get the following message: > > Unhandled databas...

trouble changing data type
I am running MS Access 2007 on Windows XP Professional 2002 (SP2). I need to change the data type of a single field in a table containing just over 1.4M records in order to link it with another table and run a Make-Table Query, but Access is telling me I do not have enough memory to change the data type. I have 1GB of RAM and a Pentium 4, 2.79 GHz processor. Am I out of luck based on the equiptment I am working with, or is there a way around this? Much appreciated. -- Kevin Philadelphia, PA First backup your database. Next Compact and Repair. Third add the new field datatype. C...

Changing size and placement of maximized dialog
Hi, I want to have maximized window not on all screen. how to change maximized size and placement of dialog ? I red doc for SetWindowPlacement(&wPlac) and I have tried in OnInitDialog(): wPLac.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(&wPlac); wPlac.ptMaxPosition.x = 200; wPlac.ptMaxPosition.y = 200; SetWindowPlacement(&wPlac) But after dialog is maximized it is on all screen. What is wrong ? Peter "Peter": > I want to have maximized window not on all screen. > how to change maximized size and placement of dialog ? > I red doc for SetWindowPlaceme...

SFO error message "write protected change are not synchronized" 07-28-05
Hi! When I am changing (closing) an kalender activity from my CRM SFO klient i recieve an message that "The item is write protected in Microsoft CRM. Changes are not synchronized to the Microsoft CRM system" (translatet error message). Do you have any ide what i wrong? ...

Change the format of my footer {date} option?
I would like to show the date in my footer as January 25, 2005 instead of the default 01/25/05 Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet .PageSetup.LeftFooter = Format(Date, "mmmm dd, yyyy") End With End Sub put this in the ThisWorkbook code module. -- HTH RP (remove nothere from the email address if mailing direct) "Tori" <Tori@discussions.microsoft.com> wrote in message news:817363F1-32AB-4528-B1D6-304F8E712EA8@microsoft.com... > I would like to show the date in my footer as January 25, 2005 instead of the &g...

Manual Worklflow
hi I have a manual workflow and am keen to know how to go about creating a scheduled job to automatically execute the workflow every morning/every night .. any advice would be helpful. regards Ridhima Hi Ridhima, the first step is to modify your manual workflow to wait 24 hours and execute itself: Manual rule ... your logic Wait for 1 day(s) Exec: Manual rule You may want to add some checks to ensure that workflow is stopped when appropriate, e.g. when record becomes inactive, e.g. Manual rule ... your logic Wait for 1 day(s) if <Your entity>....

Opening an old Word document, date changed to current date
When I open old Word documents, the date gets automatically changed to the current date and I can't view the date that the document actually had. I am using MS Office 2007, but the old document was created in Word 2003. I can see the date that the file was last modified in the details of the file, but I cant guarantee that the date of the document is the same as the date last modified for the file. Press Alt+F9 to toggle the field code display and edit the DATE field code to read CREATEDATE. Then Alt+F9 to toggle back and F9 to update. The date displayed will be the date th...

Change series in a chart
Hi guys, My first post. I have data for residents of the care home that I work at. One example is their monthly weights. I presently have the data in the following form: jan feb mar apr may Resident 1 108 109 107 105 106 Resident 2 220 225 219 226 222 I would like to have a control box or something on the line chart of a resident's weights so that I can choose which resident's monthly weights to display. The x-axis is the month and the y-axis the weight. I can't seem to figure out how to get a macro to do this. Thanks a bunch Stuart -- trispirit3...

It auto changes font size on e-mail entries, WHY?
We have a document set up in Excel (version 2000) and when I type in a e-mail address in the contact info area of the document, it automatically decreases the font to a 6 instead of a 16 like the rest of the page. I have tried formatting this cell, and simply saving it as that size on the blank document, but nothing is working. Please help. You can change the format for the Hyperlink style. Format|Style|Style Name: Hyperlink and click modify to change it to what you want. Styles live in the workbook. So changing the hyperlink style in this workbook won't affect any other workboo...

Unable to view changes to spreadsheet
Mary uses Office 2000 on a Windows 2000 pro computer. She claims she updated an Excel file on the shared drive and no one can see the changes. I checked the security of the Excel file - it has Everyone: read, write, execute. It's on the shared drive so everyone has access to it. She made the changes using someone else's Windows 2000 pro machine (not her own). I checked the time and date of the Excel file , it seems she saved the changes . What would make the changes not appear in the Excel file? Is there some security setting within Excel I don't know about.? ...

Changing Part of a Formula En Mass
Good morning, I need to edit part of a formula in many cells - but they don't all follow each other - so I cannot use the fill option. Is there anyway that I can edit text within the spreadsheet? Almost like a flat file where I do a find and replace? Thanks Yes, you can do Find & Replace (CTRL-H). Post some examples of your formulae if you need further help. Pete On May 26, 9:31=A0am, "Jim" <zj...@live.co.uk> wrote: > Good morning, > > I need to edit part of a formula in many cells - but they don't all follo= w > each other ...

Allow us to change the default view in History to all dates
Various customers of ours find a default filter of 30 days of History inconvenient. We need the ability to change the default to All Dates, 1 year, 2 years, etc. A user preference should work well. -- Please forgive me; I was raised by wolves. :) ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree&...