Results 1 to 8 of 8

Thread: Creating odd shaped command Buttons

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288

    Exclamation

    Can somebody help me in creating odd shaped command buttons? As far as I know, there are some api's(CreateRoundRect) which help you in performing the said function, but I am unable to use it. Also, what if I would like to create a command button of any shape based on some picture?


    Thanks
    Amitabh

  2. #2
    Hyperactive Member WP's Avatar
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    278

    Talking

    dont ask your question twice!

    WP

    Visual Basic 6.0 EE SP5 / .Net
    Windows XP

  3. #3
    Addicted Member eanilarora's Avatar
    Join Date
    Aug 2000
    Location
    Malaysia
    Posts
    179

    Talking It is very easy

    I have not done it myself but i think it should be ver easy stuff.
    Only thing is that you have to be creative

    first draw a couple of images in your favorite image editor.
    one for a normal button and other for the pressed one.

    You can place these images over a picture control. At run time when then user click over it you can write a code for showing the other picture till the time the mouse is down and when the user releases the mouse (MouseUp) you can show the orignal image.

    this should work.

    If it does not then do mail me and i'll try'n do it for you.
    Happy

  4. #4
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    You should also use the API's SetCapture() and RelaseCapture().
    There is a lot of sample codes available about using "skins" (graphical user interfaces) which implement such buttons. Just search on the web. I always use http://www.google.com to find the best results...

  5. #5
    Addicted Member
    Join Date
    Aug 2000
    Location
    Croatia
    Posts
    200

    Talking

    How about creating ActiveX control?

    To create buttons based on some picture, create a picture in any image editor. Fill the parts that have to be "transparent" in any color which is different from all the others (i.e. magenta, light gray, white).

    Now create ActiveX Control project. Set controls' BackStyle property to Transparent. In Picture and MaskPicture properties load the picture you've previously created. Finally, set the MaskColor property to the color that should be transparent (look up).

    Basically that's it, but you'll have to add some code though

  6. #6
    Lively Member
    Join Date
    Aug 2000
    Location
    quebec
    Posts
    81
    you can also do this using simple image controls.

    just use icons instead of bmp's then get the mousemove, down
    and click events to change the images.

    the actual icon images can be stored either as image controls
    on the page, an imagelist control or in a resource file.
    Res files are best as they don't take up memory until the
    resource is actually loaded.

    you need 4 images for each button (3 if you don't need a
    web style mouseover event).
    1. the visible 'button' with 'idle' image
    2. the mousemove image
    3. the mousedown image
    4. the invisible 'idle' image

    just switch the picture property for the main visible image control for each event.

    use the mousemove event of the container (form or
    picturebox or whatever) to change the image back to it's
    'idle' status image.



    that's a lotta controls needed for one measley button!
    SO:
    you should write an ActiveX UserControl with the above-mentioned functionality (as someone else mentioned)
    - it'll make life a lot easier.

  7. #7
    Addicted Member
    Join Date
    Aug 2000
    Location
    Croatia
    Posts
    200
    Using Image controls is not so bad idea, but the basis of non-rectangular button is that it recieves mouse events only on VISIBLE areas. That's way creating ActiveX Control is better if you have lots of those buttons.

  8. #8
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    You can also use VB6's ImageList OCX control, which lets you also choose the MaskColor for transparent pictures.

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