GuiGetMsg(1) 返回控件ID问题 [已解决]
本帖最后由 republican 于 2010-8-10 09:07 编辑代码如下:#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Opt("ExpandVarStrings", 1)
Example()
;-------------------------------------------------------------------------------------
; Example - Press the button to see the value of the radio boxes
; The script also detects state changes (closed/minimized/timeouts, etc).
Func Example()
Local $button_1, $group_1, $radio_1, $radio_2, $radio_3
Local $radioval1, $radioval2, $msg,$Formtest,$labe1
Opt("GUICoordMode", 1)
$Formtest = GUICreate("Radio Box Demo", 400, 280)
$button_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40)
$labe1= GUICtrlCreateList($button_1,100,70,200,1000)
GUISetState()
While 1
$msg = GUIGetMsg(1)
If $msg <> 0 And $msg = $Formtest Then ;
GUICtrlSetData($labe1,$msg)
Sleep(50)
Select
Case $msg = $Formtest
Case $msg = $GUI_EVENT_CLOSE
MsgBox(0, "", "Dialog was closed")
Exit
Case $msg = $GUI_EVENT_MINIMIZE
MsgBox(0, "", "Dialog minimized", 2)
Case $msg = $GUI_EVENT_MAXIMIZE
MsgBox(0, "", "Dialog restored", 2)
Case $msg = $button_1
MsgBox(0, "Default button clicked", "Radio " & $radioval1)
EndSelect
EndIf
WEnd
;~ While 1
;~ $msg = GUIGetMsg()
;~ GUICtrlSetData($labe1,$msg&'"'&$button_1);&'"'&$msg)
;~ Select
;~ Case $msg = $GUI_EVENT_CLOSE
;~ MsgBox(0, "", "Dialog was closed")
;~ Exit
;~ Case $msg = $GUI_EVENT_MINIMIZE
;~ MsgBox(0, "", "Dialog minimized", 2)
;~ Case $msg = $GUI_EVENT_MAXIMIZE
;~ MsgBox(0, "", "Dialog restored", 2)
;~ Case $msg = $button_1
;~ MsgBox(0, "Default button clicked", "Radio " & $radioval1)
;~ Case $msg >= $radio_1 And $msg <= $radio_3
;~ $radioval1 = $msg - $radio_1
;~ EndSelect
;~ WEnd
EndFunc ;==>Example注释掉的为原来的正常代码。
3为控件ID,然而GetMsg获得却是不知道什么进制的数(窗口ID能正确获取,0X00000000,应该为没发生任何事的情况),遂请问各位,
如何能在高级模式中使代码正常运行?
PS:搜官方网站以前貌似有个Opt("GUIEventAdvancedMode", 1)参数,现在没了,不知道是不是官方放弃了支持? 顶贴、回帖、拿分走人! 看着有点象句柄,不过为什么为0不太清楚了 顶贴、回帖、拿分、走人!url 自己顶贴~~~ 楼主在研究什么呢?是想这样吗#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Opt("ExpandVarStrings", 1)
Example()
;-------------------------------------------------------------------------------------
; Example - Press the button to see the value of the radio boxes
; The script also detects state changes (closed/minimized/timeouts, etc).
Func Example()
Local $button_1, $group_1, $radio_1, $radio_2, $radio_3
Local $radioval1, $radioval2, $msg, $Formtest, $labe1
Opt("GUICoordMode", 1)
$Formtest = GUICreate("Radio Box Demo", 400, 280)
$button_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40)
$labe1 = GUICtrlCreateList($button_1, 100, 70, 200, 100)
GUISetState()
While 1
$msg = GUIGetMsg(1)
If $msg = $Formtest Then ;
GUICtrlSetData($labe1,$msg)
Sleep(50)
Select
Case $msg = $GUI_EVENT_CLOSE
GUICtrlSetData($labe1, $msg)
MsgBox(0, "", "Dialog was closed")
Exit
Case $msg = $GUI_EVENT_MINIMIZE
GUICtrlSetData($labe1, $msg)
MsgBox(0, "", "Dialog minimized", 2)
Case $msg = $GUI_EVENT_MAXIMIZE
GUICtrlSetData($labe1, $msg)
MsgBox(0, "", "Dialog restored", 2)
Case $msg = $button_1
GUICtrlSetData($labe1, $msg)
MsgBox(0, "Default button clicked", "Radio " & $radioval1)
EndSelect
EndIf
WEnd
EndFunc ;==>Example 理解错误了,不好意思。
谢谢六楼。 本帖最后由 papapa314 于 2011-1-25 02:12 编辑
回复 1# republican
Case $msg = $GUI_EVENT_CLOSE这个好像写错了,事件应该是Case $msg = $GUI_EVENT_CLOSE
看看下面的代码是不是你所需要的?#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Opt("ExpandVarStrings", 1)
Example()
;-------------------------------------------------------------------------------------
; Example - Press the button to see the value of the radio boxes
; The script also detects state changes (closed/minimized/timeouts, etc).
Func Example()
Local $button_1, $group_1, $radio_1, $radio_2, $radio_3
Local $radioval1, $radioval2, $msg,$Formtest,$labe1
Opt("GUICoordMode", 1)
$Formtest = GUICreate("Radio Box Demo", 400, 280)
$button_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40)
$labe1= GUICtrlCreateList($button_1,100,70,200,1000)
GUISetState()
While 1
$msg = GUIGetMsg(1)
Select
Case $msg = $GUI_EVENT_CLOSE And $msg = $Formtest
MsgBox(0, "", "Dialog was closed")
Exit
Case $msg = $GUI_EVENT_MINIMIZE And $msg = $Formtest
MsgBox(0, "", "Dialog minimized", 2)
Case $msg = $GUI_EVENT_MAXIMIZE And $msg = $Formtest
MsgBox(0, "", "Dialog restored", 2)
Case $msg = $button_1 And $msg = $Formtest
MsgBox(0, "Default button clicked", "Radio " & $radioval1)
EndSelect
WEnd
EndFunc 回复 8# papapa314
谢谢~
那是以前写的程序用的,现在改用Windows消息来响应了。 有捕获控件ID的软件吗?
页:
[1]