life999 发表于 2025-2-8 23:45:59

新手学习AU3疑问,关于GUICtrlCreateTreeViewItem函数,读取状态的变化值

为什么经历过GUISetState()函数,GUICtrlRead($generalitem)的值从1536变成了1792呢?
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
GUICreate('GUI')
$TreeView1=GUICtrlCreateTreeView(10,10,100,200)

$generalitem=GUICtrlCreateTreeViewItem('学习资料',$TreeView1)

GUICtrlCreateTreeViewItem('语文',$generalitem)

GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON))

MsgBox(0,0,BitOR($GUI_EXPAND, $GUI_DEFBUTTON))

MsgBox(0,0,GUICtrlRead($generalitem))

GUISetState()

MsgBox(0,0,GUICtrlRead($generalitem))

While 1

wend


afan 发表于 2025-2-9 12:01:45

多了256,是激活值+显示值。GUISetState 窗口显示了,且有了激活状态。

life999 发表于 2025-2-9 18:39:33

afan 发表于 2025-2-9 12:01
多了256,是激活值+显示值。GUISetState 窗口显示了,且有了激活状态。

感谢回复,好像就是多了一个$GUI_FOCUS,这个值为256.帮忙看看这个代码 为什么 MsgBox(0,0,GUICtrlRead($generalitem))值为1280
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
GUICreate('GUI')
$TreeView1=GUICtrlCreateTreeView(10,10,100,200)
$generalitem=GUICtrlCreateTreeViewItem('学习资料',$TreeView1)

GUICtrlCreateTreeViewItem('语文',$generalitem)

GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON))

MsgBox(0,0,BitOR($GUI_EXPAND, $GUI_DEFBUTTON));---------------------1536

MsgBox(0,0,GUICtrlRead($generalitem));---------------------1536

GUICtrlSetState($generalitem,$GUI_FOCUS)

MsgBox(0,0,GUICtrlRead($generalitem));---------------------1280

GUISetState()


While 1

wend



afan 发表于 2025-2-9 19:21:13

life999 发表于 2025-2-9 18:39
感谢回复,好像就是多了一个$GUI_FOCUS,这个值为256.帮忙看看这个代码 为什么 MsgBox(0,0,GUICtrlRead($ ...

是的,激活加显示就是焦点。研究这些干啥?没什么意义……

life999 发表于 2025-2-9 19:41:38

afan 发表于 2025-2-9 19:21
是的,激活加显示就是焦点。研究这些干啥?没什么意义……

我重启设置了状态值,感觉应该是256呀,为什么是1280。就是有点想不通
GUICtrlSetState($generalitem,$GUI_FOCUS)

MsgBox(0,0,GUICtrlRead($generalitem));---------------------1280

afan 发表于 2025-2-9 20:26:25

life999 发表于 2025-2-9 19:41
我重启设置了状态值,感觉应该是256呀,为什么是1280。就是有点想不通
GUICtrlSetState($generalitem,$GU ...

GUICtrlSetState($generalitem,$GUI_FOCUS) 这样仅设置了焦点,原有的 $GUI_DEFBUTTON 状态就没了。GUICtrlRead 获取的树项目包含很多信息,不光只有$GUI_FOCUS的256,$GUI_DEFBUTTON是512,所以少了256。
研究这些没什么意义,如果是需要获取某状态通常用 BitAND

life999 发表于 2025-2-11 12:27:39

afan 发表于 2025-2-9 20:26
GUICtrlSetState($generalitem,$GUI_FOCUS) 这样仅设置了焦点,原有的 $GUI_DEFBUTTON 状态就没了。GUICt ...

感谢回复,BitAND这个好像是+if判断是否是某一状态用的吧。。需要获取某状态,通常用 BitAND 可以举个例子吗。。

afan 发表于 2025-2-12 15:22:18

Const $GUI_DEFBUTTON = 512, $GUI_FOCUS = 256

Local $vCs = 1536
If BitAND($vCs, $GUI_DEFBUTTON) Then MsgBox(0, $vCs, '有 GUI_DEFBUTTON')
If BitAND($vCs, $GUI_FOCUS) Then MsgBox(0, $vCs, '有 GUI_FOCUS')

Dim $vCs = 1280
If BitAND($vCs, $GUI_DEFBUTTON) Then MsgBox(0, $vCs, '有 GUI_DEFBUTTON')
If BitAND($vCs, $GUI_FOCUS) Then MsgBox(0, $vCs, '有 GUI_FOCUS')

life999 发表于 2025-2-13 19:08:44

afan 发表于 2025-2-12 15:22


好的。。学习了
页: [1]
查看完整版本: 新手学习AU3疑问,关于GUICtrlCreateTreeViewItem函数,读取状态的变化值