Что нового

GUI. 2 InputBox'a в одном окне.

Fortuno

Новичок
Сообщения
5
Репутация
0
Подскажите как сделать чтобы два InputBox'a был в одном окне, и что лишнее(я уверен что лишнего много) нужно удалить из кода?

Код:
$sFile = @ScriptDir & "\Options.ini" 
If @error Then Exit

$sData = InputBox("", "Введите Логин") 
$sData2 = InputBox("", "Введите Пароль")
If @error Then Exit

$sSection = "Log In"
$sItemPrefix = "Login" 
$sItemPrefix2 = "Password"

_GUICtrlListView_AddItemToINI($sFile, $sData, $sSection, $sItemPrefix)  
_GUICtrlListView_AddItemToINI2($sFile, $sData2, $sSection, $sItemPrefix2)

Func _GUICtrlListView_AddItemToINI($hFile, $sString, $sSection, $sItemPrefix) 
    
    If Not FileExists($hFile) Then SetError(1) 

    IniWrite($hFile, $sSection, $sItemPrefix, $sString) 
   
EndFunc

Func _GUICtrlListView_CountItemsFromINI($hFile, $sSection, $sItemPrefix2)
    Local $sString

    If Not FileExists($hFile) Then SetError(1)
    While 1=1
        $sString = IniRead($hFile, $sSection, $sItemPrefix, "")

        If $sString = "" Then
            ExitLoop
        EndIf
      WEnd
    
 EndFunc
 
 Func _GUICtrlListView_AddItemToINI2($hFile, $sString, $sSection, $sItemPrefix2) 
    
    If Not FileExists($hFile) Then SetError(1) 

    
    IniWrite($hFile, $sSection, $sItemPrefix2, $sString)
EndFunc

Func _GUICtrlListView_CountItemsFromINI2($hFile, $sSection, $sItemPrefix2)
    Local $sString 

    If Not FileExists($hFile) Then SetError(1)
    While 1=1
        $sString = IniRead($hFile, $sSection, $sItemPrefix2, "")

        If $sString = "" Then
            ExitLoop
        EndIf
      WEnd
    
 EndFunc
 Sleep(500)
 Run(@ScriptDir & "\process.exe")
 Exit


С помощью Koda сделал такой интерфейс

Код:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$sFile = @ScriptDir & "\Options.ini" 
If @error Then Exit
   
Opt("GUIOnEventMode", 1) 
$Form1_1 = GUICreate("Log In", 208, 177, 325, 353)
GUICtrlCreateInput("", 8, 32, 193, 21)
GUICtrlCreateInput("", 8, 96, 193, 21)
$Button1 = GUICtrlCreateButton("OK", 8, 136, 75, 25, $WS_GROUP)
$Cancel = GUICtrlCreateButton("Cancel", 128, 136, 75, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("Введите Логин", 8, 8, 80, 17)
$Label2 = GUICtrlCreateLabel("Введите Пароль", 8, 72, 87, 17)
GUICtrlSetOnEvent($Cancel, "CancelButton") 
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") 
GUISetOnEvent($Button1, "IniWrit") 

GUISetState(@SW_SHOW)

While 1 
  Sleep(1000)  ; Цикл ожидания 
WEnd 

Func CancelButton()  
  Exit 
EndFunc

Func IniWrit()  
    
  Exit 
EndFunc

Func CLOSEClicked() 
  Exit 
EndFunc


Но как вставить нужный код я понять не смог.
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
Re: Основы GUI и обращение к INI

Fortuno [?]
Вопрос который был про INI в заголовке темы снимается.
В этом случае:
Предупреждение За нарушение правил форума (пункт Б.5):
Имя темы должно нести смысловую нагрузку (отражать суть вопроса/проблемы)
Правильно сформулированное название темы привлекает больше внимания, и шансы получить конкретный ответ увеличиваются.


Данные правила могут пополняться локальными правилами раздела.
Как правильно называть темы

"Основы GUI и обращение к INI" - это неприемлемое название темы, переименуйте тему иначе она будет закрыта, а вам возможно будет выдан бан на несколько дней.

С уважением, ваш Модератор.
 
Верх