Jump to content

I’m using WinMove($w,””,-10000,-10000) instead of @SW_HIDE, but I know it’s wrong

Recommended Posts

I’ve been using WinMove to send windows silently to the outer unseen reaches, because it is so much easier than Hiding with ???SetState.

Why easier?  Because it doesn’t need a redraw after the @SW_SHOW and it even lets me draw on it when it’s off screen.

But I know in my heart it’s wrong.  I know I could also loop around waiting for GUI messages, but even that seems more complicated.

Is there a way to accomplish what I am doing without winmove but still has

  1. No unnecessary redrawing 
  2. No looping for repaint messages
  3. Drawing on hidden objects

Because of this sites known lust for code, I am providing the following working code, and two .pngs.

The code is simplified, but represents a status bar indicator which is either Red, Green and either Hidden or Not Hidden. The Random generator is just used to simulate the various combinations and sequences of states that can occur.


#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>
#include <WinAPIShPath.au3>
#include <WinAPIFiles.au3>
#include <WinAPI.au3>
#Include <GDIPlus.au3>

Local $statusBar, $sGraphic



Local $runningImage=_GDIPlus_ImageLoadFromFile("green.png")
Local $stoppedImage=_GDIPlus_ImageLoadFromFile("red.png")



   Local $isRunning=Random(False,True,1)

   If $isRunning Then 

   Local $isVisible=Random(False,True,1)

   If $isVisible Then
     WinMove($statusBar, "", 0, 0) 
     WinMove($statusBar, "", -10000, -10000) 


Until False

Func CreateStatusBar()
Local $tcolor=0x12356

$statusBar=GUICreate("STATUS", 100,100,0,0,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_TOPMOST))
_WinAPI_SetLayeredWindowAttributes($statusBar, $tcolor,255)

GUISetState(@SW_SHOWNA, $statusBar)


Func DrawStatusBar($image)
Static Local $lastImage=""

If $image=$lastImage Then Return







Edited by JockoDundee

Code hard, but don’t hard code...

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

    No registered users viewing this page.

  • Create New...