Important alert: (current site time 7/16/2013 2:37:19 AM EDT)
 

winzip icon

MorphOptionCheck 2.22 - Combo OptionButton/CheckBox UserControl

Email
Submitted on: 4/27/2006 6:30:37 PM
By: Option Explicit 
Level: Intermediate
User Rating: By 27 Users
Compatibility: VB 6.0
Views: 20963
author picture
(About the author)
 
     MorphOptionCheck is a subclassed, ownerdrawn usercontrol that combines the functionality of VB's OptionButton and CheckBox controls. Uses version 2.1 of Paul Caton's self-sub usercontrol code. Unicode supported. Background and border of control may be rendered transparent. A much-improved version of a control I had posted on PSC for a short time about a year ago. As always, constructive comments welcome, votes appreciated. ----------------------11 April 2006 - Added icon display capability, you can now use icons in place of standard checkboxes. Rearranged and tightened up code, added property to allow you to not display focus rectangle, and added code to allow you to see changes as you are making them in design mode. Added property descriptions in IDE property window.

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 8 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

4/7/2006 12:16:03 PMOption Explicit

Hi all... I know there's many option buttons and checkboxes on this site but I like this little control since it's simple, attractive and does the work of both intrinsic controls. I also wanted to be the first kid on the block to submit something with Paul Caton's cool new subclasser. :D Enjoy.
(If this comment was disrespectful, please report it.)

 
4/7/2006 7:49:46 PMHeriberto Mantilla Santamaria

Wow, is cool see the new subclass version of Paul's using in this new ownerdrawn usercontrol, the morph control is perfect as always.

Thx for sharing, I try to reupload all my control's with the new subclass too or I try to create new one.
(If this comment was disrespectful, please report it.)

 
4/7/2006 9:10:16 PMOption Explicit

Thanks Heriberto. Replacing the old subclass code with the new was a snap - just simple cut and paste. The one thing to watch out for is you have to dim the z_Data() array to at least the number of procedures in your usercontrol. In this control I added about 20 to that number for any possible future expansion of the control. One of my many spies tells me that Paul may be working to autosize the z_Data array, along with a couple other tweaks. Maybe, maybe not... my spies aren't always reliable but this one is usually right... But this seems to work great for the limited stress my controls put on Paul's code.
(If this comment was disrespectful, please report it.)

 
4/7/2006 9:13:25 PMOption Explicit

You can easily get the number of procedures in your control by using MZ Tools... I'm a latecomer to that package and I wish I had used it years ago. The only worthwhile free VB project analyzer I've ever come across.
(If this comment was disrespectful, please report it.)

 
4/8/2006 12:12:03 PMPaul Caton

Option, that's very brave of you... and slightly premature :) The gotcha you mention re procedure counts will be gone on my next update at the end of the weekend. Mail me if you want a head start.
(If this comment was disrespectful, please report it.)

 
4/8/2006 12:44:46 PMOption Explicit

Thanks Paul... I knew you had updates planned but I just wanted to see how easy it was to change out the version 1 subclasser. I'll keep an eye on your submission. You da man.
(If this comment was disrespectful, please report it.)

 
4/9/2006 11:02:17 AMOption Explicit

Thanks for the votes everybody... I will be updating this soon to allow selectable icons as an optional replacement for the checkboxes / tickmarks. Might as well make it "morphier"... :D
(If this comment was disrespectful, please report it.)

 
4/9/2006 4:46:29 PMHeriberto Mantilla Santamaria

Yeah Matt, I see this peculiar thing, but I put in my control more than 20 in the zdata().
(If this comment was disrespectful, please report it.)

 
4/10/2006 2:54:03 AMRichard Mewett

Good to see the other Morph Controls appearing again - and with improvements! *****
(If this comment was disrespectful, please report it.)

 
4/10/2006 5:47:47 PMOption Explicit

Thanks Richard. As I said this is in the process of being improved further, although I want to keep the code size small. Will repost soon...
(If this comment was disrespectful, please report it.)

 
4/10/2006 8:09:02 PMKenneth Foster

Matt, a really nice job. I've also modified it into a button control as well. 5 globes from Texas. Keep it up. I love these controls. Ken
(If this comment was disrespectful, please report it.)

 
4/11/2006 8:42:32 AMOption Explicit

Thank you Kenneth, glad you like them... I don't know exactly why I latched onto controls as my way of contributing to this site. Maybe Paul Territo (TerriTop) said it best when he stated that he likes usercontrols because they combine any and all aspects of VB programming into a single module. Or something like that. Thanks from Ohio :D
(If this comment was disrespectful, please report it.)

 
4/11/2006 11:39:34 AMMiroslaw

I novice and ask to excuse for a foolish question. How possibly, in principle, to make corners more smoothly?
At present both in ucGradContainer and in MorphOptionButton
curves on corners look very jagged.
*****
(If this comment was disrespectful, please report it.)

 
4/11/2006 12:19:18 PMOption Explicit

Miroslaw, not a foolish question at all. The truth is, I do not know. The CreateRoundRectRgn API that I use is responsible for the curvature. I also would like to know if there is another technique that could be used to create smoother rounding effects, so anyone here who might have some ideas I (and Miroslaw) would love to here them. Thanks for bring that issue up, it's something I have wondered about too.
(If this comment was disrespectful, please report it.)

 
4/11/2006 7:56:15 PMMiroslaw

May be using GDI+ or OpenGL can solve this problem?
What will our GURU’s say?
(If this comment was disrespectful, please report it.)

 
4/12/2006 8:55:21 AMLaVolpe

Well, here's my $.02... Idea #1
With window region shapes, antialiasing (AA) isn't so simple. You would need to know what pixels are behind the window (control) that would be covered up by the AA pixels, then add those AA pixels to the region. So you'll have a small flicker possibly: initially drawn without AA, get parent pixels behind AA pixels, add AA, then adjust/reset region. Sizing controls probably best without AA and apply AA after sizing is complete. As for AA routines, GDI+ probably, and this site has some AA posts that might help. Of course the AA is static so using the logic over animation isn't a good idea.
(If this comment was disrespectful, please report it.)

 
4/12/2006 8:58:28 AMLaVolpe

Idea #2 is the opposite of #1.
Shape the control then get a DC snapshot of the control's container. Draw the antialiased (AA) pixels directly on the container. Downside is that repaints may erase your AA pixels or you are forced to use extra resources by telling VB to set the container's AutoRedraw=True. I'm sure there are ways and its only a matter of rolling up one's sleeves and applying some elbow grease towards resolution. Now if layered windows applied to child controls, you could use alpha bitmaps.
(If this comment was disrespectful, please report it.)

 
4/12/2006 5:56:16 PMOption Explicit

Ahh LaVolpe... my dark master... I knew you would come... lol. Anyway, thanks for the ideas. Personally I don't know if I want to expend a lot of energy working towards a solution for something I only use in PSC demo programs. I knew it would be a p.i.t.a. (at least for me) and you pretty much confirmed that! I want to keep this control small, and although it may cost me a vote from my new friend Miroslaw, I'll just have to live with that :) I just put it out there on the off chance there would be a less "intensive" solution. However, I will look into it for future use so your $.02 is well spent ;) Thanks.
(If this comment was disrespectful, please report it.)

 
4/14/2006 11:48:16 AMKevin Ritch

5 Globes from me Groovy Dude! I reckon that I am going to adopt your cat. Your inspiration must come from somewhere :-) BRILLIANT stuff with the check boxes and radio buttons! Cheers, Kevin
(If this comment was disrespectful, please report it.)

 
4/14/2006 5:49:20 PMOption Explicit

Hmmph. Humans. Just because the author picture is a cat they assume it must be someone's pet... Let me tell ya somethin' pal... that cat is ME. *I* wrote these controls, not some inferior human. I allow my pet human Matthew R. Usner to type for me, as my lack of fingers and opposable thumb is somewhat of a problem. But the brainpower is MINE, thank you very much...Meow.

:D :D :D :D Thanks Kevin.


(If this comment was disrespectful, please report it.)

 
4/16/2006 12:20:57 AMHeriberto Mantilla Santamaria

Wow Matt, your cat is fantastic, but one question can your cat fly?
(If this comment was disrespectful, please report it.)

 
4/16/2006 12:04:25 PMOption Explicit

Now Heriberto, don't be silly. Cats can't fly, they don't have wings. However, she IS working on her pilot certification....
(If this comment was disrespectful, please report it.)

 
4/16/2006 3:19:23 PMHeriberto Mantilla Santamaria

Hi Matt, yeah I see your pic, but your cat fly don't need wings for this...

xD
(If this comment was disrespectful, please report it.)

 
4/16/2006 6:07:27 PMOption Explicit

OK, back to more serious matters... (or not) I added 3 properties to allow transparency - .Transparent, .BorderIfTransparent and .ContainerName. See comments at top of .ctl for usage. I had these in last year's version of this control but they didn't work for everybody perfectly. I reworked them a bit so here ya go... Let me know how it works for you, I'd really like to get this concept hashed out for future Morphies. Thanks.
(If this comment was disrespectful, please report it.)

 
4/16/2006 9:03:46 PMHeriberto Mantilla Santamaria

Yeah of course, I download again and comment how work the control now.

But sure work perfectly.
(If this comment was disrespectful, please report it.)

 
4/16/2006 9:08:22 PMHeriberto Mantilla Santamaria

Run perfect in my OS, the new styles is great too.
(If this comment was disrespectful, please report it.)

 
4/17/2006 7:28:59 AMOption Explicit

Glad to hear it Heriberto... what OS do you use?
(If this comment was disrespectful, please report it.)

 
4/17/2006 9:49:23 PMHeriberto Mantilla Santamaria

Hi Matt, my OS is WinXP SP2, but I run in Win98SE too, run perfectly.
(If this comment was disrespectful, please report it.)

 
4/18/2006 9:29:42 PMOption Explicit

Thankd Heriberto. Jim Jose used to run Win98SE also and it didn't work for him, so maybe I got lucky and this works for all OS's now. I hope so!
(If this comment was disrespectful, please report it.)

 
4/25/2006 7:23:22 AMOption Explicit

OK I have been notified by various people that the transparency is successful under Win98, Win98SE, XP, XP SP2, 2000 and 2003 Server. Working on a small bug reported by Gary Noble (Phantom Man). Will re-up when solved. Thanks to everybody for taking the time to test this transparency.
(If this comment was disrespectful, please report it.)

 
4/25/2006 6:03:36 PMOption Explicit

OK The transparency issue reported by Phantom Man has been resolved... by Phantom Man! When I got home I found the solution in my inbox. Thanks for being so helpful Gary. The issue was that when closing forms with transparent controls, the MakeControlTransparent routine would try to BitBlt from the container when it had already gone poof... not good. Fix uploaded and thanks again Gary.
(If this comment was disrespectful, please report it.)

 
4/26/2006 9:45:47 AMJeff Mayes

Transparency not working when placed on your jcFrames, the color from the form is used instead of the color from the frame. Good work, though. I give you 5 planets.
(If this comment was disrespectful, please report it.)

 
4/26/2006 4:16:10 PMOption Explicit

Hi Jeff, thanks for the feedback and the vote. Um, it's not *my* jcFrames, you're thinking of Juan Carlos San Roman. However, I will download his latest and check it out. This transparency has driven me nuts for the longest time and I want to get it 100%. Your feedback helps this cause! Thanks again. And I haven't forgotten about multiple columns for MorphListBox...
(If this comment was disrespectful, please report it.)

 
4/26/2006 7:12:26 PMJeff Mayes

Sorry about that (jcFrames), I was in a hurry. Thank you for keeping the columns in mind. I did find a temp way around, but I do not like it. What I did was place a series of labels in front of the listbox, and use the listbox scrollbar value to choose which records to display. This si similar to what I did for the "font combobox" I submitted before. Not pretty, not good practice, but within my skill level and works. Thanks.
(If this comment was disrespectful, please report it.)

 
4/26/2006 9:43:17 PMOption Explicit

Jeff, I downloaded JC's frame and tried it out... transparency doesn't work on my system with his frame either. It's the dandest thing. Works on different OS's with forms, pictureboxes, and my MorphContainer but not with Juan's frame. You'd think it would work with Juan's usercontrol if it works with mine... I will have to study this more but enough for tonight... I'm a cranky old man and need my sleep :\ In the meantime if anybody wants to try it, Juan's frame is at:

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=64261&lngWId=1


(If this comment was disrespectful, please report it.)

 
4/27/2006 4:02:11 PMOption Explicit

LaVolpe emailed me with a possible "covers-all-situations' transparency routine mod... I will try to have it posted today or tomorrow morning for people to test. Thanks Keith.
(If this comment was disrespectful, please report it.)

 
4/27/2006 6:08:24 PMOption Explicit

OK, have implemented LaVolpe's tweaks. Thanks again Keith. The only thing I had to do to Juan's jcFrames was add a Property Get hDC routine to his .ctl file. Any container that a MorphOptionCheck is placed in MUST have an exposed DC if you wish to use the transparency feature. As always, please give me some feedback on how this performs for you... Thanks to Jeff Mayes for finding the bug.
(If this comment was disrespectful, please report it.)

 
4/28/2006 8:43:01 AMLaVolpe

Matt, heads up? A container shouldn't have to expose a DC. The GetDC API does the job. For example, the VB Frame doesn't expose a DC but your control works there too with the new hacks.
(If this comment was disrespectful, please report it.)

 
4/28/2006 9:21:21 AMLaVolpe

^P.S. If the ContainerName property of your control is used, then the hDC must be exposed; else it doesn't. However, maybe suggest getting rid of that property now?
(If this comment was disrespectful, please report it.)

 
4/28/2006 5:35:59 PMOption Explicit

Yeah, I guess that's right! Never thought about that. I'll get rid of ContainerName too. It may not be for a week or so; Monday I fly down to sunny Florida for the week... first vacation in quite a while. I know nerds aren't supposed to be directly exposed to sunlight but I'll have to take my chances :D Maybe I'll have time this weekend to make the mods. Thanks again Keith.
(If this comment was disrespectful, please report it.)

 
4/29/2006 11:14:53 AMLaVolpe

Matt, before you take my word for it, there may be other issues to address if you decide to go that route. For example, your mousemove event will adversely affect drawing transparent buttons when [Border] and/or [CheckBox Border] options are set and no m_containername is set. This is because when button is hidden, painted, & shown it triggers mousemoves which then triggers redraw & you have a recurring loop that will have to be addressed. My solution should work for all containers, but this means re-examining/tweaking some existing logic.
(If this comment was disrespectful, please report it.)

 
4/29/2006 9:24:52 PMOption Explicit

Keith, after my vacation I'll look into it. My brain is already lying on a beach on the Gulf of Mexico, rest of body soon to follow...
(If this comment was disrespectful, please report it.)

 
5/6/2006 7:43:21 PMOption Explicit

Hi everyone, I'm back from vacation. I am just soooo sure you all missed me terribly... :D

It was nice to get away to paradise for a week... not long enough. Anyway, thanks to everyone who left feedback and voted. LaVolpe I'll look into your ideas soon.
(If this comment was disrespectful, please report it.)

 
5/8/2006 7:37:51 AMRichard Mewett

Congratulations on another win! At this rate I predict a new section ("Morph") will appear....
(If this comment was disrespectful, please report it.)

 
5/8/2006 3:25:34 PMOption Explicit

Thanks Richard... although I can think of at least one princess! wannabe! intellectual! on this site who might not like that idea... " ;o) ;o) ;o) " lol.
(If this comment was disrespectful, please report it.)

 
5/28/2006 11:12:17 PMJarvis

You have done such a wonderfull job. My favortie is the XP style frame which is only available in the Studio Express version of Visual Basic 2005.
I have been looking high and low for this control and to find it here without a fee is a god send. Your code rocks.. 5 Globes from me.. When I finish developing my application I will post it here to planetsource code for you to view. So you can see what I have done with your wonderfull control.
(If this comment was disrespectful, please report it.)

 
5/29/2006 7:31:17 AMOption Explicit

Thanks Jarvis! It's nice any time I start out my day hearing someone likes my stuff. I still have a bit of work to do on the transparency but I'll get around to it. Thanks again for the nice compliment and the vote.
(If this comment was disrespectful, please report it.)

 
6/15/2006 7:35:54 PMOption Explicit

Thanks for the vote Dean.
(If this comment was disrespectful, please report it.)

 
11/2/2006 5:14:24 AMpradeep

Highly superb. If added features like Data Input Type i.e UpperCase, Alpha, Numeric, Date, Email, URL, Decimal Places, Custom Format etc, this will help the users even better.
(If this comment was disrespectful, please report it.)

 
11/2/2006 12:16:36 PMOption Explicit

Thamks pradeep but I think you placed a comment about MorphTextBox in my MorphOptionCheck submission! ;) I got it though, and thanks for the idea and vote. When I get time I will take a closer look at your suggestions.
(If this comment was disrespectful, please report it.)

 
4/24/2007 8:06:38 PMOption Explicit

Any improvement suggestions?
(If this comment was disrespectful, please report it.)

 
4/29/2007 12:54:02 AMWilliam

Great! The combination of this code with your other submissions (Listbox and LED) make a huge difference in UI design and look. If you can include the Vista form that you used with the Listbox image, the design could make a good functional application a killer app thanks to the work and creativity you unselfishly share. 5g, thanks again for sharing!
(If this comment was disrespectful, please report it.)

 
6/23/2007 12:41:27 AMRob C

"I gots to know!" (Dirty Harry)
Am I the first to say -

That's a purrfect 5

Rob
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.