我寫了以下的程式:
Private Declare Function CreatePalette Lib "gdi32" (lpLogPalette As LOGPALETTE) As Long
Private Declare Function AnimatePalette Lib "gdi32" Alias "AnimatePaletteA" (ByVal hPalette As Long, ByVal wStartIndex As Long, ByVal wNumEntries As Long, lpPaletteColors As PALETTEENTRY) As Long
Private Declare Function SelectPalette Lib "gdi32" (ByVal hdc As Long, ByVal hPalette As Long, ByVal bForceBackground As Long) As Long
Private Declare Function RealizePalette Lib "gdi32" (ByVal hdc As Long) As Long
Private Type PALETTEENTRY
peRed As Byte
peGreen As Byte
peBlue As Byte
peFlags As Byte
End Type
Private Type LOGPALETTE
palVersion As Integer
palNumEntries As Integer
palPalEntry(255) As PALETTEENTRY
End Type
Const PC_RESERVED = &H1 ' palette index used for animation
Private Sub Command1_Click()
Dim hPAL As Long
Dim PAL As LOGPALETTE
Dim a As Long
Dim LPTemp As LOGPALETTE
PAL.palVersion = &H300
PAL.palNumEntries = 1
For b = 0 To 255
PAL.palPalEntry(b).peRed = 255 - b
PAL.palPalEntry(b).peGreen = 255 - b
PAL.palPalEntry(b).peBlue = 255 - b
PAL.palPalEntry(b).peFlags = PC_RESERVED
Next
hPAL = CreatePalette(PAL)
a = SelectPalette(Picture1.hdc, hPAL, False)
a = RealizePalette(Picture1.hdc)
Text1.Text = a
End Sub
結果A=0
究竟這個是甚麼意思呢??