Look at the attached image of a button. I want to create the same kind of button rounded button. The part that I am stuck on is how to draw different (3D) borders around the button. It's easy for a simple rectangle but I've no clue how to do that of anything other than a rectangle.
I am creating a custome button using a picture box. So any code given can use a picture box to draw stuff on it.
Well, I suggest that in the Click/MouseDown events you check the X/Y to see if it hits the button or not - that will enhance the effect of curves, etc.
But I'm still not really sure where your problem lies. The picture you had looks fine to me...
The thing is that the picture attached is not the button created by myself
I want to create the same button using MY code. The problem is drawing that rouned rectangle around the button. I don't need to work with any mouse interface for now, but I want to create a button that has a 3D border around that. If I create a rectangular button, there is an API called "DrawEdge" that I can use to draw 3D borders but it only works for rectangular buttons. If I have circular, triangular, or rounded button, how would I draw a 3D border? I need to draw some kind of lines of rectangles manually using white colour of the left and top sides edges of the button, and drawing the same kind of lines using gray or black colour on the bottom and right sides of the button. Hopefully, you get the problem now
Just a suggestion, not that i know a lot about this kind of thing, but I remember someone making a odd shaped form by using API to drawn it like a polygon. They then created their shape using a jagged shaped polygon (with more than 3 points).
Since I already did one of those, I'll help you a little bit.
Check the API call:
VB Code:
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
It creates a rectangular rounded region, on which you draw a border with the call:
[Highlight=VB]
Private Declare Function FrameRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
[Highlight=VB]
Last but not least, you change the standard retangular window region of your usercontrol to the newly created region by using:
VB Code:
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
For more information about using Regions, check either the platform SDK or msdn.microsoft.com
Originally posted by AIS_DK Since I already did one of those, I'll help you a little bit.
Check the API call:
VB Code:
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
It creates a rectangular rounded region, on which you draw a border with the call:
[Highlight=VB]
Private Declare Function FrameRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
[Highlight=VB]
Last but not least, you change the standard retangular window region of your usercontrol to the newly created region by using:
VB Code:
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
For more information about using Regions, check either the platform SDK or msdn.microsoft.com
Thanks, but I was able to create a rounded region of a picture box. But if you look carefully, the picture boxbecomes totally flat because it cuts off its edges from all 4 sides. Now, how do I draw that 3D rounded border around the regioned picture?
Using different pictureboxes to create a rounded button is the easiest way, I think.
But how about the manual stuff like the button you see on this website: www.vbthunder.com (rainbow button)
geoff_xrx:
Has Kedaman done that picture switching or the actual rounded button using API?
Keda has created a shape that can be changed which has click events, mouseover and mouseoff events. its call the LCARS control. pretty cool. I am guessing it uses some similar API to what your needing. Drop him an email
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Originally posted by Motoxpro go to www.planet-source-code.com and go to the contest page and it will be like a buttons thing or somethin and it shows you how
I hope it helps :-) It will work on anything with a hWnd.
I can create the region (which is the first thing you do if you want to create a button other than rectangular one), but if notice, the button is all flat because creating a region cuts out all the edges so it takes off the 3D border around the button. Now, I want to create a rounded 3D border around the button. How would you go about doing that?
Yo. Why don't you just create your buttons in Photoshop and use a imagebox to display them? Set all the pictures in a imagelist and call the picture for the mouse down and mouse up events.
You have to set a transparent label on top of the imagebox to allow the user to change caption ect...
This would be the best way to do it.
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.
Originally posted by Arc Yo. Why don't you just create your buttons in Photoshop and use a imagebox to display them? Set all the pictures in a imagelist and call the picture for the mouse down and mouse up events.
You have to set a transparent label on top of the imagebox to allow the user to change caption ect...
This would be the best way to do it.
Yes, but what if I wanted to do, let us say, gradiants on that button or some other effects?
That's why I want to leave the pictures out for this kind of effect.
Originally posted by DaoK He just wants to create his own control OCX are hard to make and can be a good project.
Actually, this is a part of my big project - a messenger or chat program, in which I want to allow the user to use different skins and lots of other stuff
I was just looking for some code no matter in which form it was (OCX or just simple code). Now, I will create another OCX out of it that has some more features.
You can make a really big OCX with a lots of feature and it can be hard, I have read the Tutorial on that website and I can not make everything than I have in my head about OCX but I do not worry because I hate adding OCX in my project