|
本帖最后由 cashiba 于 2017-2-6 20:18 编辑 #include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <WindowsConstants.au3>
Example()
Func Example()
Local $hGUI, $idCOLORREF, $idBGR, $idRGB, $idMemo
$hGUI = GUICreate("创建颜色选择对话框", 400, 300)
$idMemo = GUICtrlCreateEdit("", 2, 55, 396, 200, BitOR($WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont($idMemo, 10, 400, 0, "Courier New")
$idCOLORREF = GUICtrlCreateButton("COLORREF", 70, 10, 80, 40)
$idBGR = GUICtrlCreateButton("BGR", 160, 10, 80, 40)
$idRGB = GUICtrlCreateButton("RGB", 250, 10, 80, 40)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idCOLORREF
_ShowChoice($hGUI, $idMemo, 0, _ChooseColor(0, 255, 0, $hGUI), "选择的 COLORREF 颜色值为: ")
Case $idBGR
_ShowChoice($hGUI, $idMemo, 1, _ChooseColor(2, 0x808000, 1, $hGUI), "选择的 BGR 十六进制颜色值为: ")
Case $idRGB
_ShowChoice($hGUI, $idMemo, 2, _ChooseColor(2, 0x0080C0, 2, $hGUI), "选择的 RGB 十六进制颜色值为: ")
EndSwitch
WEnd
EndFunc ;==>Example
Func _ShowChoice($hGUI, $idMemo, $iType, $iChoose, $sMessage)
Local $sCr
If $iChoose <> -1 Then
If $iType = 0 Then ; 此示例将 COLORREF 转换为 RGB
$sCr = Hex($iChoose, 6)
GUISetBkColor('0x' & StringMid($sCr, 5, 2) & StringMid($sCr, 3, 2) & StringMid($sCr, 1, 2), $hGUI)
Else
GUISetBkColor($iChoose, $hGUI)
EndIf
GUICtrlSetData($idMemo, $sMessage & $iChoose & @CRLF, 1)
Else
GUICtrlSetData($idMemo, "用户取消选择" & @CRLF, 1)
EndIf
EndFunc ;==>_ShowChoice
这段示例是不是有点问题....
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idCOLORREF
_ShowChoice($hGUI, $idMemo, 0, _ChooseColor(0, 255, 0, $hGUI), "选择的 COLORREF 颜色值为: ")
Case $idBGR
_ShowChoice($hGUI, $idMemo, 1, _ChooseColor(2, 0x808000, 1, $hGUI), "选择的 BGR 十六进制颜色值为: ")
Case $idRGB
_ShowChoice($hGUI, $idMemo, 2, _ChooseColor(2, 0x0080C0, 2, $hGUI), "选择的 RGB 十六进制颜色值为: ")
EndSwitch
WEnd
上面的红色数字是不是原本应该为1?
另外:
1、话说BGR这种形式的颜色值倒地有何用处?
2、函数_ChooseColor ( [返回颜色类型 = 0 [, 默认选中颜色= 0 [, 默认选中颜色类型= 0 [,对话框的父窗口句柄= 0]]]] )中
为啥要加一个"默认选中颜色类型"这个参数?对结果有影响吗?
3、_ShowChoice感觉有点绕....
|
|