locked
Wait till mouse click RRS feed

  • Question

  • I'm trying to get my button even to wait till i click the left mouse button. but can't seem to find a way to do that.
    Attributor 2.0
    Thursday, September 9, 2010 12:42 AM

Answers


  • Here is an example form which shows what I would use.  I'm not sure if it fits your needs.
     
    Public Class Form1
     Private lbl As Label
     Public Sub New()
      ' This call is required by the designer.
      InitializeComponent()
     
      ' Add any initialization after the InitializeComponent() call.
      lbl = New Label()
      lbl.Text = "Click To Start"
      lbl.Location = New Point(10, 10)
      Controls.Add(lbl)
     
      AddHandler Me.Click, AddressOf ClickToStart
     End Sub
     Sub ClickToStart()
      lbl.Text = "Click to finish"
      Dim myEventHandler As New EventHandler(AddressOf ClickToStart)
      RemoveHandler Me.Click, myEventHandler
      AddHandler Me.Click, AddressOf ClickToFinish
     End Sub
     Sub ClickToFinish()
      lbl.Text = "You are done!"
      Dim myEventHandler As New EventHandler(AddressOf ClickToFinish)
      RemoveHandler Me.Click, myEventHandler
     End Sub
    End Class

    --
    Mike
    • Marked as answer by Liliane Teng Wednesday, September 15, 2010 8:08 AM
    Friday, September 10, 2010 12:48 AM

All replies


  • Below is an example of a button click handler.  Can you provide more information on your question?  You don't "wait" for a click, but rather you handle the click when it occurs.
     
     Private Sub Button1_Click _
      (ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles Button1.Click
      MessageBox.Show("Click")
     End Sub

    --
    Mike
    • Proposed as answer by John Anthony Oliver Thursday, September 9, 2010 1:29 AM
    • Unproposed as answer by Dmitry Post Thursday, September 9, 2010 6:42 AM
    Thursday, September 9, 2010 1:25 AM
  • I'm trying to get my button even to wait till i click the left mouse button. but can't seem to find a way to do that.
    Attributor 2.0


    can you be more clear about your question because left mouse is what you need to perform button click

    kaymaf


    CODE CONVERTER SITE

    http://www.carlosag.net/Tools/CodeTranslator/.

    http://www.developerfusion.com/tools/convert/csharp-to-vb/.

    Thursday, September 9, 2010 1:31 AM
  • what i am trying to do is to have my program wait (not go on to code past that point) till i make a mouse click.

    but i don't want it to be a event for a button, more of an even for click itself... regardless of what it clicks.

     


    Attributor 2.0
    Thursday, September 9, 2010 6:50 AM
  • Which means that you should make a class with booleans to set which button actions are already done which you trigger in the events from that action (and nothing more) and create then methods which are done after the clicking of the left mouse.

    Be aware that this is a real very personal approach, which you can use if you make a program for only yourself. It will for sure not be appreciated by other users, who are used to the standard handling like it is currently on every brand of operating system.

     

     


    Success
    Cor
    Thursday, September 9, 2010 7:15 AM
  • How would I do that?
    Attributor 2.0
    Thursday, September 9, 2010 11:06 PM

  • Here is an example form which shows what I would use.  I'm not sure if it fits your needs.
     
    Public Class Form1
     Private lbl As Label
     Public Sub New()
      ' This call is required by the designer.
      InitializeComponent()
     
      ' Add any initialization after the InitializeComponent() call.
      lbl = New Label()
      lbl.Text = "Click To Start"
      lbl.Location = New Point(10, 10)
      Controls.Add(lbl)
     
      AddHandler Me.Click, AddressOf ClickToStart
     End Sub
     Sub ClickToStart()
      lbl.Text = "Click to finish"
      Dim myEventHandler As New EventHandler(AddressOf ClickToStart)
      RemoveHandler Me.Click, myEventHandler
      AddHandler Me.Click, AddressOf ClickToFinish
     End Sub
     Sub ClickToFinish()
      lbl.Text = "You are done!"
      Dim myEventHandler As New EventHandler(AddressOf ClickToFinish)
      RemoveHandler Me.Click, myEventHandler
     End Sub
    End Class

    --
    Mike
    • Marked as answer by Liliane Teng Wednesday, September 15, 2010 8:08 AM
    Friday, September 10, 2010 12:48 AM
  • Hello Blondedude092,

    Thanks for your post.

    What's the situation on your side? When you come back, if you think Mike's reply provides no help, please unmark and follow up. Thanks.

    Best regards,
    Liliane
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. Thanks
    Wednesday, September 15, 2010 8:11 AM