We! 发表于 2010-3-9 12:07:17

GUICtrlCreateInput 讀取顯示問題。[已解決]

本帖最后由 We! 于 2010-3-9 12:53 编辑

[已解決] 謝謝二樓 afan大大 熱心幫忙 :)

請問一下,下面的 Checkbox1 點選後 GUICtrlCreateInput 出現的路徑是沒錯的,

但是! 我如果滑鼠在 GUICtrlCreateInput 上面在點一次左鍵,它又會跳回原本的數值。

有什麼方式點選後能是正確的數值。Opt("GUIOnEventMode", 1)

Dim $topdir = @DesktopDir
Dim $I1 = IniRead($topdir&"\Tests.ini", "URL", "EXE", "請選擇單一檔案")
Dim $I2 = IniRead($topdir&"\Tests.ini", "URL", "DIR", "請選擇資料夾")
Dim $I3 = IniRead($topdir&"\Tests.ini", "URL", "SAVE", "請選擇儲存路徑")
Dim $I4 = IniRead($topdir&"\Tests.ini", "URL", "ICON", "請選擇圖示檔案")

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("轉換程式", 236, 182, 333, 270)
GUICtrlCreateGroup("", 0, -4, 235, 75)
GUICtrlSetFont(-1, 10, 400, 0, "新細明體")

$Input1 = GUICtrlCreateInput($I1, 12, 14, 179, 21)
GUICtrlSetState($Input1, $GUI_DISABLE)

$Input2 = GUICtrlCreateInput("", 12, 40, 179, 21)
GUICtrlSetState($Input2, $GUI_DISABLE)

$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 204, 14, 13, 17)
GUICtrlSetOnEvent(-1, "Checkbox1Click")
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 204, 40, 13, 17)
GUICtrlSetOnEvent(-1, "Checkbox2Click")

GUICtrlCreateGroup("", -99, -99, 1, 1)

While 1
        Sleep(100)
WEnd

Func _GuiEvents()
        Switch @GUI_CtrlId
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $GUI_EVENT_MINIMIZE
                       
                Case $GUI_EVENT_RESTORE
                       
        EndSwitch
EndFunc

Func Checkbox1Click()
If GUICtrlRead($Checkbox1)=$GUI_CHECKED Then
        $exe = FileOpenDialog("選擇檔案", @DesktopDir & "\", "自解檔 (*.exe)|全部(*.*)", 2+4)
If @error Then
    MsgBox(4096,"","請選擇檔案。")
Else
    $exe = StringReplace($exe, "|", @CRLF)
    MsgBox(4096,"","您選擇的是:" & $exe)
EndIf
        IniWrite($topdir&"\Tests.ini", "URL", "EXE", $exe)
        $Input1 = GUICtrlCreateInput($exe, 12, 14, 179, 21)
        GUICtrlSetState($Checkbox2, $GUI_DISABLE)
Else

EndIf
EndFunc

afan 发表于 2010-3-9 12:43:00

#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)

Dim $topdir = @DesktopDir
Dim $I1 = IniRead($topdir & "\Tests.ini", "URL", "EXE", "請選擇單一檔案")
Dim $I2 = IniRead($topdir & "\Tests.ini", "URL", "DIR", "請選擇資料夾")
Dim $I3 = IniRead($topdir & "\Tests.ini", "URL", "SAVE", "請選擇儲存路徑")
Dim $I4 = IniRead($topdir & "\Tests.ini", "URL", "ICON", "請選擇圖示檔案")

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("轉換程式", 236, 182, 333, 270)
GUISetOnEvent(-3, "_GuiEvents")
GUICtrlCreateGroup("", 0, -4, 235, 75)
GUICtrlSetFont(-1, 10, 400, 0, "新細明體")
$Input1 = GUICtrlCreateInput($I1, 12, 14, 179, 21)
GUICtrlSetState($Input1, $GUI_DISABLE)
$Input2 = GUICtrlCreateInput("", 12, 40, 179, 21)
GUICtrlSetState($Input2, $GUI_DISABLE)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 204, 14, 13, 17)
GUICtrlSetOnEvent(-1, "Checkbox1Click")
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 204, 40, 13, 17)
GUICtrlSetOnEvent(-1, "Checkbox2Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState()

While 1
        Sleep(100)
WEnd

Func _GuiEvents()
        Exit
EndFunc   ;==>_GuiEvents

Func Checkbox1Click()
        If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
                $exe = FileOpenDialog("選擇檔案", @DesktopDir & "\", "自解檔 (*.exe)|全部(*.*)", 2 + 4)
                If @error Then
                        MsgBox(4096, "", "請選擇檔案。")
                Else
                        $exe = StringReplace($exe, "|", @CRLF)
                        MsgBox(4096, "", "您選擇的是:" & $exe)
                EndIf
                IniWrite($topdir & "\Tests.ini", "URL", "EXE", $exe)
                GUICtrlSetData($Input1, $exe)
                GUICtrlSetState($Checkbox2, $GUI_DISABLE)
        Else
        EndIf
EndFunc   ;==>Checkbox1Click
页: [1]
查看完整版本: GUICtrlCreateInput 讀取顯示問題。[已解決]