Easiest way to have a Borderless Combo! (Without using Forms 2.0 or Third Party)
I was investigating the forums searching for a way to resize the default ComboBox control (Not the one of Forms 2.0) but there were few samples and all tried to use subclassing and some even were buggy...
So I thought maybe it would be as useful for my purposes to find a way to make the combobox be borderless... but, I found the same kind of samples which were complex (I wanted something simple because I am using an already complex class for my purposes) and I thought of this code which is fairly simple.
Originally the code used no APIs but it required the Combo to be embedded already, so I just added one simple API to the code and one more line and I believe it is pretty simple.
Anyway, I would have liked to have been able to do it without the aid of another control or that I could simply declare it as "New" and then fill it without having it on the Form. If you have an idea, a comment or a suggestion I would like to hear from you.
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
I would modify your the bottom of your NoBorder function to look like this.
VB Code:
NoBorder = True
Exit Function
EndFunction:
MsgBox Err.Number & " " & Err.Description
End Function
It would also be better to change the return type of the function to Integer and return err.number rather than displaying the error message (if any) in the function.
Regarding your suggestion, I don't think I can use it because I am just interested in knowing if the Control was resized or not in run-time.
I can actually tell what the error might be already (A control without Width or Height or maybe they didn't give a PictureBox). And I don't want to annoy the user of the program with a messagebox of something he doesn't know about.
I want to avoid messages like the ones of Microsoft thay say "Error the memory could not be: READ". I prefer to know if there was no problem with the function and recover if there was one and I want to do it neatly without annoying the user.
Anyway, that's a discussion about using error messages or not... Some programmers prefer to use a status bar for that purpose.
Oh, and why do I want a borderless combobox? An image is worth thousand words. I attach the reason as a picture.
Greetings!
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
I can see why you want it borderless and it looks good.
I agree that it's not a good idea to display the error in the function. I think that every function should have a return and it should be up to the calling procedure to decide what to do with the return value. The use of a Boolean can only say success/non-success. An Integer however can say success (when 0) and non-success (any other value). The advantage of the Integer is of course that if you want to know why it failed, the value will tell you.
I see your point, Martin... You are right. I was thinking about that after I replied to you and I came to the same conclusion.
And I agree it would be a nice idea to use it to know which is the source of the error, but currently (since I am the only one who uses the class in the project ) the interesting would be to see if the function works or not.
In a future I might consider (for more complex functions) incorporate your suggestion. I really appreciate it.
I also made the borderless Combo because I found there were some threads with people asking for a flat combo or a borderless combo. The flat combo could be easily achieved using this idea and so I posted it.
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
Another thing you can do with functions is to pass an additional field ByRef and use it in the Function to, for example, pass back the err.description.
Yeah, I used to pass by reference Arrays of Integers when I didn't know how to return Arrays without using Variants.
(Now I know, of course) but it is a pretty good idea. I will post some code in the DataBank as soon as I can solve some issues of the project. I don't want to post a buggy code there.
Could you please check my other post?
Thanks again
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
Think ive found a way, that you dont have to add a picturebox at design time, but rather than that it is simply ough to add it at runtime, just when you calling the method "noborder".
After, setting the parents, the controls (objects) will be merged somehow, that means i cant remove the picTemp control anymore. But it seems to me that vb will remove it, with the parent control at when destroying the form and its contained controls. I found no any leaks so far, but please someone can confirm it?
Last edited by Jim Davis; Feb 4th, 2009 at 03:31 PM.
Mars base one Username: Jim Davis Password: yCrm33
Posts
1,284
Re: Easiest way to have a Borderless Combo! (Without using Forms 2.0 or Third Party)
The thread was, but the problem isnt to me, i just wanted to remove the border. I thought its a good idea to posting here, because this way is belongs to this thread. I have just extended the original code.
Re: Easiest way to have a Borderless Combo! (Without using Forms 2.0 or Third Party)
Originally Posted by MartinLiss
Jim, did you realize that this thread was almost 5 years old?
I never understood that, why would it matter how old the thread is? As long as the post is on topic..... VB6 and earlier hasn't changed, the code is still the same.
Re: Easiest way to have a Borderless Combo! (Without using Forms 2.0 or Third Party)
Yes, but everyone who has subscribed to the thread (which I presume is most people who posted in it, and others) will get notification of it - which is likely to annoy them.
In addition to that, having a new reply means that the thread becomes active again, and other people will spend time try to help the OP who is almost certainly not going to be interested any more (and usually don't reply to say that either).
What Jim did was basically OK, as it will help those who search - but ideally there should have been some kind of indication that the thread was old to stop people attempting to help the OP, hence why moderators/admins (and others) post something to that effect if it isn't included already.
Last edited by si_the_geek; Feb 5th, 2009 at 05:10 AM.
Mars base one Username: Jim Davis Password: yCrm33
Posts
1,284
Re: Easiest way to have a Borderless Combo! (Without using Forms 2.0 or Third Party)
@MagicInk you were right, it is simply enough to set the containers from within vb instead of using the parent api's.
Code:
Set picTemp.Container = ctrlGiven.Container 'using the .parent may not work in some cases, if you use two or more frames.
'....
Set ctrlGiven.Container = picTemp: picTemp.TabStop = False
Mars base one Username: Jim Davis Password: yCrm33
Posts
1,284
Re: Easiest way to have a Borderless Combo! (Without using Forms 2.0 or Third Party)
Originally Posted by si_the_geek
Yes, but
Right. However, everyone have the option to remove subscriptions from their list . That would be also nice, the system should automatically >close< an old thread (in case there were no additions in the last half or 1 year for example) and >mark it as "[Archived]"< or something, to prevent this to happening. Or, just simply remove the subscriptions from the users, if the thread is marked as outdated/archived.