Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Dodawanie pkt buttonami


Rekomendowane odpowiedzi

Opublikowano

Siema, mam pytanie jak zrobić dodawanie pkt buttonami + i - a iloscia pkt ograniczona od podanej liczby w inpucie?

Mam coś takiego i dodawanie pkt mi nie działa a max pkt to nawet nwm jak zrobić :( Jestem świadom, że ten kod co jest na dole to jakiaś kupa bo się na tym nie znam dopiero się uczem ^^ I jeszcze jak bym chciał liczbe pkt maksymalnych do dodania wyświetlić to jak by to miało wygladac?

 

 

 
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 176, 83, 349, 220)
$Input1 = GUICtrlCreateInput("", 32, 16, 57, 21)
$Button1 = GUICtrlCreateButton("+", 96, 16, 27, 25)
$Button2 = GUICtrlCreateButton("-", 0, 16, 27, 25)
$Input2 = GUICtrlCreateInput("0", 0, 48, 121, 21)
$Label1 = GUICtrlCreateLabel("Ile max pkt?", 128, 48, 36, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $Button1
   butek1()
  Case $Button2
   butek2()
  Case $GUI_EVENT_CLOSE
   Exit
 EndSwitch
WEnd
Func butek1()
 Local $Input1 = Execute("$Input1+1")
 EndFunc
Func butek2()
 Local $Input1 = Execute("$Input1-1")
EndFunc
Func ile()
 $1 = 5 // Po podaniu liczby 1 udostepnia nam mozliwosc dodania 5 pkt
 $2 = 9 // Po podaniu liczby 1 udostepnia nam mozliwosc dodania 9 pkt
 $3 = 13 // Po podaniu liczby 1 udostepnia nam mozliwosc dodania 13 pkt
EndFunc
 

10 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 200 | 300 400 | 500 | 600 | 700 | 800 | 900 | 1000logoskillowcy.png

 

Opublikowano


#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

 

Global $maxpkt = 10

 

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 256, 183, 349, 220)

$Input1 = GUICtrlCreateInput(0, 32, 16, 57, 21)

$Button1 = GUICtrlCreateButton("+", 96, 16, 27, 25)

$Button2 = GUICtrlCreateButton("-", 0, 16, 27, 25)

$Input2 = GUICtrlCreateInput($maxpkt, 0, 48, 121, 21)

$Label1 = GUICtrlCreateLabel("max pkt = " & $maxpkt, 128, 48, 86, 17)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $Button1

butek1()

Case $Button2

butek2()

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

 

Func butek1()

Local $readinput1 = Int(GUICtrlRead($Input1))

If $readinput1 >= $maxpkt + $readinput1 Then Return

GUICtrlSetData($Input1, $readinput1 + 1)

$maxpkt -= 1

GUICtrlSetData($Input2, $maxpkt)

EndFunc ;==>butek1

Func butek2()

Local $readinput1 = Int(GUICtrlRead($Input1))

If $readinput1 <= 0 Then Return

GUICtrlSetData($Input1, $readinput1 - 1)

$maxpkt += 1

GUICtrlSetData($Input2, $maxpkt)

EndFunc ;==>butek2

Func ile()

$1 = 5 ;// Po podaniu liczby 1 udostepnia nam mozliwosc dodania 5 pkt

$2 = 9 ;// Po podaniu liczby 1 udostepnia nam mozliwosc dodania 9 pkt

$3 = 13 ;// Po podaniu liczby 1 udostepnia nam mozliwosc dodania 13 pkt

EndFunc ;==>ile

 

 

 

Opublikowano
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $maxpkt = 10

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 256, 183, 349, 220)
$Input1 = GUICtrlCreateInput(0, 32, 16, 57, 21)
$Button1 = GUICtrlCreateButton("+", 96, 16, 27, 25)
$Button2 = GUICtrlCreateButton("-", 0, 16, 27, 25)
$Input2 = GUICtrlCreateInput($maxpkt, 0, 48, 121, 21)
$Label1 = GUICtrlCreateLabel("max pkt = " & $maxpkt, 128, 48, 86, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $Button1
			butek1()
		Case $Button2
			butek2()
		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch
WEnd

Func butek1()
	Local $readinput1 = Int(GUICtrlRead($Input1))
	If $readinput1 >= $maxpkt + $readinput1 Then Return
	GUICtrlSetData($Input1, $readinput1 + 1)
	$maxpkt -= 1
	GUICtrlSetData($Input2, $maxpkt)
EndFunc   ;==>butek1
Func butek2()
	Local $readinput1 = Int(GUICtrlRead($Input1))
	If $readinput1 <= 0 Then Return
	GUICtrlSetData($Input1, $readinput1 - 1)
	$maxpkt += 1
	GUICtrlSetData($Input2, $maxpkt)
EndFunc   ;==>butek2
Func ile()
	$1 = 5 ;// Po podaniu liczby 1 udostepnia nam mozliwosc dodania 5 pkt
	$2 = 9 ;// Po podaniu liczby 1 udostepnia nam mozliwosc dodania 9 pkt
	$3 = 13 ;// Po podaniu liczby 1 udostepnia nam mozliwosc dodania 13 pkt
EndFunc   ;==>ile

 

Działa dodawanie dzięki, ale widze, że ty ograniczyłeś do 10 pkt a mi chodziło o to by po podaniu liczby w inpucie 1 udostepnia nam 5pkt tak jak podałem w func ile

10 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 200 | 300 400 | 500 | 600 | 700 | 800 | 900 | 1000logoskillowcy.png

 

Opublikowano


#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

 

Global $maxpkt = 0

 

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 256, 183, 349, 220)

$Input1 = GUICtrlCreateInput(0, 32, 16, 57, 21)

$Button1 = GUICtrlCreateButton("+", 96, 16, 27, 25)

$Button2 = GUICtrlCreateButton("-", 0, 16, 27, 25)

$Input2 = GUICtrlCreateInput($maxpkt, 0, 48, 121, 21, $ES_NUMBER)

$Label1 = GUICtrlCreateLabel("max pkt = " & $maxpkt, 128, 48, 86, 17)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

 

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $Input2

$maxpkt = ile(GUICtrlRead($Input2))

GUICtrlSetData($Label1, "max pkt = " & $maxpkt)

GUICtrlSetData($Input1, 0)

Case $Button1

butek1()

Case $Button2

butek2()

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

 

Func butek1()

Local $read = Int(GUICtrlRead($Input1))

If $read >= $maxpkt Then Return

GUICtrlSetData($Input1, $read + 1)

EndFunc ;==>butek1

 

Func butek2()

Local $read = Int(GUICtrlRead($Input1))

If $read <= 0 Then Return

GUICtrlSetData($Input1, $read - 1)

EndFunc ;==>butek2

 

Func ile($read)

Switch $read

Case "1"

Return 5

Case "2"

Return 9

Case "3"

Return 13

EndSwitch

EndFunc ;==>ile

 

 

Opublikowano
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $maxpkt = 0

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 256, 183, 349, 220)
$Input1 = GUICtrlCreateInput(0, 32, 16, 57, 21)
$Button1 = GUICtrlCreateButton("+", 96, 16, 27, 25)
$Button2 = GUICtrlCreateButton("-", 0, 16, 27, 25)
$Input2 = GUICtrlCreateInput($maxpkt, 0, 48, 121, 21, $ES_NUMBER)
$Label1 = GUICtrlCreateLabel("max pkt = " & $maxpkt, 128, 48, 86, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $Input2
			$maxpkt = ile(GUICtrlRead($Input2))
			GUICtrlSetData($Label1, "max pkt = " & $maxpkt)
			GUICtrlSetData($Input1, 0)
		Case $Button1
			butek1()
		Case $Button2
			butek2()
		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch
WEnd

Func butek1()
	Local $read = Int(GUICtrlRead($Input1))
	If $read >= $maxpkt Then Return
	GUICtrlSetData($Input1, $read + 1)
EndFunc   ;==>butek1

Func butek2()
	Local $read = Int(GUICtrlRead($Input1))
	If $read <= 0 Then Return
	GUICtrlSetData($Input1, $read - 1)
EndFunc   ;==>butek2

Func ile($read)
	Switch $read
		Case "1"
			Return 5
		Case "2"
			Return 9
		Case "3"
			Return 13
	EndSwitch
EndFunc   ;==>ile

 

Dzięki wszystko działa, ale mam jeszcze jedno pytanko jak bym chciał zrobić coś takiego:

Podaje liczbe 1 i dostaje 5 pkt i te 5 pkt rozdaje do inputów, i teraz powiedzmy mam 4 inputy i do 1 i 2 inputu 1 pkt = 2 (w sensie po kliknieciu w button znika 1 pkt a dodaje 2 do inputu przy który mjest button i tak w 1 i 2, a w 3 i 4 inpucie normalnie 1 pkt = 1 pkt? Da rade cos takiego zrobić?

10 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 200 | 300 400 | 500 | 600 | 700 | 800 | 900 | 1000logoskillowcy.png

 

Opublikowano

ref

10 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 200 | 300 400 | 500 | 600 | 700 | 800 | 900 | 1000logoskillowcy.png

 

Opublikowano
Nie aktualne ogarnąłem sam :)

10 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 200 | 300 400 | 500 | 600 | 700 | 800 | 900 | 1000logoskillowcy.png

 

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...