|
-
Sep 13th, 2010, 02:31 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] How to draw gradient over toolbar?
Am trying to emulate the gradient look in explorer so am using the code below (i found here on vbforums) to draw gradient over the toolbar in vb6sp6, using the toolbar in common controls v5sp2, but nothings happens.
I enabled theme by using manifest in my app.
vb Code:
Private Type TRIVERTEX
x As Long
y As Long
Red As Integer 'Ushort value
Green As Integer 'Ushort value
Blue As Integer 'ushort value
Alpha As Integer 'ushort
End Type
Private Type GRADIENT_RECT
UpperLeft As Long 'In reality this is a UNSIGNED Long
LowerRight As Long 'In reality this is a UNSIGNED Long
End Type
Const GRADIENT_FILL_RECT_H As Long = &H0 'In this mode, two endpoints describe a rectangle. The rectangle is
'defined to have a constant color (specified by the TRIVERTEX structure) for the left and right edges. GDI interpolates
'the color from the top to bottom edge and fills the interior.
Const GRADIENT_FILL_RECT_V As Long = &H1 'In this mode, two endpoints describe a rectangle. The rectangle
' is defined to have a constant color (specified by the TRIVERTEX structure) for the top and bottom edges. GDI interpolates
' the color from the top to bottom edge and fills the interior.
Const GRADIENT_FILL_TRIANGLE As Long = &H2 'In this mode, an array of TRIVERTEX structures is passed to GDI
'along with a list of array indexes that describe separate triangles. GDI performs linear interpolation between triangle vertices
'and fills the interior. Drawing is done directly in 24- and 32-bpp modes. Dithering is performed in 16-, 8.4-, and 1-bpp mode.
Const GRADIENT_FILL_OP_FLAG As Long = &HFF
Private Declare Function GradientFillRect Lib "msimg32" Alias "GradientFill" (ByVal hdc As Long, pVertex As TRIVERTEX, ByVal dwNumVertex As Long, pMesh As GRADIENT_RECT, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Long
Private Function LongToUShort(Unsigned As Long) As Integer
'A small function to convert from long to unsigned short
LongToUShort = CInt(Unsigned - &H10000)
End Function
Private Sub Form_Load()
'KPD-Team 1999
'URL: [url]http://www.allapi.net/[/url]
'API uses pixels
Me.ScaleMode = vbPixels
End Sub
Private Sub Form_Paint()
Dim vert(1) As TRIVERTEX
Dim gRect As GRADIENT_RECT
'from black
With vert(0)
.x = 0
.y = 0
.Red = 0&
.Green = 0& '&HFF& '0&
.Blue = 0&
.Alpha = 0&
End With
'to blue
With vert(1)
.x = Me.ScaleWidth
.y = Me.ScaleHeight
.Red = 0&
.Green = 0&
.Blue = LongToUShort(&HFF00&)
.Alpha = 0&
End With
gRect.UpperLeft = 0
gRect.LowerRight = 1
GradientFillRect GetDC(tbMain.hwnd), vert(0), 2, gRect, 1, GRADIENT_FILL_RECT_H
End Sub
Does anybody knows why the code is not working?
-
Sep 13th, 2010, 03:07 PM
#2
Re: How to draw gradient over toolbar?
tbMain.hwnd is not what you want. You want the child window of the tbMain.hwnd.
Read the posts in this thread, it applies.
-
Sep 13th, 2010, 04:22 PM
#3
Thread Starter
Fanatic Member
Re: How to draw gradient over toolbar?
thanks Lavolpe, this solves my problem
-
Sep 13th, 2010, 05:02 PM
#4
Thread Starter
Fanatic Member
Re: [RESOLVED] How to draw gradient over toolbar?
Please one more thing, if i want to translate this structure
vb Code:
With vert(0)
.x = 0
.y = 0
.Red = 0&
.Green = 0& '&HFF& '0&
.Blue = 0&
.Alpha = 0&
End With
from color values like #eeead6 to the individual red,green, and blue, how do i get these values in ushort
-
Sep 13th, 2010, 06:14 PM
#5
Re: [RESOLVED] How to draw gradient over toolbar?
(Not in answer to your last question) but just in case it could be useful for you, i have a thread in the CodeBank about chaging Toolbar background to any color or using a picture as pattern, here is the link:
http://www.vbforums.com/showthread.php?t=381167
-
Sep 14th, 2010, 08:28 AM
#6
Re: [RESOLVED] How to draw gradient over toolbar?
 Originally Posted by coolcurrent4u
...
from color values like #eeead6 to the individual red,green, and blue, how do i get these values in ushort
What is #eeead6? Looks like an html color value? If it is then
Code:
Red = CLng("&H" & Mid$("#eeead6",2,2))
Green = CLng("&H" & Mid$("#eeead6",4,2))
Blue= CLng("&H" & Right$("#eeead6",2))
-
Sep 17th, 2010, 12:16 PM
#7
Thread Starter
Fanatic Member
Re: [RESOLVED] How to draw gradient over toolbar?
 Originally Posted by jcis
(Not in answer to your last question) but just in case it could be useful for you, i have a thread in the CodeBank about chaging Toolbar background to any color or using a picture as pattern, here is the link:
http://www.vbforums.com/showthread.php?t=381167
Thanks for replying, but if you notice, i am trying to solve the question i asked in that thread in this thread
-
Sep 17th, 2010, 12:17 PM
#8
Thread Starter
Fanatic Member
Re: [RESOLVED] How to draw gradient over toolbar?
 Originally Posted by LaVolpe
What is #eeead6? Looks like an html color value? If it is then
Code:
Red = CLng("&H" & Mid$("#eeead6",2,2))
Green = CLng("&H" & Mid$("#eeead6",4,2))
Blue= CLng("&H" & Right$("#eeead6",2))
thanks laVolpe. if i have any issues with it, i'll let you know
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
|