Results 1 to 7 of 7

Thread: windows forms 2.0

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    837

    windows forms 2.0

    i found this weird glitch unless theres something im missing. Say you have a regular old command button (the one thats always in the toolbox) and you put code to hand a right mouse button click in the MouseUp event, that works just fine. But if you use the button from the forms 2.0 library then when you run your program you have to click the button with the left mouse button before the MouseUp event is fired if you click the button with the right mouse button...did i explain ok?

    if anybody could help me resolve this actually it would be great. I want to use the forms 2.0 button for its ability to place the graphic anywhere around the button.
    Last edited by DNA7433; May 12th, 2003 at 09:33 PM.
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  2. #2
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857
    the forms 2.0 button is from fm20.dll and is the control library used in Excel, Word, Acess, PowerPoint, Visio, etc. This button definitely behaves differently. It will not fire the mouse up event until it has focus. If you click it first, then right-click the mouse over it - it works. To work around this problem, set the focus on the control before the user clicks on it (ie, when the mouse first moves over the control)

    VB Code:
    1. Private Sub CommandButton1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2.     CommandButton1.SetFocus
    3. End Sub
    4. Private Sub CommandButton1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    5.     MsgBox "Test"
    6. End Sub
    "Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!

    Resistance is futile, you will be compiled . . . Please!

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    837
    ok, lets mix things up a bit. If you click on the button then you click on something else to make the button lose focus, the right click thing will then work, and it will continue to work for the rest of your program. I was trying to come up with a way to click the button in the form_load event so that it be all ready to go. I guess i could SendMessage the button, but this is only a map editor for a game thats supposed to be done by the end of the week.
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  4. #4
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    Just put the code that is inside the button into a sub procedure. THen in form load, and the button click event for that button, call the procedure :-)

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    837
    i don't see how that will solve the problem. I want to be able to do somethign when the button is clicked with the left mouse button and this has worked fine whether i put it under the click event or the mouseup event. I also want a popup menu to appear when i right click the button so to detect a right click i put the popupmenu call in the mouseup event, which doesn't get fired until the button has been clicked by some other means other than the right mouse button.
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  6. #6
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857
    What was wrong with my example? Set focus on the button when the mouse moves over it . . .
    "Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!

    Resistance is futile, you will be compiled . . . Please!

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    837
    ok sorry i didnt' clarify. Armbruster, you're idea works, i was just wondering how ae_jesters would work?

    thanks for the replies guys
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

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