|
发表于 2019-10-20 22:57:18
|
显示全部楼层
本帖最后由 yohoboy 于 2019-10-21 00:54 编辑
選項/ user Options 開啟後輸入 code.page=65001 output.code.page=65001 , 很多繁體字,所以會有亂碼,用繁簡編輯軟體將內容改成簡體看看,
第26行改為
MsgBox(0, "SQLite 錯誤", "SQLite3.dll 不能載入,請檢查SQLite3.dll,SQLite3.def檔案是否存在同一目錄下!")
試試看#include <Array.au3>
#include <ButtonConstants.au3>
#include <Color.au3>
#include <SQLite.au3>
#include <EditConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GUIEdit.au3>
#include <GUIListBox.au3>
#Include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <GuiRichEdit.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("TrayIconHide", 1) ;0 = 显示托盘图标, 1 = 隐藏托盘图标
Opt('MustDeclareVars', 1) ;0 = 变量不需预先声明, 1 = 变量必需预先声明
Opt("GUICloseOnESC", 0) ;0 = 点击 Esc 键不关闭, 1 = 点击 Esc 键关闭
Global $aRow, $hQuery, $GUI_ListBox
Local $SQLite_Data_Path = "Game_Books.sqlite" ;sql数据库路径及名称
_SQLite_Startup ("sqlite3.dll", TRUE, 1) ;加载SQLite3.dll,工作目录下需有SQLite3.dll
If @error Then ;如果没有SQLite3.dll档案则显示错误讯息
MsgBox($MB_SYSTEMMODAL, "SQLite 错误", "SQLite3.dll 不能载入,请检查SQLite3.dll,SQLite3.def档案是否存在同一目录下!")
Exit ;离开程序不执行
EndIf
If Not FileExists($SQLite_Data_Path) Then ;如果无数据库或数据库损毁要重建则执行以下命令
Local $QUERY = MsgBox(1,"错误","数据库无法打开,请检查""BM-QUERY.sqlite""档是否存在或是档案已损毁,如要建立新档请按确定,否则取消。")
If $QUERY = 1 Then
SQLCreate() ;建立新数据库,参考SQLCreate() 功能,在下面
Exit
Else
Exit
EndIf
EndIf
Func SQLCreate() ;建立数据库
_SQLite_Open ($SQLite_Data_Path) ;建立数据库,名称为$SQLite_Data_Path 变量名称
_SQLite_Exec(-1, "Create Table IF NOT Exists Game_Books (Wind_Direction Text, Wind_Speed REAL," & _
" Distance REAL, Angle Text);") ;建立数据库内容
;以上执行SQL语法建立数据表,并建立相关字段等数据内容
_SQLite_Close (-1) ;关闭数据库
MsgBox(0,"数据库","数据库已建立,请重新执行程序")
Exit
EndFunc
Local $Title = "Game Books.." ;标题名称
Local $GUI_Form = GUICreate($Title, 750, 480, -1, -1) ;建立主窗口GUI样式
GUICtrlCreateLabel("左打右", 24, 32, 36, 17)
GUICtrlCreateLabel("逆风", 48, 64, 36, 17)
GUICtrlCreateLabel("屏距", 176, 64, 36, 17)
GUICtrlCreateLabel("顺风", 48, 128, 36, 17)
GUICtrlCreateLabel("屏距", 176, 128, 36, 17)
GUICtrlCreateLabel("右打左", 24, 184, 36, 17)
GUICtrlCreateLabel("逆风", 56, 216, 36, 17)
GUICtrlCreateLabel("屏距", 176, 208, 36, 17)
GUICtrlCreateLabel("顺风", 56, 280, 36, 17)
GUICtrlCreateLabel("屏距", 176, 280, 42, 17)
GUICtrlCreateLabel("数据显示区域", 328, 16, 90, 17)
;Local $Button1 = GUICtrlCreateButton("调整数据", 48, 360, 73, 25)
Local $Button2 = GUICtrlCreateButton("清除数据", 150, 360, 65, 25)
Local $Button3 = GUICtrlCreateButton("关闭", 250, 360, 65, 25)
Local $iStylesEx = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)
$GUI_ListBox = GUICtrlCreateListView(" 风 向 |风向值| 屏 距 | 角 度 ", 344, 64, 300, 300)
_GUICtrlListView_SetExtendedListViewStyle($GUI_ListBox, $iStylesEx)
Local $Input1 = GUICtrlCreateInput("", 88, 64, 65, 21)
Local $Input2 = GUICtrlCreateInput("", 224, 56, 57, 21)
Local $Input3 = GUICtrlCreateInput("", 96, 136, 49, 21)
Local $Input4 = GUICtrlCreateInput("", 224, 128, 49, 21)
Local $Input5 = GUICtrlCreateInput("", 104, 216, 49, 21)
Local $Input6 = GUICtrlCreateInput("", 232, 208, 49, 21)
Local $Input7 = GUICtrlCreateInput("", 96, 280, 57, 21)
Local $Input8 = GUICtrlCreateInput("", 240, 280, 41, 21)
_SQLite_Open ($SQLite_Data_Path)
GUISetState(@SW_SHOW,$GUI_Form) ;GUI 显示
While 1
Switch GUIGetMsg()
Case $Button3,$GUI_EVENT_CLOSE
ExitLoop
Case $Input2
If $Input1 <> "" And $Input2 <> "" Then Left_Headwind1()
Case $Input4
; If $Input3 <> "" And $Input4 <> "" Then MsgBox(0,"",GUICtrlRead($Input3)& "," & GUICtrlRead($Input4))
Case $Button2
GUICtrlSetData($Input1, "")
GUICtrlSetData($Input2, "")
GUICtrlSetData($Input3, "")
GUICtrlSetData($Input4, "")
GUICtrlSetData($Input5, "")
GUICtrlSetData($Input6, "")
GUICtrlSetData($Input7, "")
GUICtrlSetData($Input8, "")
EndSwitch
WEnd
Func Left_Headwind1()
_GUICtrlListView_DeleteAllItems($GUI_ListBox)
Local $Input2_temp1, $Input2_temp2
$Input2_temp1 = GUICtrlRead($Input2) - 4
If $Input2_temp1 <= 0 Then $Input2_temp1 = 0
$Input2_temp2 = GUICtrlRead($Input2) + 4
;MsgBox(0,"",$Input2_temp1&","&$Input2_temp2)
_SQLite_QuerySingleRow(-1, "SELECT count(*) FROM Game_Books Where Wind_Direction = 'Left_Headwind' And Wind_Speed = '" & GUICtrlRead($Input1)& _
"' And Distance >= '" & $Input2_temp1 & "' And Distance <= '" & $Input2_temp2 & "';",$aRow)
Local $ArrayData[Int($aRow[0])][4]
;_ArrayDisplay($list_view)
_SQLite_Query(-1, "SELECT * FROM Game_Books Where Wind_Direction = 'Left_Headwind' And Wind_Speed = '" & GUICtrlRead($Input1)& _
"' And Distance >= '" & $Input2_temp1 & "' And Distance <= '" & $Input2_temp2 & "';",$hQuery)
Local $c = 0
While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
Local $i = 0
$aRow[0] = "左逆风"
For $i = 0 to 3 Step 1
$ArrayData[$c][$i] = $aRow[$i]
Next
$c = $c +1
WEnd
_GUICtrlListView_AddArray($GUI_ListBox, $ArrayData)
Local $sText, $aItem
$sText = _GUICtrlListView_GetItemCount($GUI_ListBox) ;统计显示至ListView笔数
For $i = 0 To ($sText - 1) Step 1 ;循环处理
$aItem = _GUICtrlListView_GetItemTextArray($GUI_ListBox, $i) ;取得每行资料
;MsgBox(0,"", $aItem[2] & "," & $aItem[3])
;MsgBox(0,"", GUICtrlRead($Input1) & "," & GUICtrlRead($Input2))
If Number($aItem[2]) = GUICtrlRead($Input1) And Number($aItem[3]) = GUICtrlRead($Input2) Then
_GUICtrlListView_SetItemChecked($GUI_ListBox, $i)
EndIf
Next
EndFunc
改用listview 方式,就幫到這了..有些只要調整一下就符合您的需求了。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
|