Jump to content
Sign in to follow this  
AppTux

Close and Minimize Buttons

Recommended Posts

AppTux

I have a GUI with a close and a minimize button.

In a other topic had i see a way to do it.

I want to press the minimize or closebutton, and if you go up with your mouse button then goes it do something.

I have that code something modified, but it doesn't work

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <File.au3>
#Include <GUICtrlSetOnHover.au3>
#Include <Icons.au3>

Global $Back,$theme[6],$Hold = False

_FileReadToArray("Resources\Theme.ini",$theme)
$GUI1 = GUICreate("Example", 450,300,-1,-1,$WS_POPUP)
GUISetBkColor(0xd8d8d8)
$Back = GUICtrlCreatePic($theme[2],0,0,450,300)
GUICtrlSetState(-1,$GUI_DISABLE)
$min = GUICtrlCreatePic($theme[3],375,0,25,18)
$close = GUICtrlCreatePic($theme[5],400,0,50,18)

For $i = $min To $close
    _Leave($i)
Next

GUISetState()

Do
    $msg = GUIGetMsg()
    $cursor = GUIGetCursorInfo($GUI1)
Until $msg = -3

Func _Down($CtrlID)

    If $Hold Then
        Return
    Else
        $Hold = True
    EndIf

    Local $File

    Switch $CtrlID
        Case $min
            $File = 'min-press.bmp'
        Case $close
            $File = 'close-press.bmp'
    EndSwitch
    _SetImage($CtrlID, @ScriptDir & '\Resources\' & $File, $Back)
EndFunc   ;==>_Down

Func _Leave($CtrlID)

    Local $File

    Switch $CtrlID
        Case $min
            $File = 'min.bmp'
        Case $close
            $File = 'close.bmp'
    EndSwitch
    _SetImage($CtrlID, @ScriptDir & '\Resources\' & $File, $Back)
    $Hold = False
EndFunc   ;==>_Leave

Func _Hover($CtrlID)

    Local $File

    Switch $CtrlID
        Case $min
            $File = 'min-hover.bmp'
        Case $close
            $File = 'close-hover.bmp'
    EndSwitch
    _SetImage($CtrlID, @ScriptDir & '\Resources\' & $File, $Back)
    $Hold = False
EndFunc   ;==>_Hover

Func _Up($CtrlID)
    _Hover($CtrlID)
EndFunc   ;==>_Up

Can you see what te problem is with this code??

plz help me.


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites
GodlessSinner

#include <GUICtrlSetOnHover_UDF.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $pressed = 0
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 625, 165, 273, 569)
$Button1 = GUICtrlCreateButton("Minimize", 480, 16, 137, 33, $WS_GROUP)
_GUICtrl_SetOnHover(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc", "PrimaryUp_Proc")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd



Func _Hover_Proc($iCtrlID)
    Switch $iCtrlID
        Case $Button1
            GUICtrlSetFont($Button1, 8, 800, 0, "MS Sans Serif")
            $pressed = 1
    EndSwitch
EndFunc

Func _Leave_Hover_Proc($iCtrlID)
    Switch $iCtrlID
        Case $Button1
            GUICtrlSetFont($Button1, 8, 400, 0, "MS Sans Serif")
            $pressed = 2
    EndSwitch
EndFunc

Func PrimaryDown_Proc($iCtrlID)
    Switch $iCtrlID
        Case $Button1
            If $pressed = 1 Then
            GUICtrlSetFont($Button1, 12, 400, 0, "MS Sans Serif")
            $pressed = 2
            EndIf
    EndSwitch
EndFunc

Func PrimaryUp_Proc($iCtrlID)
    Switch $iCtrlID
        Case $Button1
            If $pressed = 2 Then
            GUICtrlSetFont($Button1, 8, 800, 0, "MS Sans Serif")
            $pressed = 1
            WinSetState($Form1, "", @SW_MINIMIZE)
            EndIf
    EndSwitch
EndFunc

Edited by Godless

_____________________________________________________________________________

Share this post


Link to post
Share on other sites
AppTux

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <File.au3>
#Include <GUICtrlSetOnHover.au3>
#Include <Icons.au3>

Global $pressed = 0,$theme[6]

_FileReadToArray("Resources\Theme.ini",$theme)
$GUI1 = GUICreate("Xtreme Run", 450,300,-1,-1,$WS_POPUP)
GUISetBkColor(0xd8d8d8)
GUICtrlCreatePic($theme[2],0,0,450,300)
GUICtrlSetState(-1,$GUI_DISABLE)
$min = GUICtrlCreatePic($theme[3],375,0,25,18)
_GUICtrl_SetOnHover(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc", "PrimaryUp_Proc")
$close = GUICtrlCreatePic($theme[5],400,0,50,18)

GUISetState()

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

    EndSwitch
WEnd


Func _Hover_Proc($iCtrlID)
    Switch $iCtrlID
        Case $min
            GUICtrlDelete($min)
            $min = GUICtrlCreatePic("Resources\min-hover.bmp",375,0,25,18)
            GUICtrlSetState(-1,$GUI_SHOW)
            $pressed = 1
    EndSwitch
EndFunc

Func _Leave_Hover_Proc($iCtrlID)
    Switch $iCtrlID
        Case $min
            GUICtrlDelete($min)
            $min = GUICtrlCreatePic("Resources\min.bmp",375,0,25,18)
            GUICtrlSetState(-1,$GUI_SHOW)
            $pressed = 2
    EndSwitch
EndFunc

Func PrimaryDown_Proc($iCtrlID)
    Switch $iCtrlID
        Case $min
            If $pressed = 1 Then
            GUICtrlDelete($min)
            GUICtrlCreatePic("Resources\min-press.bmp",375,0,25,18)
            GUICtrlSetState(-1,$GUI_SHOW)
            $pressed = 2
            EndIf
    EndSwitch
EndFunc

Func PrimaryUp_Proc($iCtrlID)
    Switch $iCtrlID
        Case $min
            If $pressed = 2 Then
            GUICtrlDelete($min)
            $pressed = 1
            WinSetState($GUI1, "", @SW_MINIMIZE)
            $min = GUICtrlCreatePic("Resources\min.bmp",375,0,25,18)
            GUICtrlSetState(-1,$GUI_SHOW)
            EndIf
    EndSwitch
EndFunc

Only the mouseover action works.

the image wouldn't change when I leave the button.


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites
AppTux

I had update the code a bit. maybe can you see the problem.

The new problem (not a very big) is a bit smaller.

the image change when i go over the image, but the normal also. it's flashing.

but if i leave the button, the images flashes not on. (own problem resolved)

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <File.au3>
#Include <GUICtrlSetOnHover.au3>
#Include <Icons.au3>

Global $pressed = 0,$theme[6]

_FileReadToArray("Resources\Theme.ini",$theme)
$GUI1 = GUICreate("Xtreme Run", 450,300,-1,-1,$WS_POPUP)
GUISetBkColor(0xd8d8d8)
GUICtrlCreatePic($theme[2],0,0,450,300)
GUICtrlSetState(-1,$GUI_DISABLE)
$min = GUICtrlCreatePic($theme[3],375,0,25,18)
_GUICtrl_SetOnHover(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc", "PrimaryUp_Proc")
$min2 = GUICtrlCreatePic("Resources\min-hover.bmp",375,0,25,18)
$min3 = GUICtrlCreatePic("Resources\min-press.bmp",375,0,25,18)
$close = GUICtrlCreatePic($theme[5],400,0,50,18)
GUICtrlSetState($min,$GUI_SHOW)
GUICtrlSetState($min2,$GUI_HIDE)
GUICtrlSetState($min3,$GUI_HIDE)

GUISetState()

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

    EndSwitch
WEnd


Func _Hover_Proc($iCtrlID)
    Switch $iCtrlID
        Case $min
            GUICtrlSetState($min,$GUI_HIDE)
            GUICtrlSetState($min3,$GUI_HIDE)
            GUICtrlSetState($min2,$GUI_SHOW)
            $pressed = 1
    EndSwitch
EndFunc

Func _Leave_Hover_Proc($iCtrlID)
    Switch $iCtrlID
        Case $min
            GUICtrlSetState($min,$GUI_SHOW)
            GUICtrlSetState($min2,$GUI_HIDE)
            GUICtrlSetState($min3,$GUI_HIDE)
            $pressed = 2
    EndSwitch
EndFunc

Func PrimaryDown_Proc($iCtrlID)
    Switch $iCtrlID
        Case $min
            If $pressed = 1 Then
            GUICtrlSetState($min,$GUI_HIDE)
            GUICtrlSetState($min2,$GUI_HIDE)
            GUICtrlSetState($min3,$GUI_SHOW)
            $pressed = 2
            EndIf
    EndSwitch
EndFunc

Func PrimaryUp_Proc($iCtrlID)
    Switch $iCtrlID
        Case $min
            If $pressed = 2 Then
            GUICtrlSetState($min,$GUI_SHOW)
            GUICtrlSetState($min2,$GUI_HIDE)
            GUICtrlSetState($min3,$GUI_HIDE)
            $pressed = 1
            WinSetState($GUI1, "", @SW_MINIMIZE)
            EndIf
    EndSwitch
EndFunc

All of the things i need are in the file. (or what you need)

maybe it can help troubleshooting


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites
AppTux

sorry, the uploading doesn't work :)


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites
PartyPooper

If all you want to do is trigger events based on whether or not the close or minimise buttons have been pressed, have you thought about using:

GUISetOnEvent($GUI_EVENT_CLOSE, "Function")

GUISetOnEvent($GUI_EVENT_MINIMIZE, "Function")

Share this post


Link to post
Share on other sites
AppTux

I understand that not really, but that is not where i was looking for

but thanks for your fast reply


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.