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

Yo, piszę drugi temat bo w tym starym starym zrobił się duży syf. Mianowicie mam taki kod, który napisał pawellek.

Tylko, że w nim można dodać pkt ujemne, oraz gdy zmieniamy liczbe 1 ( wartosc 5pkt) na liczbe 2 (wartość 9 pkt) możemy dodać maks 4 pkt na plusie i 5 na minusie zamiast 9 na plusie.

 

	
		#include <ButtonConstants.au3>		
		#include <EditConstants.au3>		
		#include <GUIConstantsEx.au3>		
		#include <StaticConstants.au3>		
		#include <WindowsConstants.au3>		
		 		
		Global $maxpkt = 0, $sumpkt = 0		
		 		
		#Region ### START Koda GUI section ### Form=		
		$Form1 = GUICreate("Form1", 256, 256, 349, 220)		
		$Input1 = GUICtrlCreateInput(0, 32, 16, 57, 21)		
		$Button1 = GUICtrlCreateButton("+", 96, 16, 27, 25)		
		$Button2 = GUICtrlCreateButton("-", 0, 16, 27, 25)		
		 		
		$Input2 = GUICtrlCreateInput(0, 32, 46, 57, 21)		
		$Button3 = GUICtrlCreateButton("+", 96, 46, 27, 25)		
		$Button4 = GUICtrlCreateButton("-", 0, 46, 27, 25)		
		 		
		$Input3 = GUICtrlCreateInput(0, 32, 76, 57, 21)		
		$Button5 = GUICtrlCreateButton("+", 96, 76, 27, 25)		
		$Button6 = GUICtrlCreateButton("-", 0, 76, 27, 25)		
		 		
		$Input4 = GUICtrlCreateInput($maxpkt, 0, 200, 121, 21, $ES_NUMBER)		
		$Label1 = GUICtrlCreateLabel("max pkt = " & $maxpkt, 128, 200, 86, 17)		
		GUISetState(@SW_SHOW)		
		#EndRegion ### END Koda GUI section ###		
		 		
		While 1		
		$nMsg = GUIGetMsg()		
		Switch $nMsg		
		Case $Input4		
		$maxpkt = ile(GUICtrlRead($Input4))		
		GUICtrlSetData($Label1, "max pkt = " & $maxpkt)		
		GUICtrlSetData($Input1, 0)		
		GUICtrlSetData($Input2, 0)		
		GUICtrlSetData($Input3, 0)		
		Case $Button1		
		add($Input1)		
		Case $Button2		
		sub($Input1)		
		Case $Button3		
		add($Input2)		
		Case $Button4		
		sub($Input2)		
		Case $Button5		
		add($Input3)		
		Case $Button6		
		sub($Input3)		
		Case $GUI_EVENT_CLOSE		
		Exit		
		EndSwitch		
		WEnd		
		 		
		Func add($idInput)		
		If $sumpkt >= $maxpkt Then Return		
		Local $read = Int(GUICtrlRead($idInput))		
		$sumpkt += 1		
		GUICtrlSetData($idInput, $read + 1)		
		EndFunc		
		 		
		Func sub($idInput)		
		If $sumpkt <= 0 Then Return		
		Local $read = Int(GUICtrlRead($idInput))		
		$sumpkt -= 1		
		GUICtrlSetData($idInput, $read - 1)		
		EndFunc		
		 		
		Func ile($read)		
		Switch $read		
		Case "1"		
		Return 5		
		Case "2"		
		Return 9		
		Case "3"		
		Return 13		
		EndSwitch		
		EndFunc ;==>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, $sumpkt = 0

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 256, 256, 349, 220)
$Input1 = GUICtrlCreateInput(0, 32, 16, 57, 21)
$Button1 = GUICtrlCreateButton("+", 96, 16, 27, 25)
$Button2 = GUICtrlCreateButton("-", 0, 16, 27, 25)

$Input2 = GUICtrlCreateInput(0, 32, 46, 57, 21)
$Button3 = GUICtrlCreateButton("+", 96, 46, 27, 25)
$Button4 = GUICtrlCreateButton("-", 0, 46, 27, 25)

$Input3 = GUICtrlCreateInput(0, 32, 76, 57, 21)
$Button5 = GUICtrlCreateButton("+", 96, 76, 27, 25)
$Button6 = GUICtrlCreateButton("-", 0, 76, 27, 25)

$Input4 = GUICtrlCreateInput($maxpkt, 0, 200, 121, 21, $ES_NUMBER)
$Label1 = GUICtrlCreateLabel("max pkt = " & $maxpkt, 128, 200, 86, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $Input4
			$maxpkt = ile(GUICtrlRead($Input4))
			GUICtrlSetData($Label1, "max pkt = " & $maxpkt)
			$sumpkt = 0
			GUICtrlSetData($Input1, 0)
			GUICtrlSetData($Input2, 0)
			GUICtrlSetData($Input3, 0)
		Case $Button1
			add($Input1)
		Case $Button2
			sub($Input1)
		Case $Button3
			add($Input2)
		Case $Button4
			sub($Input2)
		Case $Button5
			add($Input3)
		Case $Button6
			sub($Input3)
		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch
WEnd

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

Func sub($idInput)
	Local $read = Int(GUICtrlRead($idInput))
	If $sumpkt <= 0 Or $read <= 0 Then Return
	$sumpkt -= 1
	GUICtrlSetData($idInput, $read - 1)
EndFunc   ;==>sub

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

 

 

 

Opublikowano
7 minut temu, Pawellek napisał:

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

Global $maxpkt = 0, $sumpkt = 0

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 256, 256, 349, 220)
$Input1 = GUICtrlCreateInput(0, 32, 16, 57, 21)
$Button1 = GUICtrlCreateButton("+", 96, 16, 27, 25)
$Button2 = GUICtrlCreateButton("-", 0, 16, 27, 25)

$Input2 = GUICtrlCreateInput(0, 32, 46, 57, 21)
$Button3 = GUICtrlCreateButton("+", 96, 46, 27, 25)
$Button4 = GUICtrlCreateButton("-", 0, 46, 27, 25)

$Input3 = GUICtrlCreateInput(0, 32, 76, 57, 21)
$Button5 = GUICtrlCreateButton("+", 96, 76, 27, 25)
$Button6 = GUICtrlCreateButton("-", 0, 76, 27, 25)

$Input4 = GUICtrlCreateInput($maxpkt, 0, 200, 121, 21, $ES_NUMBER)
$Label1 = GUICtrlCreateLabel("max pkt = " & $maxpkt, 128, 200, 86, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $Input4
			$maxpkt = ile(GUICtrlRead($Input4))
			GUICtrlSetData($Label1, "max pkt = " & $maxpkt)
			$sumpkt = 0
			GUICtrlSetData($Input1, 0)
			GUICtrlSetData($Input2, 0)
			GUICtrlSetData($Input3, 0)
		Case $Button1
			add($Input1)
		Case $Button2
			sub($Input1)
		Case $Button3
			add($Input2)
		Case $Button4
			sub($Input2)
		Case $Button5
			add($Input3)
		Case $Button6
			sub($Input3)
		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch
WEnd

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

Func sub($idInput)
	Local $read = Int(GUICtrlRead($idInput))
	If $sumpkt <= 0 Or $read <= 0 Then Return
	$sumpkt -= 1
	GUICtrlSetData($idInput, $read - 1)
EndFunc   ;==>sub

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

 

Dzięki :D

/cls

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ę...