PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Form Programming
Prevent "Save changes" message box when programatically customising form
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Form Programming
Prevent "Save changes" message box when programatically customising form
![]() |
Prevent "Save changes" message box when programatically customising form |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I'm customising the a form programatically (currently just playing around
with colours and field locations, and adding a button). When I close a message which has these customisations applied, Outlook prompts me to save changes to the item. Is it possible to suppress this message cleanly (maybe by somehow discarding the changes)? Or do I have to hook the message box? Thanks for any help Matt Fletcher |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Sounds like you're doing more than just playing with controls. You won't get
that message unless a property has changed. You might want to add code to the PropertyChange and CustomPropertyChange events to see what's going on. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Matt Fletcher" <mng001@securitypost.net> wrote in message news:c683m3$7mg$1@newsg3.svr.pol.co.uk... > I'm customising the a form programatically (currently just playing around > with colours and field locations, and adding a button). When I close a > message which has these customisations applied, Outlook prompts me to save > changes to the item. > > Is it possible to suppress this message cleanly (maybe by somehow discarding > the changes)? Or do I have to hook the message box? > > Thanks for any help > Matt Fletcher > > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Sue,
thanks for the reply. I've stripped down my code to find the minimum that will cause the Save changes message box to display - all I need to do is to add the "Message" page to the ModifiedFormPages collection (i.e. I have removed all the useful code that actually customises the form, and just left the basis for applying the customisation). I've tried to remove the added page from the ModifiedFormPages collection when the item is closed, but this throws an exception. A fix for this would be nice as even though I can hook the message box, I can't suppress the beep. Matt Fletcher "Sue Mosher [MVP-Outlook]" <suemvp@outlookcode.com> wrote in message news:Obf7HsFKEHA.2556@TK2MSFTNGP11.phx.gbl... > Sounds like you're doing more than just playing with controls. You won't get > that message unless a property has changed. You might want to add code to > the PropertyChange and CustomPropertyChange events to see what's going on. > > -- > Sue Mosher, Outlook MVP > Author of > Microsoft Outlook Programming - Jumpstart for > Administrators, Power Users, and Developers > http://www.outlookcode.com/jumpstart.aspx > > > "Matt Fletcher" <mng001@securitypost.net> wrote in message > news:c683m3$7mg$1@newsg3.svr.pol.co.uk... > > I'm customising the a form programatically (currently just playing around > > with colours and field locations, and adding a button). When I close a > > message which has these customisations applied, Outlook prompts me to save > > changes to the item. > > > > Is it possible to suppress this message cleanly (maybe by somehow > discarding > > the changes)? Or do I have to hook the message box? > > > > Thanks for any help > > Matt Fletcher > > > > > > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Code snippet?
-- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Matt Fletcher" <mng001@securitypost.net> wrote in message news:c68bqc$dok$1@newsg3.svr.pol.co.uk... > Sue, > > thanks for the reply. I've stripped down my code to find the minimum that > will cause the Save changes message box to display - all I need to do is to > add the "Message" page to the ModifiedFormPages collection (i.e. I have > removed all the useful code that actually customises the form, and just left > the basis for applying the customisation). I've tried to remove the added > page from the ModifiedFormPages collection when the item is closed, but this > throws an exception. > > A fix for this would be nice as even though I can hook the message box, I > can't suppress the beep. > > Matt Fletcher > > "Sue Mosher [MVP-Outlook]" <suemvp@outlookcode.com> wrote in message > news:Obf7HsFKEHA.2556@TK2MSFTNGP11.phx.gbl... > > Sounds like you're doing more than just playing with controls. You won't > get > > that message unless a property has changed. You might want to add code to > > the PropertyChange and CustomPropertyChange events to see what's going on. > > > > > > "Matt Fletcher" <mng001@securitypost.net> wrote in message > > news:c683m3$7mg$1@newsg3.svr.pol.co.uk... > > > I'm customising the a form programatically (currently just playing > around > > > with colours and field locations, and adding a button). When I close a > > > message which has these customisations applied, Outlook prompts me to > save > > > changes to the item. > > > > > > Is it possible to suppress this message cleanly (maybe by somehow > > discarding > > > the changes)? Or do I have to hook the message box? > > > > > > Thanks for any help > > > Matt Fletcher > > > > > > > > > > > > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Sue,
here's the minimum (C++) code that causes the Save changes message box to appear. Note that this code is a handler for MailItemEvents::Open. STDMETHODIMP_(void) CMailHandler::OnOpen(VARIANT_BOOL* Cancel) { .. .. try { PagesPtr spPages = m_spInspector->ModifiedFormPages; if (spPages) { IDispatchPtr spPageDisp = spPages->Add("Message"); // convert spPageDisp to MSUserForms::_UserFormPtr and amend controls - commented out at present } } catch (_com_error & e) { SPTRACE("CMailHandler::OnOpen - caught COM error: %s\n", e.ErrorMessage()); } .. .. } I've commented out all my code which uses spPageDisp, and the problem still occurs Matt Fletcher "Sue Mosher [MVP-Outlook]" <suemvp@outlookcode.com> wrote in message news:#HgYFWGKEHA.3728@TK2MSFTNGP12.phx.gbl... > Code snippet? > > -- > Sue Mosher, Outlook MVP > Author of > Microsoft Outlook Programming - Jumpstart for > Administrators, Power Users, and Developers > http://www.outlookcode.com/jumpstart.aspx > > > "Matt Fletcher" <mng001@securitypost.net> wrote in message > news:c68bqc$dok$1@newsg3.svr.pol.co.uk... > > Sue, > > > > thanks for the reply. I've stripped down my code to find the minimum that > > will cause the Save changes message box to display - all I need to do is > to > > add the "Message" page to the ModifiedFormPages collection (i.e. I have > > removed all the useful code that actually customises the form, and just > left > > the basis for applying the customisation). I've tried to remove the added > > page from the ModifiedFormPages collection when the item is closed, but > this > > throws an exception. > > > > A fix for this would be nice as even though I can hook the message box, I > > can't suppress the beep. > > > > Matt Fletcher > > > > "Sue Mosher [MVP-Outlook]" <suemvp@outlookcode.com> wrote in message > > news:Obf7HsFKEHA.2556@TK2MSFTNGP11.phx.gbl... > > > Sounds like you're doing more than just playing with controls. You won't > > get > > > that message unless a property has changed. You might want to add code > to > > > the PropertyChange and CustomPropertyChange events to see what's going > on. > > > > > > > > > "Matt Fletcher" <mng001@securitypost.net> wrote in message > > > news:c683m3$7mg$1@newsg3.svr.pol.co.uk... > > > > I'm customising the a form programatically (currently just playing > > around > > > > with colours and field locations, and adding a button). When I close a > > > > message which has these customisations applied, Outlook prompts me to > > save > > > > changes to the item. > > > > > > > > Is it possible to suppress this message cleanly (maybe by somehow > > > discarding > > > > the changes)? Or do I have to hook the message box? > > > > > > > > Thanks for any help > > > > Matt Fletcher > > > > > > > > > > > > > > > > > > > > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Ah, I see now (despite my minimal ability to read C++ code). By customizing
the form programmatically in this fashion, you are actually embedding the form in the item and thus causing the item itself to change. You cannot, therefore, avoid the message box. I do hope you're publishing the form after you customize it? Otherwise, you'll have a one-off. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Matt Fletcher" <mng001@securitypost.net> wrote in message news:c68esa$g0a$1@news5.svr.pol.co.uk... > Sue, > > here's the minimum (C++) code that causes the Save changes message box to > appear. Note that this code is a handler for > MailItemEvents::Open. > > STDMETHODIMP_(void) CMailHandler::OnOpen(VARIANT_BOOL* Cancel) > { > . > . > try > { > PagesPtr spPages = m_spInspector->ModifiedFormPages; > > if (spPages) > { > IDispatchPtr spPageDisp = spPages->Add("Message"); > > // convert spPageDisp to MSUserForms::_UserFormPtr and amend > controls - commented out at present > } > } > catch (_com_error & e) > { > SPTRACE("CMailHandler::OnOpen - caught COM error: %s\n", > e.ErrorMessage()); > } > . > . > } > > I've commented out all my code which uses spPageDisp, and the problem still > occurs > > Matt Fletcher > > > > "Matt Fletcher" <mng001@securitypost.net> wrote in message > > news:c68bqc$dok$1@newsg3.svr.pol.co.uk... > > > Sue, > > > > > > thanks for the reply. I've stripped down my code to find the minimum > that > > > will cause the Save changes message box to display - all I need to do is > > to > > > add the "Message" page to the ModifiedFormPages collection (i.e. I have > > > removed all the useful code that actually customises the form, and just > > left > > > the basis for applying the customisation). I've tried to remove the > added > > > page from the ModifiedFormPages collection when the item is closed, but > > this > > > throws an exception. > > > > > > A fix for this would be nice as even though I can hook the message box, > I > > > can't suppress the beep. > > > > > > Matt Fletcher > > > > > > "Sue Mosher [MVP-Outlook]" <suemvp@outlookcode.com> wrote in message > > > news:Obf7HsFKEHA.2556@TK2MSFTNGP11.phx.gbl... > > > > Sounds like you're doing more than just playing with controls. You > won't > > > get > > > > that message unless a property has changed. You might want to add code > > to > > > > the PropertyChange and CustomPropertyChange events to see what's going > > on. > > > > > > > > > > > > "Matt Fletcher" <mng001@securitypost.net> wrote in message > > > > news:c683m3$7mg$1@newsg3.svr.pol.co.uk... > > > > > I'm customising the a form programatically (currently just playing > > > around > > > > > with colours and field locations, and adding a button). When I close > a > > > > > message which has these customisations applied, Outlook prompts me > to > > > save > > > > > changes to the item. > > > > > > > > > > Is it possible to suppress this message cleanly (maybe by somehow > > > > discarding > > > > > the changes)? Or do I have to hook the message box? |
|
|
|
#7 |
|
Guest
Posts: n/a
|
Sue,
Thanks for your assistance. As the customisation will only be applied to received mails, I won't be publishing the form - the addin will amend the form each time it is opened. So if I avoid saving the form, I only create a temporary one-off form for the life of the Inspector. (The reason I've adopted this approach is partly to avoid one-off forms when forwarding SMIME mails viewed in a custom form). I found mention of this technique in KB238755 ("OL2000: How to Programmatically Create a Form") - I'm surprised that it hasn't been developed further, as it makes a lot of sense from an addin developer's point of view. I'll just need to get my hooking code to work, and work out how to suppress the beep (if it's possible). Matt Fletcher "Sue Mosher [MVP-Outlook]" <suemvp@outlookcode.com> wrote in message news:eG5pRpGKEHA.952@TK2MSFTNGP12.phx.gbl... > Ah, I see now (despite my minimal ability to read C++ code). By customizing > the form programmatically in this fashion, you are actually embedding the > form in the item and thus causing the item itself to change. You cannot, > therefore, avoid the message box. > > I do hope you're publishing the form after you customize it? Otherwise, > you'll have a one-off. > > -- > Sue Mosher, Outlook MVP > Author of > Microsoft Outlook Programming - Jumpstart for > Administrators, Power Users, and Developers > http://www.outlookcode.com/jumpstart.aspx > > > "Matt Fletcher" <mng001@securitypost.net> wrote in message > news:c68esa$g0a$1@news5.svr.pol.co.uk... > > Sue, > > > > here's the minimum (C++) code that causes the Save changes message box to > > appear. Note that this code is a handler for > > MailItemEvents::Open. > > > > STDMETHODIMP_(void) CMailHandler::OnOpen(VARIANT_BOOL* Cancel) > > { > > . > > . > > try > > { > > PagesPtr spPages = m_spInspector->ModifiedFormPages; > > > > if (spPages) > > { > > IDispatchPtr spPageDisp = spPages->Add("Message"); > > > > // convert spPageDisp to MSUserForms::_UserFormPtr and > amend > > controls - commented out at present > > } > > } > > catch (_com_error & e) > > { > > SPTRACE("CMailHandler::OnOpen - caught COM error: %s\n", > > e.ErrorMessage()); > > } > > . > > . > > } > > > > I've commented out all my code which uses spPageDisp, and the problem > still > > occurs > > > > Matt Fletcher > > > > > > > "Matt Fletcher" <mng001@securitypost.net> wrote in message > > > news:c68bqc$dok$1@newsg3.svr.pol.co.uk... > > > > Sue, > > > > > > > > thanks for the reply. I've stripped down my code to find the minimum > > that > > > > will cause the Save changes message box to display - all I need to do > is > > > to > > > > add the "Message" page to the ModifiedFormPages collection (i.e. I > have > > > > removed all the useful code that actually customises the form, and > just > > > left > > > > the basis for applying the customisation). I've tried to remove the > > added > > > > page from the ModifiedFormPages collection when the item is closed, > but > > > this > > > > throws an exception. > > > > > > > > A fix for this would be nice as even though I can hook the message > box, > > I > > > > can't suppress the beep. > > > > > > > > Matt Fletcher > > > > > > > > "Sue Mosher [MVP-Outlook]" <suemvp@outlookcode.com> wrote in message > > > > news:Obf7HsFKEHA.2556@TK2MSFTNGP11.phx.gbl... > > > > > Sounds like you're doing more than just playing with controls. You > > won't > > > > get > > > > > that message unless a property has changed. You might want to add > code > > > to > > > > > the PropertyChange and CustomPropertyChange events to see what's > going > > > on. > > > > > > > > > > > > > > > "Matt Fletcher" <mng001@securitypost.net> wrote in message > > > > > news:c683m3$7mg$1@newsg3.svr.pol.co.uk... > > > > > > I'm customising the a form programatically (currently just playing > > > > around > > > > > > with colours and field locations, and adding a button). When I > close > > a > > > > > > message which has these customisations applied, Outlook prompts me > > to > > > > save > > > > > > changes to the item. > > > > > > > > > > > > Is it possible to suppress this message cleanly (maybe by somehow > > > > > discarding > > > > > > the changes)? Or do I have to hook the message box? > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

