找回密码
 加入
搜索
查看: 1549|回复: 4

[AU3基础] 【已解决】关于INI查询的问题及相关gui问题

[复制链接]
发表于 2011-3-13 16:04:41 | 显示全部楼层 |阅读模式
本帖最后由 喀喇喀喇 于 2011-3-14 07:29 编辑

先写下congfig.ini的格式:
[config]
xxx=xxxx|030|ht-010-0001|00001.ht
xxx=xxxx|0050|ht-010-0002|00002.ht
xxx=xxxx|584|ht-010-0003|00003.ht
xxx=xxxx|325|ht-010-0004|00004.ht

读取没有问题,我的问题是,怎样在设计好的界面上实现在$Input2中输入查询条件(任意)$Button21按钮点击后列出查询的结果,我非常菜,不知道表达清楚没有,希望各位高手能多帮忙

代码如下:
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GuiImageList.au3>
#include <GuiButton.au3>
#include <ListViewConstants.au3>
#include <EditConstants.au3>
#include <GuiListView.au3>
$Form1 = GUICreate("工具", 688, 201, -1, -1)
$Pic1 = GUICtrlCreatePic(@TempDir & "\banner.jpg", 0, 0, 687, 93)
$Button1 = GUICtrlCreateButton("待添加", 300, 109, 75, 75)
_GUICtrlButton_SetImageList($Button1, _GetImageListHandle("shell32.dll", -20, True), 2, -1, 12)
$Button2 = GUICtrlCreateButton("查询", 400, 109, 75, 75)
_GUICtrlButton_SetImageList($Button2, _GetImageListHandle("shell32.dll", -279, True), 2, -1, 12)
$Button3 = GUICtrlCreateButton("待添加", 500, 109, 75, 75)
_GUICtrlButton_SetImageList($Button3, _GetImageListHandle("shell32.dll", -258, True), 2, -1, 12)
$Button4 = GUICtrlCreateButton("待添加", 600, 109, 75, 75)
_GUICtrlButton_SetImageList($Button4, _GetImageListHandle("shell32.dll", -27, True), 2, -1, 12)
$Label1 = GUICtrlCreateLabel("  ★ 说明事项:" & @LF & "" & @LF & "  ★ 待添加!" & @LF & "" & @LF & "  ★ 待添加!", 0, 112, 250, 65)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        MsgBox(0,"提示","还没东西呢")
                Case $Button2
                        $dir = @ScriptDir & "\config.ini"
                        $Form2 = GUICreate("查询", 687, 480)
                        $Pic2 = GUICtrlCreatePic(@TempDir & "\banner.jpg", 0, 0, 687, 93)
                        $ListView1 = GUICtrlCreateListView("     1111        |     2222       |     3333      |     4444       |     5555        ", 10, 100, 668, 320)
                        $Label2 = GUICtrlCreateLabel("  ★ 请输入需要查询的内容:", 60, 440, 200, 25)
                        $Input2 = GUICtrlCreateInput("", 256, 435, 300, 21)
                        $Button21 = GUICtrlCreateButton("开始查询", 576, 432, 100, 23)
                        GUISetState(@SW_SHOW, $Form2)
                        Read()
                        While 1
                                $Msg_about = GUIGetMsg()
                                Select
                                        Case $Msg_about = $GUI_EVENT_CLOSE
                                                GUIDelete($Form2)
                                                ExitLoop
                                EndSelect
                        WEnd

                Case $Button3
                        MsgBox(0,"提示","还没东西呢")
                Case $Button4
                        MsgBox(0,"提示","还没东西呢")
        EndSwitch
WEnd
Func Read()
        Dim $var = IniReadSection($dir, "config"), $item[1], $i
        For $i = 1 To $var[0][0]
                $item[$i - 1] = GUICtrlCreateListViewItem($var[$i][0] & '|' & $var[$i][1], $ListView1)
                ReDim $item[$i + 1]
        Next
EndFunc   ;==>Read
Func _GetImageListHandle($sFile, $nIconID = 0, $fLarge = False)
        Local $iSize = 16
        If $fLarge Then $iSize = 32

        Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
        If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
                _GUIImageList_AddBitmap($hImage, $sFile)
        Else
                _GUIImageList_AddIcon($hImage, $sFile, $nIconID, $fLarge)
        EndIf
        Return $hImage
EndFunc   ;==>_GetImageListHandle
还请各位多多帮忙,代码都是拼凑出来的,初学au3,还望多多指点
 楼主| 发表于 2011-3-13 20:52:54 | 显示全部楼层
自己顶一下,希望达人帮忙
发表于 2011-3-13 22:40:04 | 显示全部楼层

INI查询+子窗口

查询:重读ini利用StringInStr判断再重添item
子窗口:这部分例子论坛多的是
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GuiImageList.au3>
#include <GuiButton.au3>
#include <ListViewConstants.au3>
#include <EditConstants.au3>
#include <GuiListView.au3>
$Form1 = GUICreate("工具", 688, 201, -1, -1)
$Pic1 = GUICtrlCreatePic(@TempDir & "\banner.jpg", 0, 0, 687, 93)
$Button1 = GUICtrlCreateButton("待添加", 300, 109, 75, 75)
_GUICtrlButton_SetImageList($Button1, _GetImageListHandle("shell32.dll", -20, True), 2, -1, 12)
$Button2 = GUICtrlCreateButton("查询", 400, 109, 75, 75)
_GUICtrlButton_SetImageList($Button2, _GetImageListHandle("shell32.dll", -279, True), 2, -1, 12)
$Button3 = GUICtrlCreateButton("待添加", 500, 109, 75, 75)
_GUICtrlButton_SetImageList($Button3, _GetImageListHandle("shell32.dll", -258, True), 2, -1, 12)
$Button4 = GUICtrlCreateButton("待添加", 600, 109, 75, 75)
_GUICtrlButton_SetImageList($Button4, _GetImageListHandle("shell32.dll", -27, True), 2, -1, 12)
$Label1 = GUICtrlCreateLabel("  ★ 说明事项:" & @LF & "" & @LF & "  ★ 待添加!" & @LF & "" & @LF & "  ★ 待添加!", 0, 112, 250, 65)
$Form2 = GUICreate("查询", 687, 480)
$ListView1 = GUICtrlCreateListView("     1111        |     2222       |     3333      |     4444       |     5555        ", 10, 100, 668, 320)
$Label2 = GUICtrlCreateLabel("  ★ 请输入需要查询的内容:", 60, 440, 200, 25)
$Input2 = GUICtrlCreateInput("", 256, 435, 300, 21)
$Button5 = GUICtrlCreateButton("开始查询", 576, 432, 100, 23)
GUISetState(@SW_SHOW, $Form1)
$dir = @ScriptDir & "\config.ini"
Dim $var = IniReadSection($dir, "config"), $item[1], $i
For $i = 1 To $var[0][0]
        $item[$i - 1] = GUICtrlCreateListViewItem($var[$i][0] & '|' & $var[$i][1], $ListView1)
        ReDim $item[$i + 1]
Next
While 1
        $nMsg = GUIGetMsg(1)
        Switch $nMsg[0]
                Case $GUI_EVENT_CLOSE
                        If $nMsg[1] == $Form1 Then
                                Exit
                        ElseIf $nMsg[1] == $Form2 Then
                                GUISetState(@SW_SHOW, $Form1)
                                GUISetState(@SW_HIDE, $Form2)
                        EndIf
                Case $Button2
                        GUISetState(@SW_SHOW, $Form2)
                        GUISetState(@SW_HIDE, $Form1)
                Case $Button5
                        _GUICtrlListView_DeleteAllItems($ListView1)
                        For $i = 1 To $var[0][0]
                                If StringInStr($var[$i][0], GUICtrlRead($Input2)) Or StringInStr($var[$i][1], GUICtrlRead($Input2)) Then GUICtrlCreateListViewItem($var[$i][0] & '|' & $var[$i][1], $ListView1)
                        Next

        EndSwitch

WEnd

Func _GetImageListHandle($sFile, $nIconID = 0, $fLarge = False)
        Local $iSize = 16
        If $fLarge Then $iSize = 32

        Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
        If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
                _GUIImageList_AddBitmap($hImage, $sFile)
        Else
                _GUIImageList_AddIcon($hImage, $sFile, $nIconID, $fLarge)
        EndIf
        Return $hImage
EndFunc   ;==>_GetImageListHandle

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2011-3-14 07:29:21 | 显示全部楼层
非常感谢,又学习到了,谢谢lynfr8
发表于 2011-3-14 19:40:48 | 显示全部楼层
For $i = 1 To $var[0][0]
For $i = 1 To $var^ ERROR
>Exit code: 1    Time: 0.907
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-2 12:35 , Processed in 0.080355 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表