在ListView滚动显示未显示完的Label,谢谢!
#include <StaticConstants.au3>#include <WindowsConstants.au3>
#include <GuiConstants.au3>
$Gui = GUICreate("test", 500, 550)
Dim $Label
$h = 30
$s = 30
For $i = 1 To 255
$Label[$i] = GUICtrlCreateLabel($i, $h, $s, 30, 20, $WS_BORDER)
GUICtrlSetBkColor(-1, 0xA6CAF0)
$h = $h + 40
If $h > 450 Then
$h = 30
$s = $s + 30
EndIf
Next
$hListView = GUICtrlCreateListView("", 10, 0, 470, 550)
$DummyMenu = GUICtrlCreateDummy()
$ContextMenu = GUICtrlCreateContextMenu($DummyMenu)
$MenuItem1 = GUICtrlCreateMenuItem("菜单1", $ContextMenu)
$MenuItem2 = GUICtrlCreateMenuItem("菜单2", $ContextMenu)
GUICtrlCreateMenuItem("", $ContextMenu)
$ExitMenuItem = GUICtrlCreateMenuItem("退出", $ContextMenu)
GUISetState()
While 1
$CurInfo = GUIGetCursorInfo($Gui)
$Msg = GUIGetMsg()
Select
Case $Msg = -3
Exit
Case $CurInfo = 1 And $CurInfo = $Label
ShowMenu($Gui, $ContextMenu)
Case $CurInfo = 1 And $CurInfo = $Label
ShowMenu($Gui, $ContextMenu)
Case $CurInfo = 1 And $CurInfo = $Label
ShowMenu($Gui, $ContextMenu)
Case $Msg = $ExitMenuItem
Exit
Case $Msg =$MenuItem1
MsgBox(0,0,GUICtrlRead($Label))
EndSelect
WEnd
; Show a menu in a given GUI window which belongs to a given GUI ctrl
Func ShowMenu($hWnd, $nContextID)
Local $hMenu = GUICtrlGetHandle($nContextID)
$arPos = MouseGetPos()
Local $x = $arPos
Local $y = $arPos
DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc ;==>ShowMenu
Func _exit()
Exit
EndFunc ;==>_exit
还有一个问题,如何循环所有Label的右键功能,二个问题。谢谢帮忙!
页:
[1]