|
-
Apr 6th, 2001, 11:11 AM
#1
Thread Starter
Addicted Member
Hi there . . .
I've got some shapes on my form, and instead of a solid background color, I'd like to have it shaded -- (ie, dark blue on top, light blue at the bottom, faded into each other).
Any suggestions?
Elizabeth
-
Apr 6th, 2001, 04:46 PM
#2
You don't need a shape for this:
Code:
Sub Dither(vForm As Form)
Dim intLoop As Integer
vForm.DrawStyle = vbInsideSolid
vForm.DrawMode = vbCopyPen
vForm.ScaleMode = vbPixels
vForm.DrawWidth = 2
vForm.ScaleHeight = 256
For intLoop = 0 To 255
vForm.Line (0, intLoop)-(Screen.Width, intLoop - 1), RGB(0, 0, 255 - intLoop), B
Next intLoop
End Sub
Private Sub Form_Activate()
AutoRedraw = True
Dither Me
End Sub
Private Sub Form_Resize()
Dither Me
End Sub
-
Apr 6th, 2001, 04:59 PM
#3
Thread Starter
Addicted Member
Sorry I wasn't clear.
I only want little areas of the form to be shaded. Not the whole form.
Originally I had just a shape on the form with a fill color, but now they've decided they'd like to see it with a gradient color instead of a solid.
I've been playing around with images in the meantime.
-
Apr 6th, 2001, 05:03 PM
#4
Thread Starter
Addicted Member
-
Apr 6th, 2001, 08:47 PM
#5
How about using a PictureBox instead? You can still use the above method, but just change the beginning line to:
Code:
Sub Dither(vForm As PictureBox)
And you would use it like:
-
Apr 7th, 2001, 06:13 PM
#6
Thread Starter
Addicted Member
Any suggestion on how to get rounded corners? That's what the boss liked about the shape, was the rounded corners.
Would there be an advantage to using a filled picturebox instead of an image?
Thanks, Elizabeth
-
Apr 7th, 2001, 06:25 PM
#7
Monday Morning Lunatic
The advantage of a PictureBox is that you can draw into it.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 7th, 2001, 06:27 PM
#8
In other words, it's an actual window, whereas an Image is not. An Image is simply drawn onto the DC of the parent window, so the advantage is that it consumes less resources.
-
Apr 8th, 2001, 02:55 AM
#9
Addicted Member
For Round Forms::
Code:
'In a module
' or in a form(Change to private)
Public Declare Function CreateEllipticRgn Lib "gdi32" Alias "CreateEllipticRgn" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Public Declare Function SetWindowRgn Lib "user32" Alias "SetWindowRgn" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
' In The Form
Private Sub Form_Load( )
Dim lRgn As Long
lRgn=CreateEllipticRgn(0,0,Me.Width/Screen.TwipsPerPixelX,Me.Height/Screen.TwipsPerPixelY)
SetWindowRgn Me.hWnd,lRgn,True
End Sub
Worked??
-
Apr 8th, 2001, 03:02 AM
#10
Addicted Member
For Round Corners
Code:
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
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
Private Sub Form_Load()
cx = 50
cy = 50
lrgn = CreateRoundRectRgn(0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, cx, cy)
SetWindowRgn hWnd, lrgn, 1
End Sub
Change The cx and cy values for more
curvature @ the corners.
-
Apr 9th, 2001, 09:43 AM
#11
Thread Starter
Addicted Member
KrishnaSantosh --
Yup, it works, and it might come in handy in the future. But I'm not looking for a form with rounded edges, I'd like a shape with rounded edges inside my form.
Mega -- so it sounds like for my purposes, an image would be better? It's lighter, and I don't really need to draw on it. A static image is fine for what I need to do.
-
Apr 9th, 2001, 11:07 AM
#12
Addicted Member
To shade a control inside the form, just change the
SetWindowRgn to the hWnd of the Control.
Note: Image box doesn't have an hWnd. So try using
picture box as it is much functional that image,
though it costs you something, in terms of
memory.
-
May 27th, 2003, 01:40 PM
#13
Hyperactive Member
Searching for something else I found this nice example for rounding the corners of a form or control with a hWnd.
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|