Jump to content
pixelsearch

@SW_SHOWDEFAULT vs $WS_EX_TOPMOST

Recommended Posts

pixelsearch
Posted (edited)

Hi all,
When creating a GUI, we often want it to stay on top, no matter any other window we clic on.
To achieve this, I found 2 different ways. When you run the following script, just clic on any other window and see how the GUI will stay on top :

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

For $i = 1 to 2
   If $i = 1 Then
      $hGui = GUICreate("1 - @SW_SHOWDEFAULT", 300, 300, -1, -1, _
         $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX + $WS_SIZEBOX, @SW_SHOWDEFAULT)
   Else
      $hGui = GUICreate("2 - $WS_EX_TOPMOST", 300, 300, -1, -1, _
         BitOr($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX), $WS_EX_TOPMOST)
   EndIf
   GUISetState(@SW_SHOW)
   While GUIGetMsg() <> $GUI_EVENT_CLOSE
   WEnd
   GUIDelete($hGui)
Next

It appears that @SW_SHOWDEFAULT or $WS_EX_TOPMOST do the same job, both keeping the window on top.

The question is : anyone knows if one of them should always be used instead of the other, for a particular reason ?

 

Edited by pixelsearch

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

×