【已解决】关于INI查询的问题及相关gui问题
本帖最后由 喀喇喀喇 于 2011-3-14 07:29 编辑先写下congfig.ini的格式:
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, $i
For $i = 1 To $var
$item[$i - 1] = GUICtrlCreateListViewItem($var[$i] & '|' & $var[$i], $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,还望多多指点 自己顶一下,希望达人帮忙
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, $i
For $i = 1 To $var
$item[$i - 1] = GUICtrlCreateListViewItem($var[$i] & '|' & $var[$i], $ListView1)
ReDim $item[$i + 1]
Next
While 1
$nMsg = GUIGetMsg(1)
Switch $nMsg
Case $GUI_EVENT_CLOSE
If $nMsg == $Form1 Then
Exit
ElseIf $nMsg == $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
If StringInStr($var[$i], GUICtrlRead($Input2)) Or StringInStr($var[$i], GUICtrlRead($Input2)) Then GUICtrlCreateListViewItem($var[$i] & '|' & $var[$i], $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 非常感谢,又学习到了,谢谢lynfr8 For $i = 1 To $var
For $i = 1 To $var^ ERROR
>Exit code: 1 Time: 0.907
页:
[1]