Jump to content

GUISetStyle() problem?


Recommended Posts

Hello everyone.

I have run into a problem that is somewhere along the lines of GUISetStyle() does not really function as it should. In one of my programs, I had $WS_EX_TOPMOST as the extended style of the GUI. When I added functionality for a tray item to change whether or not the GUI had this style applied, I found that GUISetStyle did not do anything. Maybe I did something wrong? But then, I set up a test program and found that if I created the GUI without setting the style, and then using GUISetStyle() right afterwards, nothing happened (the GUI did not stay on top of the other windows). Here is the test program that I used. Did I use the function wrong, or why is the style not being set?

Thanks.

Here is the program:

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>
#include <Constants.au3>



Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)

TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "trayExit")


TrayCreateItem("Keep GUI On Top of Other Windows")
TrayItemSetState(-1, $TRAY_CHECKED)
TrayItemSetOnEvent(-1, "trayKeepGUIOnTop")


Global $boolKeepGUIOnTop = True


Global $hForm = GUICreate("Lark Autoclicker", 580, 550)
ConsoleWrite(GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_TOPMOST, $hForm) & @CRLF & @CRLF)

GUISetState()


Do
Until GUIGetMsg() = -3





Func trayKeepGUIOnTop()
If $boolKeepGUIOnTop Then; if its true then set it to false and get rid of the style of the GUI
ConsoleWrite("true" & @CRLF)
$boolKeepGUIOnTop = False
ConsoleWrite(GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), 0) & @CRLF & @CRLF); set the GUI to its default style
Else
ConsoleWrite("false" & @CRLF)
$boolKeepGUIOnTop = True; its false so set it to true
GUISetStyle(-1, $WS_EX_TOPMOST); set the GUI to stay on top
EndIf
EndFunc


Func trayExit(); for the tray item "Exit"
Exit
EndFunc
Link to comment
Share on other sites

Isnt $WS_EX_TOPMOST used for Guis when creating more than 1 Gui to set on top of other gui or not?

if your looking to set on top use

WinSetOnTop($hForm, "", 1)

play around with

#include <Constants.au3>
#include <WindowsConstants.au3>
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "trayExit")
TrayCreateItem("Keep GUI On Top of Other Windows")
TrayItemSetState(-1, $TRAY_CHECKED)
TrayItemSetOnEvent(-1, "trayKeepGUIOnTop")
Global $boolKeepGUIOnTop = True
Global $hForm = GUICreate("Lark Autoclicker1", 580, 550)
Global $hForm1 = GUICreate("Lark Autoclicker2", 580, 550)
GUISetState(@SW_SHOW,$hForm)
GUISetState(@SW_SHOW,$hForm1)
GUISetStyle(-1, $WS_EX_TOPMOST,$hForm1)
Do
Until GUIGetMsg() = -3
Func trayKeepGUIOnTop()
    If $boolKeepGUIOnTop Then; if its true then set it to false and get rid of the style of the GUI
        $boolKeepGUIOnTop = False
;~ WinSetOnTop($hForm, "", 0)
    Else
        $boolKeepGUIOnTop = True; its false so set it to true
;~ WinSetOnTop($hForm, "", 1)
    EndIf
EndFunc   ;==>trayKeepGUIOnTop

Func trayExit(); for the tray item "Exit"
    Exit
EndFunc   ;==>trayExit

change from

GUISetStyle(-1, $WS_EX_TOPMOST,$hForm1)

to

GUISetStyle(-1, $WS_EX_TOPMOST,$hForm)

for effect

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

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