Sign in to follow this  
Followers 0
qwert

Is an overlay graphic possible?

7 posts in this topic

#1 ·  Posted (edited)

I've been trying to fashion a way to have a graphic overlay a portion of a GUI that contains buttons and other images. I want the graphic to lay on top of those elements and effectively disable them from user actions until it is removed. So far, nothing has worked, Here's what I have:

#include <GUIConstants.au3>

$main=GUICreate("Display With Overlay",300,300,400,200)
GUICtrlSetState(-1,$GUI_DISABLE)
$BG = GUICtrlCreatePic(@ScriptDir&"\BG.bmp",0,0,300,300)
GUICtrlSetState(-1,$GUI_DISABLE)
$Btn1 = GUICtrlCreateButton( "Overlay", 40, 40, 50, 20) 
$Btn2 = GUICtrlCreateButton( "Normal", 120, 220, 50, 20) 
GUISetState()
$Overlay = ""

While 1
    $gMsg = GUIGetMsg()
    Switch $gMsg
        Case -3 
            Exit
        Case $Btn1 
            $Overlay = GUICtrlCreatePic(@ScriptDir&"\FG.bmp",0,0,300,200)           
        Case $Btn2
            If $Overlay Then GUICtrlDelete($Overlay)    
    EndSwitch
WEnd

Below is an image showing the (partial) effect. The "Normal" button should always stay active and is used to remove the overlay. The "Overlay" button, once clicked, should be covered up by the overlay image and shouldn't be clickable until the overlay is removed. The script above also suffers from the fact that the Overlay button sometimes requires several clicks before it has any effect -- and (of course) that the Normal button doesn't remove the overlay.

Is this kind of thing even possible? Thanks in advance for any advice.

post-29172-1210259402_thumb.png

Edited by qwert

Share this post


Link to post
Share on other sites



When you overlay... just GUICtrlSetState the controls to $GUI_HIDE and back to $GUI_SHOW on $btn2.

Lar.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites

When you overlay... just GUICtrlSetState the controls to $GUI_HIDE and back to $GUI_SHOW on $btn2.

Actually, I forgot to mention that that's what I'm trying to avoid. In my real script I have nearly 30 buttons and graphics that I'm trying to hide/deactivate with the overlay. I'm striving for a "Now you see 'em/Now you don't" macro effect.

But thanks for your response.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Make a child-gui :) This is always TopMost :(

$Disable = GUICreate("TH",100,100,0,0,$WS_POPUP+$WS_CHILD,-1,$GUI_to_DISABLE)

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Make a child-gui :)

That's more like what was hoping for. Here's what I did:

#include <GUIConstants.au3>

$main=GUICreate("Main Display",300,300,400,200)
GUICtrlSetState(-1,$GUI_DISABLE)
$BG = GUICtrlCreatePic(@ScriptDir&"\BG.bmp",0,0,300,300)
GUICtrlSetState(-1,$GUI_DISABLE)
$Btn1 = GUICtrlCreateButton( "Overlay", 40, 40, 50, 20) 
$Btn2 = GUICtrlCreateButton( "Normal", 120, 220, 50, 20) 
GUISetState()
$Overlay = ""

While 1
    $gMsg = GUIGetMsg()
    Switch $gMsg
        Case -3 
            Exit
        Case $Btn1 
            MsgBox(0,"Action", "Overlay requested", 1)
            $Overlay = GUICreate("TH",300,200,0,0,$WS_POPUP+$WS_CHILD,-1,$main)
            GUICtrlCreatePic(@ScriptDir&"\FG.bmp",0,0,300,200)
            GUISetState(@SW_SHOW, $Overlay)
        Case $Btn2
            If $Overlay Then 
                GUIDelete($Overlay) 
                MsgBox(0,"Action", "Overlay deleted", 1)
            EndIf
    EndSwitch
WEnd

The problem is the child GUI has its own screen coordinates. How do I confine it to stay within the parent GUI? Or do I have to read the parent position and use those coordinates. I prefer to have it "bound" to the parent as a true overlay. (BTW, this is the first child window I've worked with.)

Thanks very much for your help.

Share this post


Link to post
Share on other sites

How do I confine it to stay within the parent GUI?

The answer is:

Add $WS_EX_MDICHILD in place of the -1 extended style for the child window.

As far as I can tell, this works perfectly.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Well, I have almost gotten the result I was after -- but things still aren't working right.

#include <GUIConstants.au3>

$main=GUICreate("Main Display",300,300,840,200,$WS_POPUP,$WS_EX_LAYERED)
GUICtrlSetState(-1,$GUI_DISABLE)
$BG = GUICtrlCreatePic(@ScriptDir&"\BG.bmp",0,0,300,300)
GUICtrlSetState(-1,$GUI_DISABLE)
$ExitButton = GUICtrlCreateLabel("X", 230, 0, 20, 20, $SS_NOTIFY + $SS_CENTER)
$Btn1 = GUICtrlCreateButton( "Add Overlay", 40, 40, 100, 20) 
$Btn2 = GUICtrlCreateButton( "Normal", 120, 220, 50, 20) 
$Btn3 = ""
GUISetState()
$Overlay = ""

While 1
    $gMsg = GUIGetMsg()
    Switch $gMsg
        Case -3, $ExitButton 
            Exit
        Case $Btn1 
            $Overlay = GUICreate("TH",300,200,-3,-29,BitOR($WS_POPUP, $WS_CHILD),$WS_EX_MDICHILD,$main)
            GUICtrlCreatePic(@ScriptDir&"\FG.bmp",0,0,300,200)
GUICtrlSetState(-1,$GUI_DISABLE)
            $Btn3 = GUICtrlCreateButton( "Remove Overlay", 120, 40, 100, 20) 
            GUISetState()
            GUISetState(@SW_SHOW, $Overlay)
        Case $Btn2                      ;"normal"
            If $Overlay Then GUIDelete($Overlay)    
        Case $Btn3                      ;"remove"
            If $Overlay Then GUIDelete($Overlay)    
    EndSwitch
WEnd

I'm attempting (now) to use a round-cornered graphic (see examples) -- and use an overlay with round corners on the top half, as well. The overlay comes up properly and masks the underlying controls -- and can be taken away with the Normal button. However, two aspects don't work:

The Remove button on the overly doesn't work, but it appears to activate when clicked. FIXED by disabling graphic.

The overlay has the same orange transparency color as the parent graphic, but the orange shows (doesn't render as transparent, like it does on the parent graphic background).

Plus, I the overlay GUI has to be positioned with -3, -29 coordinates to make it align -- and I haven't found any explanation for that.

Help on these things will be greatly appreciated. Only one problem remains!

post-29172-1210372936_thumb.png

post-29172-1210372945_thumb.png

Edited by qwert

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