Results 1 to 9 of 9

Thread: Is this a bug, or am i doing something wrong

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Is this a bug, or am i doing something wrong

    In a module I have a sub main which is the start of my app

    In this module I have declared an instance of my main form
    Public MainForm as new frmMain
    and in sub main I call it
    MainForm.ShowDialog

    I show it as dialog because if I just use Show, then it goes right through sub main and exits the application...

    now while i think that in itself is odd, i used showdialog so the app will run while the main form is open. This works fine, but when the user clicks the X button, I set e.cancel = true because its just supposed to minimize to the system tray... but for some reason, even if I set cancel to true, the app then resumes in submain and exits the program....

    any ideas?

  2. #2
    Hyperactive Member
    Join Date
    Dec 2002
    Location
    The Big D
    Posts
    310
    Here's my Sub Main. Note that I run the app not show the form.


    VB Code:
    1. Public Sub Main()
    2.  
    3.     Dim frm As New frmMain
    4.     Application.Run(frm)
    5.    
    6. End Sub

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    I was thinking the same thing but that still exits the app when using event.Cancel = true in the OnClosing Event
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    no it seems to work fine actually... setting cancel to true still works when using application.run

    thanks!

  5. #5
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Hmm. Wonder why it isnt working here.

    Blah
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  6. #6
    Hyperactive Member
    Join Date
    Dec 2002
    Location
    The Big D
    Posts
    310
    I just tried adding e.Cancel = True to the OnClosing event and it works for me as expected. It cancels the close event, the form stays open and the app continues to run just fine.

  7. #7
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Im an idiot. I forgot to add handles mybase.closing...

    D'uh
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  8. #8

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by Cander
    Im an idiot. I forgot to add handles mybase.closing...

    D'uh
    doesn't it do that for you????

  9. #9
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Not when you typed it out by hand. I do alot of thing manually because I am anal.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width