Что нового

[Элементы GUI] Как соединить код скрипта с кодом GUI

warezoogle3

Новичок
Сообщения
73
Репутация
1
В общем построил GUI с помощью Koda FormDesigner

Вот код GUI-я
Код:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\desktop\copy of form1.kxf
$Form1_1 = GUICreate("Zinguilla 6 Sigma Edition", 464, 453, 288, 125)
$Label1 = GUICtrlCreateLabel(" Zinguilla 6 Sigma Edition", 80, 32, 288, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$Button1 = GUICtrlCreateButton("Change Regional Settings", 144, 192, 171, 25)
$Button2 = GUICtrlCreateButton("Install Zinguilla 6 Sigma Edition", 144, 296, 171, 25)
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\Administrator\My Documents\Downloads\Zinguilla_logo.gif", 80, 72, 292, 100)
$Label2 = GUICtrlCreateLabel("Warning! After pressing the Change Regional Settings button you computer may restart!", 24, 232, 415, 17)
$Label3 = GUICtrlCreateLabel("Please save all unsaved data and close all running programs!", 88, 264, 292, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

	EndSwitch
WEnd


Как уже понятно из кода,там две кнопки (button) и я хочу прицепить к каждой кнопке свой код (код готов),тоесть чтобы при нажатии кнопок исполнялся соответсвующий код!

Но как это сделать? Куда вставить куски кода?
Помогите пожалуйста! :smile:
 

InnI

AutoIT Гуру
Сообщения
4,922
Репутация
1,432
warezoogle3 [?]
Куда вставить куски кода?
Можно непосредственно в цикл, а можно вынести в функции, которые в цикле вызывать.
Код:
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Button1Click()
        Case $Button2
            Button2Click()

    EndSwitch
WEnd

Func Button1Click()
  MsgBox(0, "", "Код кнопки 1")
EndFunc

Func Button2Click()
  MsgBox(0, "", "Код кнопки 2")
EndFunc
 

AZJIO

Меценат
Меценат
Сообщения
2,879
Репутация
1,194
warezoogle3
Что мешает в своём выложенном коде кликнуть на GUICtrlCreateButton или другие элементы и посмотреть в примере куда код вставлять.
 
Автор
W

warezoogle3

Новичок
Сообщения
73
Репутация
1
Спасибо огромное! Все работает! :beer: :IL_AutoIt_1:
 
Верх