[Switch]Images

02/13/2014 18:54 xKemya#1
Hello,

so I've created a new project, I want to know how to when I click on a picture it switch to another picture?

I mean : I made a picture for the check box which is unchecked, I want to make a function that when I press on the picture it make it checked.
02/13/2014 19:16 alpines#2
Just replace the GUICtrlCreateButton with GUICtrlCreatePic
Code:
$h = GUICreate("", 100, 100)
$b1 = GUICtrlCreateButton("checked", 0, 0)
$b2 = GUICtrlCreateButton("unchecked", 0, 25)
$c = GUICtrlCreateCheckbox("sample", 0, 50)
GUISetState()

While 1
	Switch GUIGetMsg()
		Case -3
			Exit

		Case $b1
			GUICtrlSetState($c, 1)

		Case $b2
			GUICtrlSetState($c, 4)
	EndSwitch
WEnd
02/14/2014 08:34 xKemya#3
Quote:
Originally Posted by alpines View Post
Just replace the GUICtrlCreateButton with GUICtrlCreatePic
Code:
$h = GUICreate("", 100, 100)
$b1 = GUICtrlCreateButton("checked", 0, 0)
$b2 = GUICtrlCreateButton("unchecked", 0, 25)
$c = GUICtrlCreateCheckbox("sample", 0, 50)
GUISetState()

While 1
	Switch GUIGetMsg()
		Case -3
			Exit

		Case $b1
			GUICtrlSetState($c, 1)

		Case $b2
			GUICtrlSetState($c, 4)
	EndSwitch
WEnd
But the 2 pictures are in the same position, will this work with it?

Testing...


More explanation : I've made a squared small picture, added beside it a label called for E.X : Hit Range, I want when I press on the picture, it automatically changes to another picture which in the same position.

If you do not understand I can add pictures.
02/14/2014 12:59 .yorliK#4
Quote:
Originally Posted by "V" View Post
But the 2 pictures are in the same position, will this work with it?

Testing...


More explanation : I've made a squared small picture, added beside it a label called for E.X : Hit Range, I want when I press on the picture, it automatically changes to another picture which in the same position.

If you do not understand I can add pictures.
PHP Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 GUICreate("Form1"397141308262)
$Pic1 GUICtrlCreatePic("filepathpicture1"3224233105)
$Checkbox1 GUICtrlCreateCheckbox("Checkbox1"280569717)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg 
GUIGetMsg()
    Switch 
$nMsg
        
Case $GUI_EVENT_CLOSE
            
Exit
        Case 
$Pic1
            
If GUICtrlRead($Checkbox1) == $GUI_CHECKED Then
                GUICtrlSetImage
($Pic1"filepathpicture1")
                
GuiCtrlSetState($Checkbox1$GUI_UNCHECKED)
            Else
                
GUICtrlSetImage($Pic1, @ScriptDir "filepathpictur2")
                
GuiCtrlSetState($Checkbox1$GUI_CHECKED)
            EndIf

    EndSwitch
WEnd 
Something like that?
02/15/2014 12:02 xKemya#5
Quote:
Originally Posted by Kilroy. View Post
<.<, see :
I want when I press on the Red Squared pic down :

[Only registered and activated users can see links. Click Here To Register...]

Turns into this :

[Only registered and activated users can see links. Click Here To Register...]

So it looks like a checkbox but in real it is Pic and switched to other pic
02/15/2014 14:34 .yorliK#6
Quote:
Originally Posted by "V" View Post
<.<, see :
I want when I press on the Red Squared pic down :
Than do this:
PHP Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 GUICreate("Form1"397141308262)
$Pic1 GUICtrlCreatePic(@ScriptDir '\img_black.jpg'3224233105)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Dim $Pic_check 0
While 1
    $nMsg 
GUIGetMsg()
    Switch 
$nMsg
        
Case $GUI_EVENT_CLOSE
            
Exit
        Case 
$Pic1
            
If $Pic_check 1 Then
                GUICtrlSetImage
($Pic1, @ScriptDir '\img_black.jpg')
                
$Pic_check 0
            
Else
                
GUICtrlSetImage($Pic1, @ScriptDir '\img_white.jpg')
                
$Pic_check 1
            
EndIf

    EndSwitch
WEnd 
You only have to change, the koords and pathes.
If you need help, send me your code via pn