- Offizieller Beitrag
Hi,
ich habe mal probiert folgendes VB-Bsp.:
Spoiler anzeigen
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: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'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 Me.hdc, vert(0), 2, gRect, 1, GRADIENT_FILL_RECT_H
End Sub
Alles anzeigen
nach AutoIt zu portieren. Leider ohne sichtbaren Erfolg. Der Dll-Call wird zwar ohne Fehler ausgeführt, aber der Return ist immer '0', also Mißerfolg. Hat jemand eine Idee?
Spoiler anzeigen
Global Const $tagTRIVERTEX = 'long x;long y;int Red;int Green;int Blue;int Alpha'
Global Const $tagGRADIENT_RECT = 'ulong UpperLeft;ulong LowerRight'
Global Const $GRADIENT_FILL_RECT_H = 0x0 ;'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.
Global Const $GRADIENT_FILL_RECT_V = 0x1 ;'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.
Global Const $GRADIENT_FILL_TRIANGLE = 0x2 ;'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.
Global Const $GRADIENT_FILL_OP_FLAG = 0xFF
Func GradientFillRect($hdc, $pTRIVERTEX, $dwNumVertex, ByRef $tGRADIENT_RECT, $dwNumMesh, $dwMode)
Local $ret = DllCall("msimg32", 'long', "GradientFill", 'long', $hdc, 'ptr', $pTRIVERTEX, _
'long', $dwNumVertex, 'ptr', $tGRADIENT_RECT, 'long', $dwNumMesh, 'long', $dwMode)
If @error > 0 Then Return SetError(1,@error,-1)
Return $ret[0] ; True or False
EndFunc
Func LongToUShort($Unsigned)
Return Int($Unsigned - 0x10000)
EndFunc
Form_Paint()
[/autoit] [autoit][/autoit] [autoit]Func Form_Paint()
Local $width = 400, $height = 300
Local $gui = GUICreate('Test', $width, $height)
Local $vert0 = DllStructCreate($tagTRIVERTEX)
Local $vert1 = DllStructCreate($tagTRIVERTEX)
Local $vert = DllStructCreate('ptr[2]')
DllStructSetData($vert, 1, DllStructGetPtr($vert0), 1)
DllStructSetData($vert, 1, DllStructGetPtr($vert1), 2)
Local $gRect = DllStructCreate($tagGRADIENT_RECT)
[/autoit] [autoit][/autoit] [autoit];~ 'from black
DllStructSetData($vert0, 'x', 0)
DllStructSetData($vert0, 'y', 0)
DllStructSetData($vert0, 'Red', 0)
DllStructSetData($vert0, 'Green', 0xFF)
DllStructSetData($vert0, 'Blue', 0)
DllStructSetData($vert0, 'Alpha', 0)
;~ 'to blue
DllStructSetData($vert1, 'x', $width)
DllStructSetData($vert1, 'y', $height)
DllStructSetData($vert1, 'Red', 0)
DllStructSetData($vert1, 'Green', 0)
DllStructSetData($vert1, 'Blue', LongToUShort(0xFF00))
DllStructSetData($vert1, 'Alpha', 0)
DllStructSetData($gRect, 'UpperLeft', 0)
DllStructSetData($gRect, 'LowerRight', 1)
GUISetState()
Local $ret = GradientFillRect(WinGetHandle($gui), $vert, 2, $gRect, 1, $GRADIENT_FILL_RECT_H)
ConsoleWrite($ret & ' @err: ' & @error & @CRLF)
[/autoit] [autoit][/autoit] [autoit]Do
Until GUIGetMsg() = -3
EndFunc