Sign in to follow this  
Followers 0
ChrisL

Detecting if another window has crossed your gui

3 posts in this topic

When using anygui to add a picture to another gui sometimes if another window is dragged over the top the added picture doesn't always repaint. (See attached screen shot)

I can force it to repaint every 10 seconds or so but I was looking for a more elegant method for triggering a repaint.

Is it possible to detect when another window has been dragged over the top of your gui?

#include <guiconstants.au3>
#include <anyguiv2.8.au3>
Run ( "calc" )
WinWait ( "Calculator" )
$Pos = WinGetPos ( "Calculator" )
WinMove ( "Calculator", '', (@DesktopWidth-$Pos[2])/2, (@DesktopHeight-$Pos[3])/2, $Pos[2] + 47, $Pos[3] )
_GuiTarget ( "Calculator", 1 )
$Quit = _TargetAddButton ( "Quit", $Pos[2]-10, 37, 50, 29 )
$Quit = $Quit[0]
GUISetState ( )
_TargetAddLabel ( "Notepad", $Pos[2]-10, 66, 50, 18 )
GUISetState ( )
_TargetAddPic ( "D:\My Documents\AutoITscripts\OrderManager2\gfx\ONButton.bmp", $Pos[2]-10, 84, 50, 115 )

GUISetState ( )
While 1
    $msg = GUIGetMsg ( )
    If $msg = $Quit Then Exit
    If Not WinExists ( "Calculator" ) Then Exit
WEnd

Func OnAutoItExit()
    ProcessClose ( "calc.exe" )
EndFunc

Share this post


Link to post
Share on other sites



Is it possible to detect when another window has been dragged over the top of your gui?

Not without polling (or system-wide hook) to check your window's rectangle against suspects' rectangles with IntersectRect API, I think.

Anyway, your problem is repaint, so that's what you should concentrate on.

;...
$aPic = _TargetAddPic ( "D:\My Documents blah blah")

GUIRegisterMsg($WM_PAINT, 'WM_PAINT')

;...

Func WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _WinAPI_InvalidateRect($aPic[1])
    Return $GUI_RUNDEFMSG
EndFunc

as a start.


"be smart, drink your wine"

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