Jump to content

Recommended Posts

Posted

Good day,
I hope that the day finds you well!

I am attempting to create what I would refer to as a "static" button...that is, a button that does not move, or display a depressed state!
• I do hope that I am stating this question correctly?

I gather that I could employ a label or a image...but can this e accomplished via the standard options
• I did check out the GUI Control Styles Appendix and the Extended Style Table - with no apparent success.

Any assistance in this matter would be greatly appreciated!

Posted

In a Graphic User Interface, the behavior of the controls have an expectation of function. Different version of windows show some differences but are basically the same.
What is this static button that is not a label nor disabled button ? What is the user to understand of it ? Show a picture with explanation ?

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)

argumentum,

Here is the script thus far...

; -----------------------------------------------
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
; -----------------------------------------------
Global $sColRow
Global $g_h_MainGui2
; -----------------------------------------------
_MainGui1()
; -----------------------------------------------
Func _MainGui1()
    Global $g_h_MainGui1 = GUICreate("  Session|Show Development Main Menu", 895, 285)
    GUISetFont(14, 800, 0, "Calibri")
    ; -----------------------------------------------
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_MainGui1")
    ; -----------------------------------------------
    Global $sCol2Row1 = GUICtrlCreateButton("Add SoundFile", 230, 10, 215, 25)
    GUICtrlSetOnEvent($sCol2Row1, "On_AddSoundFile")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $g_h_MainGui1)
    ; -----------------------------------------------
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>_MainGui1
; -----------------------------------------------
Func On_AddSoundFile()
    _AddSoundFile()
EndFunc   ;==>On_AddSoundFile
; -----------------------------------------------
Func On_Close_MainGui1()
    Exit
EndFunc   ;==>On_Close_MainGui1
; -----------------------------------------------
Func On_Close_MainGui2()
    GUIDelete($g_h_MainGui2)
    GUICtrlSetState($sCol2Row1, $GUI_ENABLE)
EndFunc   ;==>On_Close_MainGui2
; -----------------------------------------------
Func On_EnableHotKey()
    _EnableHotKey()
EndFunc   ;==>On_EnableHotKey
; -----------------------------------------------
Func _AddSoundFile()
    MsgBox($MB_OK, "", "Add SoundFile")
    GUICtrlSetState($sCol2Row1, $GUI_DISABLE)
    MsgBox($MB_OK, "", "Calling MainGui2()")
    _MainGui2()
EndFunc   ;==>_AddSoundFile
; -----------------------------------------------
Func _EnableHotKey()
    Local Static $hbHotKeyEnabled = True
    ; -----------------------------------------------
    If $hbHotKeyEnabled = True Then
        GUICtrlSetData($sColRow, "Disable")
        $hbHotKeyEnabled = False
    Else
        HotKeySet("{APPSKEY}")
        GUICtrlSetData($sColRow, "Enable")
        $hbHotKeyEnabled = True
        On_Close_MainGui2()
    EndIf
EndFunc   ;==>_EnableHotKey
; -----------------------------------------------
Func _MainGui2()
    Global $g_h_MainGui2 = GUICreate("  MainGui2", 65, 20, 115, 52, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont(14, 800, 0, "Calibri")
    GUISetBkColor(0x3D3D3D)
    ; -----------------
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_MainGui2")
    ; -----------------------------------------------
    Global $sColRow = GUICtrlCreateButton("Enable", 0, 0, 65, 20)
    GUICtrlSetOnEvent($sColRow, "On_EnableHotKey")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $g_h_MainGui2)
EndFunc   ;==>_MainGui2
; -----------------------------------------------

Here is the end result...

Hope this helps?

 

1.png

Edited by mr-es335
Posted

argumentum,

Thanks for the reply...appreciated!

You stated, "I assume that you'd like the enable/disable button to look 'static'."
• Yes...that is correct.

You then stated, "Play around with what win32 controls has to offer and settle for something that will clearly signal the state on any Windows version."
• May I ask where I can obtain the information on these "win32 controls"?

Posted
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 200, 50)
Local $iBorderSize = 1
$Label1 = GUICtrlCreateLabel("", 10 - $iBorderSize, 10 - $iBorderSize, 75 + ($iBorderSize * 2), 25 + ($iBorderSize * 2))
GUICtrlSetBkColor(-1, 0x006600)
$Button1 = GUICtrlCreateButton("Enable", 10, 10, 75, 25)
$Checkbox1 = GUICtrlCreateCheckbox("Test here", 112, 12, 75, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_PUSHLIKE))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Checkbox1
            If GUICtrlRead($Checkbox1) = 1 Then
                GUICtrlSetData($Button1, "Enable")
                GUICtrlSetBkColor($Label1, 0x006600)
            Else
                GUICtrlSetData($Button1, "Disable")
                GUICtrlSetBkColor($Label1, 0x660000)
            EndIf
    EndSwitch
WEnd

image.png.22e87b3fe843c5ded27337b561b4fc18.png

27 minutes ago, mr-es335 said:

Why?

you're very cryptic for me. The above will be identifiable anywhere.

Kirk Out

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

argumentum,

Hmmm, I was thinkin' of employing a label as well! Here is what I have:

; -----------------------------------------------
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
; -----------------------------------------------
Global $sColRow
Global $g_h_MainGui2
; -----------------------------------------------
_MainGui1()
; -----------------------------------------------
Func _MainGui1()
    Global $g_h_MainGui1 = GUICreate("  Session|Show Development Main Menu", 895, 285)
    GUISetFont(14, 800, 0, "Calibri")
    ; -----------------------------------------------
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_MainGui1")
    ; -----------------------------------------------
    Global $sCol2Row1 = GUICtrlCreateButton("Add SoundFile", 230, 10, 215, 25)
    GUICtrlSetOnEvent($sCol2Row1, "On_AddSoundFile")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $g_h_MainGui1)
    ; -----------------------------------------------
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>_MainGui1
; -----------------------------------------------
Func On_AddSoundFile()
    _AddSoundFile()
EndFunc   ;==>On_AddSoundFile
; -----------------------------------------------
Func On_Close_MainGui1()
    Exit
EndFunc   ;==>On_Close_MainGui1
; -----------------------------------------------
Func On_Close_MainGui2()
    GUIDelete($g_h_MainGui2)
    GUICtrlSetState($sCol2Row1, $GUI_ENABLE)
EndFunc   ;==>On_Close_MainGui2
; -----------------------------------------------
Func On_EnableHotKey()
    _EnableHotKey()
EndFunc   ;==>On_EnableHotKey
; -----------------------------------------------
Func _AddSoundFile()
    ;MsgBox($MB_OK, "", "Add SoundFile")
    GUICtrlSetState($sCol2Row1, $GUI_DISABLE)
    ;MsgBox($MB_OK, "", "Calling MainGui2()")
    _MainGui2()
EndFunc   ;==>_AddSoundFile
; -----------------------------------------------
Func _EnableHotKey()
    ConsoleWrite(_EnableHotKey)
    Local Static $hbHotKeyEnabled = True
    ; -----------------------------------------------
    If $hbHotKeyEnabled = True Then
        GUICtrlSetData($sColRow, "Disable")
        $hbHotKeyEnabled = False
    Else
        HotKeySet("{APPSKEY}")
        GUICtrlSetData($sColRow, "Enable")
        $hbHotKeyEnabled = True
        On_Close_MainGui2()
    EndIf
EndFunc   ;==>_EnableHotKey
; -----------------------------------------------
Func _MainGui2()
    Global $g_h_MainGui2 = GUICreate("  MainGui2", 60, 20, 115, 52, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont(14, 800, 0, "Calibri")
    GUISetBkColor(0x3D3D3D)
    ; -----------------
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_MainGui2")
    ; -----------------------------------------------
    ;Global $sColRow = GUICtrlCreateButton("Enable", 0, 0, 65, 20)
    Global $sColRow = GUICtrlCreateLabel("Enable", 0, 0, 60, 20, $SS_CENTER)
    GUISetFont(14, 800, 0, "Calibri")
    GUICtrlSetColor(-1,0xFFFFFF)
    GUICtrlSetOnEvent($sColRow, "On_EnableHotKey")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $g_h_MainGui2)
EndFunc   ;==>_MainGui2
; -----------------------------------------------

...and, here is the end result...

 

2.png

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...