Jump to content

(solved)GUISetstyle what am I doing wrong?


 Share

Recommended Posts

I have the following code which is meant to change the "extended style" of all the GUIs in the project, but it doesn't want to take.  I thought I followed the help file, when the tray icon is checked, leave the standard styles as their defaults and add $WS_EX_TOPMOST to the extended styles, and when unchecked, set the styles back to what the GUI was originally created with.  Please help:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.15.0 (Beta)
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GUIConstantsEx.au3>
; *** End added by AutoIt3Wrapper ***
; *** Start added by AutoIt3Wrapper ***
#include <FontConstants.au3>
; *** End added by AutoIt3Wrapper ***
; *** Start added by AutoIt3Wrapper ***
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
; *** End added by AutoIt3Wrapper ***
; *** Start added by AutoIt3Wrapper ***
#include <GUIConstants.au3>
; *** End added by AutoIt3Wrapper ***
; *** Start added by AutoIt3Wrapper ***
#include <AutoItConstants.au3>
#include <ListBoxConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <FileConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <Constants.au3>
#include <Misc.au3>
#include <GuiButton.au3>
#include <MsgBoxConstants.au3>
#include <GuiListBox.au3>
#include <GuiListView.au3>
#include <Crypt.au3>
Const $path = @AppDataDir & "\filler"
Opt ( "TrayMenuMode", 1 )
$nonote = False
$TrayMenu = TrayCreateMenu ( "Settings" )
$settings1 = TrayCreateItem ( "Turn off notifications", $TrayMenu )
TrayItemSetState ( -1, Int ( IniRead ( $path & "\infostore.ini", "Tray Settings", "No Notifications", "68" ) ) )
$settings2 = TrayCreateItem ( "Keep Window on top", $TrayMenu )
TrayItemSetState ( -1, Int ( IniRead ( $path & "\infostore.ini", "Tray Settings", "On top", "68" ) ) )

$Form1_1 = GUICreate("Form filler", 701, 659, 317, 125, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP))
If TrayItemGetState ( $settings2 ) = 65 Then
    GUISetStyle ( -1, $WS_EX_TOPMOST )
EndIf
GUISetState(@SW_SHOW, $Form1_1)
While 1
    $tmsg = TrayGetMsg ()
    $nMsg = GUIGetMsg()
    Switch $tmsg
        Case $TrayMenu
        Case $settings1
            #Region --- CodeWizard generated code Start ---

;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=None
MsgBox($MB_OK,"State",TrayItemGetState ($settings1))
#EndRegion --- CodeWizard generated code End ---

            If TrayItemGetState ( $settings1 ) = 65 Then
                IniWrite ( $path & "\infostore.ini", "Tray Settings", "No Notifications", "65" )
            ElseIf TrayItemGetState ( $settings1 ) = 68 Then
                IniWrite ( $path & "\infostore.ini", "Tray Settings", "No Notifications", "68" )
            Else
            EndIf

        Case $settings2

            If TrayItemGetState ( $settings2 ) = 65 Then
                IniWrite ( $path & "\infostore.ini", "Tray Settings", "On top", "65" )
                GUISetStyle ( -1, $WS_EX_TOPMOST, $Form1_1 )
            ElseIf TrayItemGetState ( $settings2 ) = 68 Then
                IniWrite ( $path & "\infostore.ini", "Tray Settings", "On top", "68" )
                GUISetStyle ( BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP), 0, $Form1_1 )
            Else
            EndIf

    EndSwitch

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

While this is a snippet of the code, it is the portion which illustrates my issue and can be compiled, so have at it.

Edited by MattHiggs
Link to comment
Share on other sites

I've never had any luck with getting GUISetStyle to work. Try this instead

Case $settings2
            ; If window does not have the $WS_EX_TOPMOST
            If (BitAND(_WinAPI_GetWindowLong($Form1_1, $GWL_EXSTYLE), $WS_EX_TOPMOST) <> $WS_EX_TOPMOST) Then
                WinSetOnTop($Form1_1, "", True)
            Else
                WinSetOnTop($Form1_1, "", False)
            EndIf

 

Link to comment
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
 Share

×
×
  • Create New...