smooth 发表于 2014-2-4 01:20:36

【已解决】请教能否通过一个选择框的选中状态关联到分页标签?

本帖最后由 smooth 于 2014-2-4 14:28 编辑

请教能否通过一个选择框的选中状态关联到分页标签?比如选中选择框A,则分页标签X是选中状态,选中选择框B,则分页标签Y是选中状态,谢谢!

veket_linux 发表于 2014-2-9 13:36:03

请参考Au3 帮助文件DllDllStructCreate创建C/C++ 中的结构体 HWND 、UINT其实就是long 、unsigned int ,学过SDK的都知道
typedef struct tagNMHDR {
    HWND hwndFrom;
    UINT idFrom;
    UINT code;
} NMHDR;


没有64位系统 帮不了你

veket_linux 发表于 2014-2-4 13:20:11


#Include <GuiTab.au3>

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 473, 351, 192, 114)
$Radio1 = GUICtrlCreateRadio("Radio1", 16, 24, 73, 25)
$Radio2 = GUICtrlCreateRadio("Radio2", 112, 24, 81, 25)
$Radio3 = GUICtrlCreateRadio("Radio3", 216, 16, 73, 33)
$Tab1 = GUICtrlCreateTab(16, 72, 377, 241)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$tabHandle = GUICtrlGetHandle($Tab1)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Radio1
                        _GUICtrlTab_SetCurSel($tabHandle, 0)
                Case $Radio2
                        _GUICtrlTab_SetCurSel($tabHandle, 1)
                Case $Radio3
                        _GUICtrlTab_SetCurSel($tabHandle, 2)
        EndSwitch
WEnd

smooth 发表于 2014-2-4 14:28:14


veket_linux 发表于 2014-2-4 13:20 http://www.autoitx.com/images/common/back.gif


非常感谢!

smooth 发表于 2014-2-5 09:44:00

回复 2# veket_linux

这样还存在一个问题,就是虽然分页标签的名称是切换过来了,可是内容还是停留在上一个分页上。

veket_linux 发表于 2014-2-6 21:42:12

搞定了,
界面用Koda拖拽控件 so easy,分分钟搞定
关键要 给tab的父窗口 发消息
_SendMessage发送$WM_NOTIFY消息给tab控件的父窗口
通知代码为$TCN_SELCHANGE
通知代码需要利用 结构体(sendmessage的第四个参数是结构体指针)
typedef struct tagNMHDR {
    HWND hwndFrom;
    UINT idFrom;
    UINT code;
} NMHDR;

结构创建、设置结构值、得到结构指针 au3进程管理函数DllStruct****函数.....


sendmessage

#Include <GuiTab.au3>
#Include <SendMessage.au3>


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 432, 436, 192, 114)
$Checkbox1 = GUICtrlCreateCheckbox("第一页", 24, 16, 81, 25)
GUICtrlSetState($Checkbox1, $GUI_CHECKED)
$Checkbox2 = GUICtrlCreateCheckbox("第二页", 120, 16, 81, 25)
$Checkbox3 = GUICtrlCreateCheckbox("第三页", 200, 16, 81, 25)
$Tab1 = GUICtrlCreateTab(24, 56, 337, 337)
$TabSheet1 = GUICtrlCreateTabItem("第一页")
$Label1 = GUICtrlCreateLabel("Label1", 64, 112, 68, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Button1 = GUICtrlCreateButton("Button1", 176, 112, 65, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$TabSheet2 = GUICtrlCreateTabItem("第二页")
$Edit1 = GUICtrlCreateEdit("", 56, 128, 153, 177)
GUICtrlSetData(-1, "Edit1")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Button2 = GUICtrlCreateButton("Button2", 248, 184, 65, 33)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$TabSheet3 = GUICtrlCreateTabItem("第三页")
$Edit2 = GUICtrlCreateEdit("", 56, 136, 145, 169)
GUICtrlSetData(-1, "Edit2")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Radio1 = GUICtrlCreateRadio("Radio1", 232, 136, 73, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Radio2 = GUICtrlCreateRadio("Radio2", 232, 184, 73, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Button3 = GUICtrlCreateButton("Button3", 232, 232, 73, 33)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$tabHandle = GUICtrlGetHandle($Tab1)
$str = "long x;long y;long z"
$a   = DllStructCreate($str)
DllStructSetData($a,1,$tabHandle )
DllStructSetData($a,2,$Tab1)
DllStructSetData($a,3,$TCN_SELCHANGE)
$p = DllStructGetPtr($a)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Checkbox1
                        GUICtrlSetState($Checkbox1, $GUI_CHECKED)
                        GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
                        GUICtrlSetState($Checkbox3, $GUI_UNCHECKED)
                        _GUICtrlTab_SetCurSel($tabHandle, 0)
                        _SendMessage($Form1, $WM_NOTIFY, $Tab1, $p)
                Case $Checkbox2
                        GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
                        GUICtrlSetState($Checkbox2, $GUI_CHECKED)
                        GUICtrlSetState($Checkbox3, $GUI_UNCHECKED)
                        _GUICtrlTab_SetCurSel($tabHandle, 1)
                        _SendMessage($Form1, $WM_NOTIFY, $Tab1, $p)
                Case $Checkbox3
                        GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
                        GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
                        GUICtrlSetState($Checkbox3, $GUI_CHECKED)
                        _GUICtrlTab_SetCurSel($tabHandle, 2)
                        _SendMessage($Form1, $WM_NOTIFY, $Tab1, $p)
        EndSwitch
WEnd

veket_linux 发表于 2014-2-6 21:48:56

测试 OK请看 图效果图

smooth 发表于 2014-2-6 21:55:51

回复 6# veket_linux

我来试试,谢谢!

meteor0330 发表于 2014-2-7 17:44:55

记号一下!!!!!

kkahk 发表于 2014-2-8 00:56:33

回复 6# veket_linux


    谢谢分享,另外请教下你用的是啥GIF录制工具啊?最近一直在寻找类似好用的工具的

veket_linux 发表于 2014-2-8 12:01:25

http://www.autoitx.com/forum.php?mod=viewthread&tid=16952&highlight=gif%2Bgif%2Bgif

smooth 发表于 2014-2-8 21:30:03

回复 10# veket_linux

看不懂$str = "long x;long y;long z"是什么意思,请指教,谢谢!

zxcslove 发表于 2014-2-9 15:23:39

动图不错,看上去一目了然

haopp1 发表于 2017-8-18 17:25:01

留个脚印!
页: [1]
查看完整版本: 【已解决】请教能否通过一个选择框的选中状态关联到分页标签?