请问如何消除控件的边缘虚线[已解决]
本帖最后由 飘云 于 2011-5-7 00:57 编辑如图,就是滑块控件在鼠标点击它后,即焦点到它上面后,边缘出现的黑色虚线,这线在焦点消失后就没了,比如鼠标点一下界面的其它地方,但是我希望一直没这虚线框框,请问有什么方法不? #include <Thread.au3>
$bBinary = Binary("0x33C0C20800CCCCCC")
$pDrawFocusRect = _RTGetProcAddress("User32.dll", "DrawFocusRect")
$tBinary = DllStructCreate("ubyte Code", $pDrawFocusRect)
_RTVirtualProtect($pDrawFocusRect, 8)
DllStructSetData($tBinary, "Code", $bBinary) 版主们都是牛人,这都可以,太给力了,虽然有点不太明白的说,为啥把这串2进制值传入绘制焦点矩形的数据结构中就没有那矩形了呢。。。。深奥啊~~~ 回复 3# 飘云
帮助文件中解释DllStruct*函数都是与数据结构有关的。其实这些与数据结构有关的函数,它们真正的用途是用来读取、修改内存数据的。2#的代码实际是修改了User32.dll中的DrawFocusRect函数,调用后 此函数将直接返回,并不会执行绘制虚线框的操作。 不容易理解 ? 高手太多了,我这只菜鸟不知道什么时候才能赶上,真是惭愧啊。 #Include <Constants.au3>
#Include <GUIConstantsEx.au3>
#Include <SliderConstants.au3>
#Include <StaticConstants.au3>
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>
Global Const $tagNMCUSTOMDRAW = 'hwnd hWndFrom;uint_ptr IDFrom;int Code;dword DrawStage;hwnd hDC;' & $tagRECT & ';dword_ptr ItemSpec;uint ItemState;lparam ItemlParam'
Global Const $STM_GETIMAGE = 0x0173
Global $hTemp = 0
GUICreate('MyGUI', 413, 161)
GUICtrlCreatePic(@DesktopDir & '\1.jpg', 0, 0, 413, 161)
GUICtrlSetState(-1, $GUI_DISABLE)
$hPic = GUICtrlGetHandle(-1)
GUICtrlCreateSlider(200, 100, 200, 23, $TBS_NOTICKS)
$hSlider = GUICtrlGetHandle(-1)
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam)
Local $hWndFrom = DllStructGetData($tNMCD, 'hWndFrom')
Local $Code = DllStructGetData($tNMCD, 'Code')
Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage')
Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec')
Local $hDC = DllStructGetData($tNMCD, 'hDC')
Local $hMemDC, $hBitmap, $hPrev
Local $aPos
Switch $hWndFrom
Case $hSlider
Switch $Code
Case $NM_CUSTOMDRAW
Switch $DrawStage
Case $CDDS_PREPAINT, $CDDS_POSTPAINT
$aPos = ControlGetPos($hSlider, '', '')
Switch $DrawStage
Case $CDDS_PREPAINT
$hMemDC = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _SendMessage($hPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0)
$hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap)
_WinAPI_BitBlt($hDC, 0, 0, $aPos, $aPos, $hMemDC, $aPos, $aPos, $SRCCOPY)
_WinAPI_SelectObject($hMemDC, $hPrev)
_WinAPI_DeleteDC($hMemDC)
DllStructSetData($tNMCD, 'ItemState', BitXOR(DllStructGetData($tNMCD, 'ItemState'), $CDIS_FOCUS))
Return BitOR($CDRF_NOTIFYITEMDRAW, $CDRF_NOTIFYPOSTPAINT)
Case $CDDS_POSTPAINT
$hMemDC = _WinAPI_CreateCompatibleDC($hDC)
If Not $hTemp Then
$hTemp = _WinAPI_CreateCompatibleBitmap($hDC, $aPos, $aPos)
$hPrev = _WinAPI_SelectObject($hMemDC, $hTemp)
_WinAPI_BitBlt($hMemDC, 0, 0, $aPos, $aPos, $hDC, 0, 0, $MERGECOPY)
Else
$hMemDC = _WinAPI_CreateCompatibleDC($hDC)
$hPrev = _WinAPI_SelectObject($hMemDC, $hTemp)
_WinAPI_BitBlt($hDC, 0, 0, $aPos, $aPos, $hMemDC, 0, 0, $SRCCOPY)
EndIf
_WinAPI_SelectObject($hMemDC, $hPrev)
_WinAPI_DeleteDC($hMemDC)
Return $CDRF_DODEFAULT
EndSwitch
Case $CDDS_ITEMPREPAINT
If $hTemp Then
_WinAPI_DeleteObject($hTemp)
$hTemp = 0
EndIf
Switch $ItemSpec
Case $TBCD_TICS
Return $CDRF_SKIPDEFAULT
Case $TBCD_THUMB, $TBCD_CHANNEL
Return $CDRF_DODEFAULT
EndSwitch
EndSwitch
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
页:
[1]