找回密码
 加入
搜索
查看: 4505|回复: 6

[GUI管理] 请问如何消除控件的边缘虚线[已解决]

  [复制链接]
发表于 2011-5-6 17:56:44 | 显示全部楼层 |阅读模式
本帖最后由 飘云 于 2011-5-7 00:57 编辑



如图,就是滑块控件在鼠标点击它后,即焦点到它上面后,边缘出现的黑色虚线,这线在焦点消失后就没了,比如鼠标点一下界面的其它地方,但是我希望一直没这虚线框框,请问有什么方法不?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-5-6 18:45:37 | 显示全部楼层
#include <Thread.au3>

$bBinary = Binary("0x33C0C20800CCCCCC")
$pDrawFocusRect = _RTGetProcAddress("User32.dll", "DrawFocusRect")
$tBinary = DllStructCreate("ubyte Code[8]", $pDrawFocusRect)

_RTVirtualProtect($pDrawFocusRect, 8)
DllStructSetData($tBinary, "Code", $bBinary)
 楼主| 发表于 2011-5-7 00:57:35 | 显示全部楼层
版主们都是牛人,这都可以,太给力了,虽然有点不太明白的说,为啥把这串2进制值传入绘制焦点矩形的数据结构中就没有那矩形了呢。。。。深奥啊~~~
发表于 2011-5-7 01:54:22 | 显示全部楼层
回复 3# 飘云


    帮助文件中解释DllStruct*函数都是与数据结构有关的。其实这些与数据结构有关的函数,它们真正的用途是用来读取、修改内存数据的。2#的代码实际是修改了User32.dll中的DrawFocusRect函数,调用后 此函数将直接返回,并不会执行绘制虚线框的操作。
发表于 2011-5-7 09:28:55 | 显示全部楼层
不容易理解 ?
发表于 2011-5-7 10:13:45 | 显示全部楼层
高手太多了,我这只菜鸟不知道什么时候才能赶上,真是惭愧啊。
发表于 2011-5-7 10:27:46 | 显示全部楼层
#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[2], $aPos[3], $hMemDC, $aPos[0], $aPos[1], $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[2], $aPos[3])
                                        $hPrev = _WinAPI_SelectObject($hMemDC, $hTemp)
                                        _WinAPI_BitBlt($hMemDC, 0, 0, $aPos[2], $aPos[3], $hDC, 0, 0, $MERGECOPY)
                                    Else
                                        $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
                                        $hPrev = _WinAPI_SelectObject($hMemDC, $hTemp)
                                        _WinAPI_BitBlt($hDC, 0, 0, $aPos[2], $aPos[3], $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金钱 +30 贡献 +3 收起 理由
pusofalse + 30 + 3 学习了。

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-8 21:31 , Processed in 0.075899 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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