找回密码
 加入
搜索
查看: 3819|回复: 7

[图形处理] 用GUICtrlGetHandle 得到 GUIBUTTON句柄后如何用gdi32着色

  [复制链接]
发表于 2012-1-3 22:39:09 | 显示全部楼层 |阅读模式
#include <GUIConstantsEx.au3>
$locationx=@DesktopWidth-330
$mon=GUICreate("TEST MONITOR",320,200,$locationx,0)
$setinfowin=GUICtrlCreateButton("setinfo",0,0,80,40)
GUISetState(@SW_SHOW,$mon)
WinActivate("TEST MONITOR")
$setinfobutton = GUICtrlGetHandle($setinfowin)
MsgBox(0,"setinfobutton is",$setinfobutton)
sleep(2000)
$tBuffer = DllStructCreate("short r[256];short g[256];short b[256]")
DllStructSetData($tBuffer, "r", 99)
DllStructSetData($tBuffer, "g", 66)
DllStructSetData($tBuffer, "b",99)
$iResult = DllCall("Gdi32.dll", "int", "SetDeviceGammaRamp", "hWnd", $setinfobutton, "ptr", DllStructGetPtr($tBuffer))
;SetMenuColor($setinfobutton, 0x99BBEE)
Sleep(20000)
发表于 2012-1-4 09:04:15 | 显示全部楼层
gdi 白痴 全部看不懂
发表于 2012-1-4 17:40:32 | 显示全部楼层
_WinAPI_GetWindowInfo
_GDIPlus_BrushCreateSolid
_GDIPlus_GraphicsFillRectangles
不过是gdi++
 楼主| 发表于 2012-1-4 22:05:53 | 显示全部楼层
回复 3# netegg


    是的 我就是不太懂api 函数的调用,能否帮忙大体解释下,谢谢
发表于 2012-1-5 05:51:49 | 显示全部楼层
回复 4# pili
先看看帮助再说
 楼主| 发表于 2012-1-8 12:09:35 | 显示全部楼层
回复 5# netegg


   我找到一个winpi函数,_WINAPI_SETBKCOLOR($handle,$ncolor)但是 用guictrlgethandle得到的句柄仍然无法变色。
#include <WinAPI.au3>
$locationx=@DesktopWidth-330
$mon=GUICreate("TEST MONITOR",320,200,$locationx,0)
$setinfowin=GUICtrlCreateButton("setinfo",0,0,80,40)
GUISetState(@SW_SHOW,$mon)
WinActivate("TEST MONITOR")
;$hsetinfobutton = ControlGetHandle($setinfowin)
$hsetinfobutton = GUICtrlGetHandle($setinfowin)
If IsHWnd($hsetinfobutton) Then
    MsgBox(4096, "", "&Ecirc;&Ccedil;&Oacute;&ETH;&ETH;§&frac34;&auml;±ú")
Else
    MsgBox(4096, "", "&sup2;&raquo;&Ecirc;&Ccedil;&frac34;&auml;±ú")
EndIf
;MsgBox(0,"setinfobutton is",$hsetinfobutton)
sleep(2000)
$h=_WinAPI_SetBkColor($hsetinfobutton, 0x00ff00)
MsgBox(0,"setinfobutton is",$h)

Sleep(20000)
 楼主| 发表于 2012-1-8 12:11:23 | 显示全部楼层

RE: 用GUICtrlGetHandle 得到 GUIBUTTON句柄后如何用gdi32着色

回复 5# netegg


   我找到一个winpi函数,_WINAPI_SETBKCOLOR($handle,$ncolor)但是 用guictrlgethandle得到的句柄仍然无法变色。
#include <WinAPI.au3>
$locationx=@DesktopWidth-330
$mon=GUICreate("TEST MONITOR",320,200,$locationx,0)
$setinfowin=GUICtrlCreateButton("setinfo",0,0,80,40)
GUISetState(@SW_SHOW,$mon)
WinActivate("TEST MONITOR")
;$hsetinfobutton = ControlGetHandle($setinfowin)
$hsetinfobutton = GUICtrlGetHandle($setinfowin)
If IsHWnd($hsetinfobutton) Then
    MsgBox(4096, "", "有效句柄")
Else
    MsgBox(4096, "", "无效句柄")
EndIf
;MsgBox(0,"setinfobutton is",$hsetinfobutton)
sleep(2000)
$h=_WinAPI_SetBkColor($hsetinfobutton, 0x00ff00)
MsgBox(0,"setinfobutton is",$h)

Sleep(20000)

返回值为-1 执行失败
请帮忙看看
发表于 2012-1-8 13:12:38 | 显示全部楼层
获取句柄后,找出按钮的矩形范围,gdi填充,如果有文字,gdi画上去
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-7 01:26 , Processed in 0.077405 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表