Results 1 to 6 of 6

Thread: Capture when user click the X on the form

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219

    Question Capture when user click the X on the form

    Is there a way to capture the event when a user click on the X button on the top right corner of a form? I want to do something with the event when a user click on the X on the form. However, I could not figure out how to capture that.

    Any help is appreciated!

    ljCharlie

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    like this ...
    VB Code:
    1. Protected Overrides Sub WndProc(ByRef m As Message)
    2.         If m.Msg = 161 Then
    3.             If m.WParam.ToInt32 = 20 Then
    4.                 MessageBox.Show("you just clicked the X button!")
    5.             End If
    6.         End If
    7.         MyBase.WndProc(m)
    8.     End Sub
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    Ok this is kinda off the topic question but, where do you guys find this stuff?

    Like:

    m.Msg = 161
    and
    m.WParam.ToInt32 = 20

    What is 161 and 20?

    Where is the defenition of these numbers?

    Just for future reference

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219

    Question

    Thanks a bunch, dynamic_sysop! It works, but yes, Hole-In-One, you're right.
    Where do you guys find this stuff?
    ljCharlie

  5. #5
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    trial and error , i tend to try stuff like clicking on the toolbox of a form , then outputing the windows messages ( m.msg ) to Console.WriteLine
    same with the wparams etc...
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 2003
    Posts
    219

    Thumbs up

    Thanks!

    ljCharlie

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