August 19th, 2004, 09:21 AM
TIP: Heres a little tip for region mapping on buttons..
I recently devised a nice little thing and thought i would share it with you guys, incase anyone else likes it and wants to use it.
I have a program with some image buttons and a simple, small user interface. It is for running reports, and the image on the button is somehow related to the report, and the text to the right gives some small info about the report
Now, i was asked, can i make the reports with some configuration ability, like ORDER BY. sure, says i.. and thought to have a nice, subtle combobox next to the report name, so it would say "Full Stock List ordered by Item Code" etc
Well, as i found, the combobox couldnt be made flat, so it just looked ugly...
Eventually, i realised, what if i make the button do a different action, depending where i click it.. I can have the lower right region of the button for config, and edit the picture to put some kind of star icon in that region or something..
So i changed my button click method into mouseUp, because that gives twips coordinates of where the click occurred. I used mouseup because using mouseDown causes the button to behave not-like-a-button (ie something happens too soon)
After that, it was a matter of working out how the buttonclick coordinates were to be used. You can define rectangular or triangular areas with this method. initially I had a square area, but later switched to a triangular one when i pasted the settings-indicator onto the button (it was triangle shaped)
I post the following pictures as a demonstration of how to mathematically select a range of coordinates in order to provide a different action for a button, depending on where it is clicked. You could use these in combination, to make some strange shapes
August 19th, 2004, 09:25 AM
heres some example code, that confines my popup menu to appearing only if i click the lower right triangle of the button:
and in action:
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, mouseX As Single, mouseY As Single)
'out of the button?
If Not (mouseX > 0 And mouseY > 0 And mouseX < Command1.WIDTH And mouseY < Command1.HEIGHT) Then Exit Sub
If ((mouseX / twipX) + (mouseY / twipY) > 70) Or Button = vbRightButton Then
Last edited by cjard; August 20th, 2004 at 07:25 AM.
August 19th, 2004, 07:13 PM
But if options are two, how about using "Button" parameter of mouseUp
event and left Vs right click? Or you did not like rightClick not showing
the button pushed?
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
August 20th, 2004, 07:29 AM
oh, yes.. and that feature is in the code.. if you see, the statement is:
if (within region) OR button = vbRightButton
but i deal with simple people in my work.. and they do not always use the right button. plus, from an HCI point of view, it is better to show the cogs.. that way i can say in the documentation "click the cogs to configure" ..
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.