标题: 如何调用调色板? [打印本页] 作者: msf 时间: 2003-12-21 22:50 标题: 如何调用调色板? 怎样调用系统的颜色选择窗体,并获得其中的颜色编号?作者: cg1 时间: 2003-12-22 02:40
http://www.access911.net/index.asp?board=4&mode=3&recordid=71FAB31E16DC作者: 大頭 时间: 2003-12-22 08:28 标题: 調用调色板的方法 ‘使用win API
Private Type COLORSTRUC
lStructSize As Long
hwnd As Long
hInstance As Long
rgbResult As Long
lpCustColors As String
Flags As Long
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Declare Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" _
(pChoosecolor As COLORSTRUC) As Long
‘調用调色板
Private Sub Command0_Click()
lngBackColor = aDialogColor()
End Sub
‘公用模組
Public Function aDialogColor() As Long
Dim x As Long, CS As COLORSTRUC, CustColor(16) As Long
CS.lStructSize = Len(CS)
CS.hwnd = hWndAccessApp
CS.Flags = CC_SOLIDCOLOR
CS.lpCustColors = String$(16 * 4, 0)
x = ChooseColor(CS)
If x = 0 Then
'發生錯誤時
aDialogColor = RGB(254, 254, 254) ' 白色
Exit Function
Else
'指定顏色
If CS.rgbResult = RGB(255, 255, 255) Then
aDialogColor = RGB(254, 254, 254)
Else
aDialogColor = CS.rgbResult
End If
End If
End Function