C# Make an event on exit - InfoPath Dev
in

InfoPath Dev

C# Make an event on exit

Last post 01-27-2011 06:15 AM by HamishAhern. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-19-2006 12:49 AM

    C# Make an event on exit

    Hi,

    In one of my form I want to launch an event when this form is close. The save event is currently desactivate* but I want to make one more call to one of my secondary datasource!

    Is there a way for catch when a user hit the red cross?

    *I know that I can make with Onsave event but there are always this stupid question "Would you like to save?" and if the user click no I cant do anything!

    Do you know a work around for make this possible?

    Thanks

    Thierry
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 05-19-2006 12:46 PM In reply to

    Re: C# Make an event on exit

    I don't know of a way to do it, but someone with more Windows development background might know.
  • 05-22-2006 02:15 AM In reply to

    Re: C# Make an event on exit

    Thanks for the reply I will ask somebody else and if I found a way I publish it here!

    Thierry
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 01-27-2011 06:15 AM In reply to

    Re: C# Make an event on exit

    did anybody find a solution to his yet?

    did anybody find a solution to his yet?   I made a solution:

    1) Use windows API to disable the form close button...    http://social.msdn.microsoft.com/Forums/en/sharepointinfopath/thread/257f186f-3ab3-4ac4-9553-f71d100ad297
    2) Disable the toolbars using code from google..
    3) put a button on the form for the user to close the app
    4)  use Application.Exit() to quit InfoPath.

    public void btnExit_Clicked(object sender, ClickedEventArgs e){
    // your save code here.

    //re-enable toolbars before you exit
    HideAllToolbars(
    true);
    //Exit App
    Application.Quit();
    }

    void HideAllToolbars(bool flag)

    {


    CommandBars myCommandBars = this.Application.ActiveWindow.CommandBars as CommandBars;

    CommandBar myCommandBar = (this.Application.ActiveWindow.CommandBars as CommandBars).ActiveMenuBar;

    foreach (CommandBar item in myCommandBars)

    {

    //MessageBox.Show(item.Name.ToString() + " " + item.Type.ToString() + " " + item.Index.ToString());

    if (flag == true && (item.Type == MsoBarType.msoBarTypeMenuBar || item.Type == MsoBarType.msoBarTypeNormal))

    {

    item.Enabled =
    false;

    }

    }

    }

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.