|
-
May 12th, 2003, 09:24 PM
#1
Thread Starter
Fanatic Member
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.
-
May 12th, 2003, 10:03 PM
#2
Fanatic Member
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:
Private Sub CommandButton1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
CommandButton1.SetFocus
End Sub
Private Sub CommandButton1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MsgBox "Test"
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!
-
May 13th, 2003, 01:26 PM
#3
Thread Starter
Fanatic Member
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.
-
May 13th, 2003, 01:30 PM
#4
Frenzied Member
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 :-)
-
May 13th, 2003, 06:48 PM
#5
Thread Starter
Fanatic Member
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.
-
May 13th, 2003, 06:50 PM
#6
Fanatic Member
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!
-
May 13th, 2003, 09:20 PM
#7
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|