TIP: Heres a little tip for region mapping on buttons..
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: TIP: Heres a little tip for region mapping on buttons..

  1. #1
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    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
    Attached Images Attached Images  
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  2. #2
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104
    heres some example code, that confines my popup menu to appearing only if i click the lower right triangle of the button:

    Code:
    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
      
      'setup options?
      If ((mouseX / twipX) + (mouseY / twipY) > 70) Or Button = vbRightButton Then
    and in action:
    Attached Images Attached Images  
    Last edited by cjard; August 20th, 2004 at 06:25 AM.
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726
    Nice trick.
    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.

  4. #4
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104
    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" ..
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center