pili 发表于 2012-1-3 22:39:09

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

#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;short g;short b")
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)

80ren 发表于 2012-1-4 09:04:15

gdi 白痴 全部看不懂

netegg 发表于 2012-1-4 17:40:32

_WinAPI_GetWindowInfo
_GDIPlus_BrushCreateSolid
_GDIPlus_GraphicsFillRectangles
不过是gdi++

pili 发表于 2012-1-4 22:05:53

回复 3# netegg


    是的 我就是不太懂api 函数的调用,能否帮忙大体解释下,谢谢

netegg 发表于 2012-1-5 05:51:49

回复 4# pili
先看看帮助再说

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)

pili 发表于 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 执行失败
请帮忙看看

netegg 发表于 2012-1-8 13:12:38

获取句柄后,找出按钮的矩形范围,gdi填充,如果有文字,gdi画上去
页: [1]
查看完整版本: 用GUICtrlGetHandle 得到 GUIBUTTON句柄后如何用gdi32着色