找回密码
 加入
搜索
楼主: 网络小僧

[系统综合] 求方法去除Combo右边的三角块区域

 火... [复制链接]
 楼主| 发表于 2011-12-2 15:17:08 | 显示全部楼层
没人可以完美解决这个问题吗???
发表于 2011-12-2 16:12:41 | 显示全部楼层
没有下拉按钮的,是LISTVIEW吧,不怎么用这些,没记住
发表于 2011-12-2 16:45:05 | 显示全部楼层
本帖最后由 netegg 于 2011-12-2 16:47 编辑

回复 17# 网络小僧

只有afan那个方法了,重新看了看combo的结构,没别的方法,如果创建combo必然带着下拉按键
发表于 2011-12-18 12:53:13 | 显示全部楼层
好方法,谢谢共享
发表于 2011-12-18 13:38:20 | 显示全部楼层
lz这个不应该用combo做,用listbox做,显示的时候只显示一行数据(单位高度),点击按钮,显示全部listbox(全高)
发表于 2011-12-18 13:45:22 | 显示全部楼层
本帖最后由 netegg 于 2011-12-19 05:55 编辑

[au3]#AutoIt3Wrapper_au3check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIListBox.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <winapi.au3>

Opt('MustDeclareVars', 1)

$Debug_LB = False ; 检查传递给函数的类名, 设置为真并使用另一控件的句柄观察其工作

Global $hListBox, $edit, $msg

_Main()

Func _Main()
        Local $hGUI, $button, $iflag = True

        ; 创建界面
        $hGUI = GUICreate("(UDF Created) List Box Create", 400, 400)
        $hListBox = _GUICtrlListBox_Create($hGUI, "String upon creation", 2, 2, 396, 30, $LBS_NOREDRAW)
        $button = GUICtrlCreateButton("", 2, 100, 50, 20)
        GUISetState()
        _GUICtrlListBox_BeginUpdate($hListBox)
        _GUICtrlListBox_ResetContent($hListBox)
        _GUICtrlListBox_InitStorage($hListBox, 100, 4096)
        _GUICtrlListBox_Dir($hListBox, @WindowsDir & "\win*.exe")
        _GUICtrlListBox_AddFile($hListBox, @WindowsDir & "\Notepad.exe")
        _GUICtrlListBox_Dir($hListBox, "", $DDL_DRIVES)
        _GUICtrlListBox_Dir($hListBox, "", $DDL_DRIVES, False)
        _GUICtrlListBox_EndUpdate($hListBox)
        While 1
                If GUIGetMsg() = $button Then
                        If $iflag Then
                                _WinAPI_MoveWindow($hListBox, 2, 2, 396, 60) ;60是弹出框的高度,自定
                                $iflag = Not $iflag
                        Else
                                _GUICtrlListBox_SetTopIndex($hListBox, _GUICtrlListBox_GetCurSel($hListBox))
                                _WinAPI_MoveWindow($hListBox, 2, 2, 396, 24)
                                ;24是默认一个项目的高度,最好别改,或者在前面用getitemheight获取下
                                ;确保收回的时候显示且仅显示一行完整数据
                                ;另外,movewindow中的四个坐标可用getwindowsplacement获取
                                $iflag = Not $iflag
                        EndIf
                EndIf
                If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
        WEnd
        GUIDelete()
EndFunc   ;==>_Main
[/au3]
这段代码仅供参考

对了,有个问题没想出来,下方列表框如何显示滑动条似乎不太容易,再想想吧
还有,用edit+list也能实现,就是麻烦的多
发表于 2011-12-29 15:49:34 | 显示全部楼层
进来学习一下了,谢谢
发表于 2012-1-1 04:07:19 | 显示全部楼层
回复  网络小僧

只有afan那个方法了,重新看了看combo的结构,没别的方法,如果创建combo必然带着下拉按键
netegg 发表于 2011-12-2 16:45


守夜到现在了,斗了一晚上地主,现在太兴奋了,一点睡意都没有,现在上来看看论坛有没有有点意思的问题,结果看到了这个问题还不错,远比那些‘看起来’就象干坏事的(如:如何欺骗;读取别的程序内存……)好点。

楼主既然要这种效果,可以连那个Button都不需要,直接点鼠标,就出来象Combo那样的下拉菜单,看看下面的代码效果,是不是合乎楼主的“完美解决”

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>

Global $hGui, $hProcA, $hProcB, $cInput, $cMenu, $aItem[10], $cRevItem

VoidMain()


Func VoidMain()
        Local $cDummy
        Opt("GUIOnEventMode", 1)

        $hGui = GUICreate("PseuCombo Test", 400, 300)
        GUISetOnEvent($GUI_EVENT_CLOSE, "SysEvent")
        
        $cInput = GUICtrlCreateInput("Hit me strongly", 100, 100, 200, 20, $ES_CENTER + $ES_READONLY)
        $cDummy = GUICtrlCreateDummy()
        $cMenu = GUICtrlCreateContextMenu($cDummy)
        For $i = 0 To UBound($aItem) - 1
                $aItem[$i] = GUICtrlCreateMenuItem("Value" & $i + 1, $cMenu)
        Next
        
        $hProcA = DllCallbackRegister("WindowProc", "ptr", "hwnd;uint;long;ptr")
        $hProcB = _WinAPI_SetWindowLong(GUICtrlGetHandle($cInput), $GWL_WNDPROC, DllCallbackGetPtr($hProcA))
        
        GUISetState(@SW_SHOW, $hGui)        
        
        While True
                Sleep(10)
        WEnd
        
EndFunc


Func ShowContextMenu($hWnd, $cCtrlID)
        Local $WinPos[2], $hMenu, $Return        
        
        $WinPos = WinGetPos($hGui)
        $hMenu = GUICtrlGetHandle($cCtrlID)
        $Return = DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0x0100, "int", $WinPos[0] + 200, "int", $WinPos[1] + 140, "hwnd", $hWnd, "ptr", 0)
        
        Return $Return[0]
EndFunc


Func SysEvent()
        Switch @GUI_CtrlId
                Case $GUI_EVENT_CLOSE
                        GUIDelete($hGui)
                        Exit
        EndSwitch
EndFunc


Func WindowProc($hWnd, $iMsg, $wParam, $lParam)
        Switch $iMsg
                Case $WM_RBUTTONDOWN, $WM_CONTEXTMENU
                        If $hWnd = GUICtrlGetHandle($cInput) Then
                                $cRevItem = ShowContextMenu($hGui, $cMenu)
                                For $i = 0 To UBound($aItem) - 1
                                        If $cRevItem = $aItem[$i] Then
                                                GUICtrlSetData($cInput, "Value" & $i + 1)
                                                ExitLoop
                                        EndIf
                                Next
                                Return 0
                        EndIf
                Case $WM_LBUTTONDOWN
                        If $hWnd = GUICtrlGetHandle($cInput) Then
                                $cRevItem = ShowContextMenu($hGui, $cMenu)
                                For $i = 0 To UBound($aItem) - 1
                                        If $cRevItem = $aItem[$i] Then
                                                GUICtrlSetData($cInput, "Value" & $i + 1)
                                                ExitLoop
                                        EndIf
                                Next
                        EndIf
        EndSwitch

        Return _WinAPI_CallWindowProc($hProcB, $hWnd, $iMsg, $wParam, $lParam)
EndFunc


发表于 2012-1-1 08:52:07 | 显示全部楼层
直接找个控件覆盖看不到三角不就行了
发表于 2012-1-1 09:35:58 | 显示全部楼层
回复 25# augual


    你想象了,效果不会很好的,会漏陷的
发表于 2012-1-1 10:22:24 | 显示全部楼层
回复 24# happytc


    这个方法不错。但点击窗体的关闭按钮时也会触发$WM_LBUTTONDOWN,也会显示菜单的。
发表于 2012-1-1 11:45:03 | 显示全部楼层

标题

回复 27# xiehuahere
忘了这个了,呵,解决这个问题简单啊:用opt设置点击的在窗体客户区域就可以了
发表于 2012-1-1 16:17:30 | 显示全部楼层
呵呵,这些朋友越来越可爱了!!
发表于 2012-1-8 10:08:52 | 显示全部楼层
感谢分享,试试看
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 19:27 , Processed in 0.071062 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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