Sign in to follow this  
Followers 0
aGorilla

Using a checkbox for 'Stay on Top' feature.

3 posts in this topic

Like the title says, I want to have a checkbox that determines whether the window should 'stay on top', or not.

I've tried variations on this, but none of them are working. All suggestions welcome.

#include <GUIConstants.au3>

Opt('GUIOnEventMode', 1)
Opt('GUICoordMode', 2)

Global $Win_Data, $Stay

ShowData()
While 1
  sleep(250)
Wend

Func ShowData()
  Local $lh, $lw, $vh, $vw, $ClickDone

  $Win_Data = GUICreate( 'The Top Window', 390, 250, -1, -1, _
    $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS _
  )

  $Stay = GUICtrlCreateCheckbox('Stay On Top', 10, 10, 100, 20) 

  GUICtrlSetOnEvent($Stay, 'DataStay')
  GUISetOnEvent($GUI_EVENT_CLOSE, 'DataDone')

  GUISetState(@SW_SHOW, $Win_Data);Show GUI
EndFunc

Func DataDone()
  GUIDelete($Win_Data);Kill GUI
EndFunc

Func DataStay()
  If GUICtrlRead($Stay) = 1 Then
    Local $stay = GUISetStyle($WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS, $WS_EX_TOPMOST, $Win_Data)
  Else
    GUISetStyle($WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS, 0, $Win_Data)
  EndIf
EndFunc

Share this post


Link to post
Share on other sites



Like the title says, I want to have a checkbox that determines whether the window should 'stay on top', or not.

I've tried variations on this, but none of them are working. All suggestions welcome.

#include <GUIConstants.au3>

Opt('GUIOnEventMode', 1)
Opt('GUICoordMode', 2)

Global $Win_Data, $Stay

ShowData()
While 1
  sleep(250)
Wend

Func ShowData()
  Local $lh, $lw, $vh, $vw, $ClickDone

  $Win_Data = GUICreate( 'The Top Window', 390, 250, -1, -1, _
    $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS _
  )

  $Stay = GUICtrlCreateCheckbox('Stay On Top', 10, 10, 100, 20) 

  GUICtrlSetOnEvent($Stay, 'DataStay')
  GUISetOnEvent($GUI_EVENT_CLOSE, 'DataDone')

  GUISetState(@SW_SHOW, $Win_Data);Show GUI
EndFunc

Func DataDone()
  GUIDelete($Win_Data);Kill GUI
EndFunc

Func DataStay()
  If GUICtrlRead($Stay) = 1 Then
    Local $stay = GUISetStyle($WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS, $WS_EX_TOPMOST, $Win_Data)
  Else
    GUISetStyle($WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS, 0, $Win_Data)
  EndIf
EndFunc
Modify your DataStay() function to use WinSetOnTop() instead of GUISetStyle():

Func DataStay()
    If GUICtrlRead($Stay) = $GUI_CHECKED Then
        WinSetOnTop($Win_Data,"", 1)
    Else
        WinSetOnTop($Win_Data,"", 0)
    EndIf
EndFunc

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

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  
Followers 0