本帖最后由 happytc 于 2011-3-20 23:47 编辑
象下面这样子添加上删除绘的外框,就可以了嘛
#include <ProgressConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <BorderConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <ComboConstants.au3>
#include <Constants.au3>
#include <GDIPlus.au3>
#include <WinApi.au3>
#Include <Misc.au3>
Window()
Func Window()
Local $sImgFile
Local $hUser32Dll = DllOpen("user32.dll")
Local $hLast_Control = -1
Local $hWinCtrl = -1
Local $IsCapture = False
Local Const $WH_MOUSE_LL = 14
Local $hKey_Proc = DllCallbackRegister("_Mouse_Handler", "int", "int;ptr;ptr;int")
Local $hModule = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "int", 0)
Local $hHook = DllCall($hUser32Dll, "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hModule[0], "dword", 0)
Local $Frame_Width = 3
Local $hSquare_GUI = -1
While 1
Check_Highlight_Controls_Proc($hSquare_GUI, $hLast_Control)
If _IsPressed("0D", $hUser32Dll) Or _IsPressed("01", $hUser32Dll) Then ;0D ENTER, 01 Primary Key
GUIDeleteSquare($hSquare_GUI)
$hWinCtrl = $hLast_Control
If $hWinCtrl <= 0 Then $hWinCtrl = _Get_Hovered_Handle()
$IsCapture = True
ExitLoop
EndIf
If _IsPressed("1B", $hUser32Dll) Or _IsPressed("02", $hUser32Dll) Then ;1B ESC 键
GUIDeleteSquare($hSquare_GUI)
ExitLoop
EndIf
WEnd
DllCall($hUser32Dll, "int", "UnhookWindowsHookEx", "hwnd", $hHook[0])
DllCallbackFree($hKey_Proc)
DllClose($hUser32Dll)
EndFunc
Func Check_Highlight_Controls_Proc(ByRef $hSquare_GUI, ByRef $hLast_Control)
Local $hWinCtrl = _Get_Hovered_Handle()
If $hWinCtrl <> 0 And $hWinCtrl <> $hLast_Control And $hWinCtrl <> $hSquare_GUI Then
$hLast_Control = $hWinCtrl
Local $aCtrlPos = WinGetPos($hWinCtrl)
If @error Then Return
GUIDeleteSquare($hSquare_GUI)
GUICreateSquare($hSquare_GUI, $aCtrlPos[0], $aCtrlPos[1], $aCtrlPos[2], $aCtrlPos[3], 0xFF0000)
EndIf
EndFunc
Func GUIDeleteSquare(ByRef $hSquare_GUI)
If IsHWnd($hSquare_GUI) Then
GUIDelete($hSquare_GUI)
$hSquare_GUI = -1
EndIf
EndFunc
Func _Get_Hovered_Handle()
Local $aRet = DllCall("user32.dll", "int", "WindowFromPoint", "long", MouseGetPos(0), "long", MouseGetPos(1))
If Not IsArray($aRet) Then Return SetError(1, 0, 0)
Return HWnd($aRet[0])
EndFunc
Func GUICreateSquare(ByRef $hSquare_GUI, $i_X=-1, $i_Y=-1, $i_W=-1, $i_H=-1, $sColor=0x0)
$hSquare_GUI = GUICreate("", $i_W, $i_H, $i_X, $i_Y, $WS_POPUP, $WS_EX_TOPMOST+$WS_EX_TOOLWINDOW)
Local $Frame_Width = 3
GUISetBkColor($sColor)
_GUISetHole($hSquare_GUI, $Frame_Width, $Frame_Width, $i_W - ($Frame_Width * 2), $i_H - ($Frame_Width * 2))
GUISetState(@SW_SHOWNOACTIVATE, $hSquare_GUI)
EndFunc
Func _GUISetHole(ByRef $hWin, $i_X, $i_Y, $i_SizeW, $i_SizeH)
Local $aWinPos, $Outer_Rgn, $Inner_Rgn, $Wh, $Combined_Rgn
Local Const $RGN_DIFF = 4
$aWinPos = WinGetPos($hWin)
$Outer_Rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", $aWinPos[2], "long", $aWinPos[3])
$Inner_Rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $i_Y, "long", $i_Y, "long", $i_Y + $i_SizeW, "long", $i_Y + $i_SizeH)
$Combined_Rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
DllCall("gdi32.dll", "long", "CombineRgn", "long", $Combined_Rgn[0], "long", $Outer_Rgn[0], "long", $Inner_Rgn[0], "int", $RGN_DIFF)
DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWin, "long", $Combined_Rgn[0], "int", 1)
EndFunc
|