PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook Form Programming Prevent "Save changes" message box when programatically customising form

Reply

Prevent "Save changes" message box when programatically customising form

 
Thread Tools Rate Thread
Old 22-04-2004, 10:36 AM   #1
Matt Fletcher
Guest
 
Posts: n/a
Default Prevent "Save changes" message box when programatically customising form


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


  Reply With Quote
Old 22-04-2004, 12:22 PM   #2
Sue Mosher [MVP-Outlook]
Guest
 
Posts: n/a
Default Re: Prevent "Save changes" message box when programatically customising form

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
>
>



  Reply With Quote
Old 22-04-2004, 12:55 PM   #3
Matt Fletcher
Guest
 
Posts: n/a
Default Re: Prevent "Save changes" message box when programatically customising form

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
> >
> >

>
>



  Reply With Quote
Old 22-04-2004, 01:39 PM   #4
Sue Mosher [MVP-Outlook]
Guest
 
Posts: n/a
Default Re: Prevent "Save changes" message box when programatically customising form

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
> > >
> > >

> >
> >

>
>



  Reply With Quote
Old 22-04-2004, 01:47 PM   #5
Matt Fletcher
Guest
 
Posts: n/a
Default Re: Prevent "Save changes" message box when programatically customising form

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
> > > >
> > > >
> > >
> > >

> >
> >

>
>



  Reply With Quote
Old 22-04-2004, 02:13 PM   #6
Sue Mosher [MVP-Outlook]
Guest
 
Posts: n/a
Default Re: Prevent "Save changes" message box when programatically customising form

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?



  Reply With Quote
Old 22-04-2004, 02:34 PM   #7
Matt Fletcher
Guest
 
Posts: n/a
Default Re: Prevent "Save changes" message box when programatically customising form

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?

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off