Sign in to follow this  
Followers 0
Burgs

Not understanding the concepts about images and backgrounds...

6 posts in this topic

Hello,

I am having trouble exactly understanding the GUI commands related to placing 'clickable' images in GUI Windows over other 'background' images...I have the following that makes a rather nice GUI interface:

...
Global $MapFile = "C:\Program Files\AppX\Files\Maps\Main.jpg"

Global $MapWidth = 768
Global $MapHeight = 576
Global $MainGUI = GUICreate("Main Interface", 1024, 768)
GUISetState(@SW_SHOW)
Sleep(500)
Map_Window()
...
Func Map_Window()
Global $MapBack = GUICreate("", $MapWidth, $MapHeight, 0, 28, $WS_CHILD, -1, $MainGUI)
GUISetState(@SW_SHOW)

; background picture
$TheMap = GUICtrlCreatePic($MapFile, 2, 0, 2048, 2048, -1, $WS_EX_CLIENTEDGE)
GUISetState(@SW_SHOW)
EndFunc

From what I understand I cannot place other images on the '$TheMap' because it needs to have certain coding, so I change that line to read:

$TheMap = GUICtrlCreatePic($MapFile, 2, 0, 2048, 2048, -1, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD))

However when I run this the window showing the '$TheMap' is blank...the image and window no longer appear. I wish to be able to 'draw' within this window ('clickable and movable' images, texts, etc...) over that background image...but I am not following the Helpfile topics as well as I would have liked...can somebody let me know what I am missing here...any advice to point me in the right direction appreciated. Thank you.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You can create a background image using GUICtrlCreatePic() but you have to disable the control to place other control over it which should react on mouse clicks (GUICtrlSetState(-1, $GUI_DISABLE)).

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

As a follow-up on this I changed the "Map_Window()" function to:

Func Map_Window()
Global $MapBack = GUICreate("", $MapWidth, $MapHeight, 0, 28, $WS_CHILD, -1, $MainGUI)
GUISetState(@SW_SHOW)

; background picture
$TheMap = GUICtrlCreatePic($MapFile, 2, 0, 2048, 2048, -1, $WS_EX_CLIENTEDGE)
GUISetState(@SW_SHOW)
Dim $graph2[31]
Dim $X_PLOT = 20
Dim $Y_PLOT = 30
For $x = 0 To UBound($graph2) - 1
; Amend the x,y coords for each graphic
$X_PLOT += 20
$Y_PLOT += 5

$graph2[$x] = GUICtrlCreatePic("C:\Program Files\AppX\Files\Test_Gif.gif", $X_PLOT, $Y_PLOT, 40, 40, BitOR($SS_NOTIFY, $SS_BLACKFRAME))
GuiCtrlSetState(-1,$GUI_DISABLE)
Next

EndFunc

That seems to create the 'pics' but they then 'disappear', I presume hidden under the "$TheMap" image...AutoIT is normaly quite easy to work with but i am finding this quite confusing...

Share this post


Link to post
Share on other sites

Thanks UEZ...when I add in:

$TheMap = GUICtrlCreatePic($MapFile, 2, 0, 2048, 2048, -1, $WS_EX_CLIENTEDGE)

GUICtrlSetState($TheMap, $GUI_DISABLE)

The images seem to create however they immediately disappear (under the "$TheMap"?)...?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

The problem is the $SS_BLACKFRAME style!

Try this:

#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $MapFile = StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUImsoobe.jpg")

Global $MapWidth = 1024
Global $MapHeight = 768
Global $MainGUI = GUICreate("Main Interface", 1024, 768)
$TheMap = GUICtrlCreatePic($MapFile, 0, 0, 1024, 768, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetState($TheMap, $GUI_DISABLE)
Map_Window()
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3

GUIDelete()
Exit

Func Map_Window()
    Dim $graph2[31]
    Dim $X_PLOT = 20
    Dim $Y_PLOT = 30
    For $x = 0 To UBound($graph2) - 1
        ; Amend the x,y coords for each graphic
        $X_PLOT += 20
        $Y_PLOT += 5
        $graph2[$x] = GUICtrlCreatePic(StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUIMerlin.gif"), $X_PLOT, $Y_PLOT, 40, 40, $SS_NOTIFY)
        GuiCtrlSetState($graph2[$x] ,$GUI_DISABLE)
    Next
EndFunc

If you want to tile an image have a look here:

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Thanks for the post UEZ...they seem to be drawing now...however I have a related question, when they draw I am getting the opposite effect of what I expected, my .gif image is a blue square surrounded by a black border (see attached). I would think the black border would be set as transparency (top left pixel, correct?) and thus only a blue square should draw...but instead I get the blue part being transparent and only a black border is drawing on the background image...what might be the reason for this?

I assume those images are 'clickable' and 'over-lap' one another without difficulty correct? I ask because I am not using the " BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD)" in the "$TheMap" background GUI as I had thought was necessary...?

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