关于 系统事件 $GUI_EVENT_DROPPED 的使用 高手请进【已解决】
本帖最后由 cumtljj 于 2011-12-19 10:21 编辑$GUI_EVENT_DROPPED ——结束拖放操作 @GUI_DRAGID, @GUI_DRAGFILE 和 @GUI_DROPID 将返回一个相关的ID,文件通信到相关控件. 这是帮助文档的解释 我理解其功能是:与桌面快捷方式拖放到程序中的释放 有关。帮助文档的例子是:
#include <GUIConstantsEx.au3>
Example()
Func Example()
Opt("GUICoordMode", 2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)
GUICreate("Parent1")
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
GUICtrlCreateButton("OK", 10, 30, 50)
GUICtrlSetOnEvent(-1, "OKPressed")
GUICtrlCreateButton("Cancel", 0, -1)
GUICtrlSetOnEvent(-1, "CancelPressed")
GUISetState(@SW_SHOW)
; Just idle around
While 1
Sleep(10)
WEnd
EndFunc ;==>Example
Func OKPressed()
MsgBox(0, "OK Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)
EndFunc ;==>OKPressed
Func CancelPressed()
MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)
EndFunc ;==>CancelPressed
Func SpecialEvents()
Select
Case @GUI_CtrlId = $GUI_EVENT_CLOSE
MsgBox(0, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
Exit
Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
MsgBox(0, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
Case @GUI_CtrlId = $GUI_EVENT_RESTORE
MsgBox(0, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
EndSelect
EndFunc ;==>SpecialEvents
于是我把$GUI_EVENT_DROPPED 也添加进去了 红色部分代码变成了:#include <GUIConstantsEx.au3>
Example()
Func Example()
Opt("GUICoordMode", 2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)
GUICreate("Parent1")
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_DROPPED , "SpecialEvents")
GUICtrlCreateButton("OK", 10, 30, 50)
GUICtrlSetOnEvent(-1, "OKPressed")
GUICtrlCreateButton("Cancel", 0, -1)
GUICtrlSetOnEvent(-1, "CancelPressed")
GUISetState(@SW_SHOW)
; Just idle around
While 1
Sleep(10)
WEnd
EndFunc ;==>Example
Func OKPressed()
MsgBox(0, "OK Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)
EndFunc ;==>OKPressed
Func CancelPressed()
MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)
EndFunc ;==>CancelPressed
Func SpecialEvents()
Select
Case @GUI_CtrlId = $GUI_EVENT_CLOSE
MsgBox(0, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
Exit
Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
MsgBox(0, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
Case @GUI_CtrlId = $GUI_EVENT_RESTORE
MsgBox(0, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
Case @GUI_CtrlId = $GUI_EVENT_DROPPED
MsgBox(0, "drop", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
EndSelect
EndFunc ;==>SpecialEvents
以为这样 在把桌面图标拖放到窗口上时会弹出提示 但是没效果啊请指点 $GUI_EVENT_DROPPED 到底咋用 你在GUI建立以后还要建立一个控件 大小跟你要拖拽的区域相同 比如label。
Local $App_Path = GUICtrlCreateLabel("", 1, 1, 620, 400)
GUICtrlSetState($App_Path, $GUI_DROPACCEPTED) 好提法,谢谢提醒 回复 2# eaglelin
我加上这句 还是不行啊? 能给个完整的么? 谢谢 回复 2# eaglelin
在帮助文档里搜不到$GUI_DROPACCEPTED啊? 本帖最后由 cumtljj 于 2011-12-18 20:24 编辑
回复 2# eaglelin
按照你说的添加了 $GUI_DROPACCEPTED 啊 可是就是实现不了拖拽功能啊 能给我给例子么?谢谢#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1) ; 开启 Event 模式
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 443, 206, 124)
$Tab1 = GUICtrlCreateTab(0, 0, 617, 441)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUISetOnEvent($GUI_EVENT_DROPPED, "tuofang")
GUISetOnEvent($GUI_EVENT_CLOSE, "end")
While 1
Sleep(30)
WEnd
Func end()
Exit
EndFunc
Func tuofang();拖拽执行的
Local $lujing
$lujing = @GUI_DragFile
MsgBox(0,0,$lujing)
EndFunc ;==>tuofang 回复 2# eaglelin
看看六楼吧 谢谢 回复 7# cumtljj
Gui 需加上扩展样式$Form1 = GUICreate("Form1", 623, 443, 206, 124, -1, 0x00000010) ;$WS_EX_ACCEPTFILES=0x00000010 Opt("GUIOnEventMode", 1) ; 开启 Event 模式
$Form1 = GUICreate("Form1", 623, 443, 206, 124,-1,$WS_EX_ACCEPTFILES)
GUISetOnEvent($GUI_EVENT_DROPPED, "GUI_Drop")
$Tab1 = GUICtrlCreateTab(0, 0, 617, 441)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
.........
funcGUI_Drop
endfunc Opt("GUIOnEventMode", 1) ; 开启 Event 模式
如果不用这个模式
在消息循环里面
case$Msg = $GUI_EVENT_DROPPED {:face (411):}谢谢
页:
[1]