Jump to content
Sign in to follow this  
Marklar

Transparent GIF

Recommended Posts

#include <GUIConstants.au3>


$MainWin=GUICreate("Select a Task",442,400,-1,-1,-1,$WS_EX_LAYERED)
$Logo=GUICtrlCreatePic("imgs\logo.gif",115,50, 230,75)
GUISetState()


While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

I have the image set to be transparent. It works in HTML pages and all that good stuff. Now, how do I get it to work in AutoIT? I read the Help file and it says to set at as $WS_EX_LAYERED.... Which I did. But I can see straight through and onto my desktop.

Any help would be appreciated

Thanks

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
$MainWin=GUICreate("Select a Task",442,400,-1,-1,-1,$WS_EX_LAYERED)
$Logo=GUICtrlCreatePic("imgs\logo.gif",115,50, 230,75)
GUISetState()
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

I have the image set to be transparent. It works in HTML pages and all that good stuff. Now, how do I get it to work in AutoIT? I read the Help file and it says to set at as $WS_EX_LAYERED.... Which I did. But I can see straight through and onto my desktop.

Any help would be appreciated

Thanks

<{POST_SNAPBACK}>

i think you need the latest beta. Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

nope... Same result

and if I take out the EX_Layered thing then the image has a black background with no transparency at all

Edited by Marklar

Share this post


Link to post
Share on other sites

this will be of no help at all... but, it doesn't look like you need to even declare the variables $MainWin and $Logo unless you're not done with your script yet :(


FootbaG

Share this post


Link to post
Share on other sites

this will be of no help at all... but, it doesn't look like you need to even declare the variables $MainWin and $Logo unless you're not done with your script yet :(

<{POST_SNAPBACK}>

lol i know.... but its good practice

Share this post


Link to post
Share on other sites

Try to specify the full path to the image-file. Like this :

$Logo=GUICtrlCreatePic(@ScriptDir & "\imgs\logo.gif",115,50, 230,75)

That should work.

Share this post


Link to post
Share on other sites

It doesn't work. Period. Transparency in images is not supported, except as a transparent mask for the entire GUI.

Your option is thus: Have one GUI with just the image, transparency and everything, just like you have it now, GUI(1). Then have another GUI with whatever you want in the background, GUI(2). Have GUI(1) be a child of GUI(2).

If you're using the latest beta, you can find example code at "*AutoIt Folder*\tests\gui\pic transparent on pic.au3"

Share this post


Link to post
Share on other sites

Well that was strange, because I replaced Marklar's line with the line I posted above,

and it worked...! As far as I remember, the only other thing I added was the

GUI-style $WS_POPUP.

As I've moved my ass a couple of hundred meters away from where I was half an

hour ago, and to a Macintosh, I'm unable to give you the test right now.... Later.

(If I remember correctly I think I tested something like this, when I was back home

last week, on my own computer running WinXP, and it failed. When tested today it was

running on Win2000... It probably has nothing do with it, though.)

It doesn't work. Period. Transparency in images is not supported, except as a transparent mask for the entire GUI.

Your option is thus: Have one GUI with just the image, transparency and everything, just like you have it now, GUI(1). Then have another GUI with whatever you want in the background, GUI(2). Have GUI(1) be a child of GUI(2).

If you're using the latest beta, you can find example code at "*AutoIt Folder*\tests\gui\pic transparent on pic.au3"

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites

Well that was strange, because I replaced Marklar's line with the line I posted above,

and it worked...! As far as I remember, the only other thing I added was the

GUI-style $WS_POPUP.

As I've moved my ass a couple of hundred meters away from where I was half an

hour ago, and to a Macintosh, I'm unable to give you the test right now.... Later.

(If I remember correctly I think I tested something like this, when I was back home

last week, on my own computer running WinXP, and it failed. When tested today it was

running on Win2000... It probably has nothing do with it, though.)

<{POST_SNAPBACK}>

I think maybe we are just misunderstanding eachother, or the original poster.

What I understood from the original post, was that Marklar wanted to put an image on his GUI, and have the colour he designated as transparent appear transparent, ON the GUI window. Not unlike this image here:

Posted Image

Notice how you can see the forum background colour around the image. But if you were to load this image into an editor, you'd see that the background colour is bright green.

Also, if you attempt to load this image into a GUI, you will see the bright green background colour. You can however supply $WS_EX_LAYERED to the GUICreate, which makes the GUI itself transparent, hence his comment about being able to see his desktop through the GUI. But I don't think that's what he wants.

If you look at this image:

Posted Image

Ex. 1 is without using $WS_EX_LAYERED

Ex. 2 is with using $WS_EX_LAYERED (that's your avatar in the background Helge :()

Ex. 3 is the one that I believe is currently impossible but is also what Marklar is after.

Share this post


Link to post
Share on other sites

It doesn't work. Period. Transparency in images is not supported, except as a transparent mask for the entire GUI.

Your option is thus: Have one GUI with just the image, transparency and everything, just like you have it now, GUI(1). Then have another GUI with whatever you want in the background, GUI(2). Have GUI(1) be a child of GUI(2).

If you're using the latest beta, you can find example code at "*AutoIt Folder*\tests\gui\pic transparent on pic.au3"

Okay this works. Thanks

Unfortunately it wont help me for my current project because I am using multiple tabs and each tab takes up the whole window... Depending where I place the popup gui the tabs wont show up. Then if I can get the tabs to show up the logo (which is supposed to only show on the first tab) will show up on every other tab.. I tried a @SW_HIDE but only found problems.

It may be possible, but I'll just have to mess with it. Until then I'll probably have to wait until gif is supported (please :()

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

$gui=GUICreate("test", 150, 150)
GUISetBkColor(0x00ffff)
GUISetState(@SW_SHOW)

$pic=GUICreate("", 44, 80, 50, 50,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui)
$Logo = GUICtrlCreatePic ("transparent.gif", 0, 0,0,0)

GUISetState()

do
    $msg = GUIGetMsg()
    
until $msg = $GUI_EVENT_CLOSE

What do you think? :(

Share this post


Link to post
Share on other sites

If you're using tabs, then Holger wrote some good example code that shows how to use tabs/child GUIs.

Lemme find it here...

*Edit: Found it. Maybe this will provide some help.

<{POST_SNAPBACK}>

Wow.. When i try to adapt that to what i need i get overwhelmed. I've got child windows on top of child windows... Heh.. im gonna have to look at that one for a while

But you wanna know whats really weird. This attached file works. Its transparent just the way I want it and what is apparently impossible. Yet this works? And its only with this BMP file.. Thats right its not even a gif file

And here is the code

#include <GuiConstants.au3>
GuiCreate("What the ???", 200, 200,200,250,-1)

GUICtrlCreatePic("ie.bmp",65,50,0,0)
GUICtrlCreateLabel("It only appears to work with this certain bmp file_
    .... Its not even a gif???",65,105,90,90)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    EndSelect
WEnd

HuhWhat.zip

Share this post


Link to post
Share on other sites

Update: The above attachment seems to only work on Windows XP not Windows 98.

Edited by Marklar

Share this post


Link to post
Share on other sites

@Marklar: Wow.. that really is odd...

@jpm: Yeah, that's basically the same method used in "pic transparent on pic.au3" in the tests folder. But here's a question, do you know of a way to have it so that the child window is restricted to within the parent? Like the Yum example here?

Posted Image

Share this post


Link to post
Share on other sites

Yes and no you have to compute the position of thechild window to stay in the parent area.

No automatic process. :(

You can handle the $GUI_EVENT_RESIZED special event and use GuiCtrlSetPos on the child window.

Good computation

Share this post


Link to post
Share on other sites

@Saunders :

Oooh, of course.

Man, I have to stop posting so late at night..

(/early in the morning).. :(

Share this post


Link to post
Share on other sites

This may help as a workaround.

I set a background colour for the window using GUISetBkColor

Then using your favourite program change your image to set the layer that you want to end up as transparent to be the same colour as the window background.

I know it's not pretty, but it works.


AutoIt is great - leave me alone and I'll play for hours

Share this post


Link to post
Share on other sites

Hm, the *.AVI-files from, for example the shell32.dll, can be used with transparence (at least at a common gray window).

Maybe you should convert your *.gif in a "one-frame-avi" :whistle: ...

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...