找回密码
 加入
搜索
查看: 2463|回复: 0

[网络通信] 使用_GUICtrlListView_Create函数添加背景图片.鼠标事件失效!(解决)

[复制链接]
发表于 2011-7-17 19:11:27 | 显示全部楼层 |阅读模式
本帖最后由 夜猫猫 于 2011-8-3 12:27 编辑

使用_GUICtrlListView_Create函数添加背景图片后,添加鼠标右键.双击全失效.


#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Local $hImage, $hListView


        ; Create GUI
        $gui=GUICreate("ListView测试", 800, 600)
                GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
                



        $hListView = _GUICtrlListView_Create($gui, "", 2, 2, 596, 500, -1, -1, True)
        _GUICtrlListView_SetView($hListView, 1)

                
                

        ; Load images
        $hImage = _GUIImageList_Create(32,32,5,2)
        _GUIImageList_SetIconSize($hImage,32,32)
        _GUIImageList_SetBkColor($hImage,0xffffff)
        _GUIImageList_AddIcon($hImage, @WindowsDir&"\notepad.exe",0,True)  ;读取图标
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 48, 48))
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 48, 48))
        _GUICtrlListView_SetImageList($hListView, $hImage, 0)
                _GUICtrlListView_SetBkImage($hListView, @ScriptDir & "\1.jpg")
        ; Add items
        _GUICtrlListView_AddItem($hListView, "Item 1", 0)
        _GUICtrlListView_AddItem($hListView, "Item 2", 1)
        _GUICtrlListView_AddItem($hListView, "Item 3", 2)

        _GUICtrlListView_SetIconSpacing($hListView, 64, 64)
                
        $contextmenu = GUICtrlCreateContextMenu ($hListView)
        $Run  = GUICtrlCreateMenuitem ("运行",$contextmenu)
                $Runpath  = GUICtrlCreateMenuitem ("目录",$contextmenu)
                $shuxin  = GUICtrlCreateMenuitem ("属性",$contextmenu)
                
                GUISetState()
While 1
         $nMsg = GUIGetMsg()
             Switch $nMsg
                          Case $GUI_EVENT_CLOSE
                   Exit
             EndSwitch                           
WEnd
                
Func WM_Notify_Events($hWndGUI, $MsgID, $WParam, $LParam)

        Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
        Local $tagNMHDR = DllStructCreate("int;int;int", $LParam)
        If @error Then Return $GUI_RUNDEFMSG
        $IDFrom = DllStructGetData($tagNMHDR, 2)
        $Event = DllStructGetData($tagNMHDR, 3)
        $tagNMHDR = 0
        Switch $IDFrom;选择产生事件的控件
           Case $hListView
            Switch $Event; 选择产生的事件
                   Case $NM_CLICK ; 左击
            $Index = _GUICtrlListView_GetSelectedIndices($hListView)
            If Not StringLen($Index) Then; 这里用以判断是否选定了ListViewItem
             Return
            EndIf
           $jy=_GUICtrlListView_GetItemText($hListView, Number($Index),0)
           Case $NM_DBLCLK ; 双击
            MsgBox(0,"","双击鼠标提示")
                                                                                                                
         EndSwitch
     EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc  
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 11:06 , Processed in 0.073947 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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