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:
  1. Private Type TRIVERTEX
  2.     x As Long
  3.     y As Long
  4.     Red As Integer 'Ushort value
  5.     Green As Integer 'Ushort value
  6.     Blue As Integer 'ushort value
  7.     Alpha As Integer 'ushort
  8. End Type
  9. Private Type GRADIENT_RECT
  10.     UpperLeft As Long  'In reality this is a UNSIGNED Long
  11.     LowerRight As Long 'In reality this is a UNSIGNED Long
  12. End Type
  13.  
  14. Const GRADIENT_FILL_RECT_H As Long = &H0 'In this mode, two endpoints describe a rectangle. The rectangle is
  15. 'defined to have a constant color (specified by the TRIVERTEX structure) for the left and right edges. GDI interpolates
  16. 'the color from the top to bottom edge and fills the interior.
  17. Const GRADIENT_FILL_RECT_V  As Long = &H1 'In this mode, two endpoints describe a rectangle. The rectangle
  18. ' is defined to have a constant color (specified by the TRIVERTEX structure) for the top and bottom edges. GDI interpolates
  19. ' the color from the top to bottom edge and fills the interior.
  20. Const GRADIENT_FILL_TRIANGLE As Long = &H2 'In this mode, an array of TRIVERTEX structures is passed to GDI
  21. 'along with a list of array indexes that describe separate triangles. GDI performs linear interpolation between triangle vertices
  22. '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.
  23. Const GRADIENT_FILL_OP_FLAG As Long = &HFF
  24.  
  25. 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
  26. Private Function LongToUShort(Unsigned As Long) As Integer
  27.     'A small function to convert from long to unsigned short
  28.     LongToUShort = CInt(Unsigned - &H10000)
  29. End Function
  30. Private Sub Form_Load()
  31.     'KPD-Team 1999
  32.     'URL: [url]http://www.allapi.net/[/url]
  33.     'E-Mail: [email][email protected][/email]
  34.     'API uses pixels
  35.     Me.ScaleMode = vbPixels
  36. End Sub
  37. Private Sub Form_Paint()
  38.     Dim vert(1) As TRIVERTEX
  39.     Dim gRect As GRADIENT_RECT
  40.  
  41.     'from black
  42.     With vert(0)
  43.         .x = 0
  44.         .y = 0
  45.         .Red = 0&
  46.         .Green = 0& '&HFF&   '0&
  47.         .Blue = 0&
  48.         .Alpha = 0&
  49.     End With
  50.  
  51.     'to blue
  52.     With vert(1)
  53.         .x = Me.ScaleWidth
  54.         .y = Me.ScaleHeight
  55.         .Red = 0&
  56.         .Green = 0&
  57.         .Blue = LongToUShort(&HFF00&)
  58.         .Alpha = 0&
  59.     End With
  60.  
  61.     gRect.UpperLeft = 0
  62.     gRect.LowerRight = 1
  63.  
  64.  GradientFillRect GetDC(tbMain.hwnd), vert(0), 2, gRect, 1, GRADIENT_FILL_RECT_H
  65. End Sub


Does anybody knows why the code is not working?