AHK调用系统颜色对话框函数

 贴一个 AHK 调用系统颜色对话框的函数 Dlg_Color:

Dlg_Color(ByRef Color, hGui=0)    ;调用系统颜色对话框
{
    clr := ((Color & 0xFF) << 16) + (Color & 0xFF00) + ((Color >> 16) & 0xFF)
    VarSetCapacity(CHOOSECOLOR, 0x24, 0), VarSetCapacity(CUSTOM, 64, 0)
    ,NumPut(0x24,        CHOOSECOLOR, 0)    ; DWORD lStructSize 
    ,NumPut(hGui,        CHOOSECOLOR, 4)    ; HWND hwndOwner (makes dialog "modal"). 
    ,NumPut(clr,        CHOOSECOLOR, 12)    ; clr.rgbResult 
    ,NumPut(&CUSTOM,    CHOOSECOLOR, 16)    ; COLORREF *lpCustColors
    ,NumPut(0x00000103,CHOOSECOLOR, 20)    ; Flag: CC_ANYCOLOR || CC_RGBINIT 

    nRC := DllCall("comdlg32\ChooseColorA", str, CHOOSECOLOR)  ; Display the dialog. 
    if (errorlevel <> 0) || (nRC = 0) 
        return  false 
    clr := NumGet(CHOOSECOLOR, 12) 
    oldFormat := A_FormatInteger 
    SetFormat, integer, hex    ; Show RGB color extracted below in hex format. 

    Color := (clr & 0xff00) + ((clr & 0xff0000) >> 16) + ((clr & 0xff) << 16)    ;convert to rgb 
    StringTrimLeft, Color, Color, 2 
    loop, % 6-strlen(Color) 
        Color=0%Color% 
    Color=%Color% 
    SetFormat, integer, %oldFormat% 
    return true
}

注意:

  1. 该函数的参数 Color 为 ByRef  类型。否则,可以用 Return 返回选定的颜色。
  2. 参数 hGui 为调用该函数的窗口ID。

转载于:https://www.cnblogs.com/easysky/p/3472104.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值