Results 1 to 4 of 4

Thread: Looking for Custom UC checkbox on/off switch

  1. #1

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,664

    Question Looking for Custom UC checkbox on/off switch

    I'm looking for a custom simple checkbox/option button in the following on/off style:


    I've started a custom control, but if there's one out there, it'll surely speed up my work flow.

    I've found one but that uses GDI+ too heavily, which I want to avoid.

    Any links or ideas?
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: Looking for Custom UC checkbox on/off switch

    I have seen some similar controls out there, but I'll let you search for them. One thing I often do is search with Google, with the site:vbforums.com as part of my search terms.

    Also, if I were doing this from scratch, I might think about a custom UC just rotating through maybe half-a-dozen images of the switch sliding side-to-side to toggle it on or off. That would be a nice effect, and wouldn't need any GDI or GDI+ at all. GDI+ certainly does seem like overkill for something like this, regardless of how you do it.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  3. #3
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Re: Looking for Custom UC checkbox on/off switch

    I agree with Elroy. You can use simple images in combination with simple GDI calls like StretchBlt to achieve this. However, I won't lie to you, it's still going to take quite a bit of time. You still will need to handle drawing the text yourself which means you will have to deal with Fonts and stuff yourself which can get a bit involved when you're doing it using Win32 and GDI. You will also have to implement the check logic yourself which means handling of mouse events and whatnot. However, this is simple enough that you can do all that in a single night.

    Too bad VB6 doesn't have something like WPF where you can do this in a couple of minutes.

    EDIT:

    On second thought, I just remembered that UserControls in VB6 handle Fonts by default so you can just use the DrawText Win32 function to draw your text into the UserControl's device context without concerning yourself with fonts. The UC internals would take care of all that. Not having to deal with fonts would save about an hour of work.
    Last edited by Niya; Nov 27th, 2021 at 07:37 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  4. #4
    Member
    Join Date
    Jan 2021
    Posts
    55

    Re: Looking for Custom UC checkbox on/off switch

    You can get "LabelPlus" User Control (https://www.vbforums.com/showthread....3707-LabelPlus) from Leandro Ascierto

    Here you have a proyect using LabelPlus and use that style http://leandroascierto.com/blog/descargador-de-videos/

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