Sign in to follow this  
Followers 0
FeReNGi

How to make a label transparant on a bitmap

12 posts in this topic

#1 ·  Posted (edited)

Does anybody has an example how to make a label transparent on a bitmap ?

I made some code :

Splahscreen("Starting....")

; ----------------------------------------------------------------------------
; Info screen for user
; ----------------------------------------------------------------------------
Func SplashScreen($Splashtext)
    local $Font="Comic Sans MS" 
    Local $guiSplash = GUICreate("Title", 550, 150, -1, -1, BitOR($WS_POPUP, $WS_VISIBLE), BitOR($WS_EX_DLGMODALFRAME, $WS_EX_TOPMOST, $WS_EX_LAYERED ))
    
    GUICtrlCreatePic(@ScriptDir & "\notes.jpg",10,10, 0,0,0)
    GuiCtrlSetState(-1,$GUI_DISABLE)
    
    Local $Lbl= GUICtrlCreateLabel("TEST- TEST - TEST", 350, 25, 185, 30, -1)
    GUICtrlSetFont (-1,12, 400, 2, $Font)
    GUICtrlSetBkColor($Lbl, $GUI_BKCOLOR_TRANSPARENT)
    

    Local $Lbl2= GUICtrlCreateLabel($Splashtext, 30, 100, 230, 120)
    GUICtrlSetFont (-1,12, 400, 4, $Font)

    
    GUISetState()
    Sleep(5000)
    
EndFunc

My test label doesn't show the picture but is gray.

Any help would be welcome

Edited by FeReNGi

Share this post


Link to post
Share on other sites



#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>

SplashScreen("Starting....")

; ----------------------------------------------------------------------------
; Info screen for user
; ----------------------------------------------------------------------------
Func SplashScreen($Splashtext)
    local $Font="Comic Sans MS"    
    Local $guiSplash = GUICreate("Title", 550, 150, -1, -1, BitOR($WS_POPUP, $WS_VISIBLE), BitOR($WS_EX_DLGMODALFRAME, $WS_EX_TOPMOST ))
    
    GUICtrlCreatePic(@SystemDir & "\oobe\images\wpaflag.jpg",0,0, 550,150, -1, $WS_EX_TRANSPARENT )
    GuiCtrlSetState(-1,$GUI_DISABLE)
    
    Local $Lbl= GUICtrlCreateLabel("TEST- TEST - TEST", 350, 25, 185, 30)
    GUICtrlSetFont (-1,12, 400, 2, $Font)
    GUICtrlSetBkColor($Lbl, $GUI_BKCOLOR_TRANSPARENT)
    

    Local $Lbl2= GUICtrlCreateLabel($Splashtext, 30, 100, 230, 120)
    GUICtrlSetFont (-1,12, 400, 4, $Font)
    GUICtrlSetBkColor($Lbl2, $GUI_BKCOLOR_TRANSPARENT)

    
    GUISetState()
    Sleep(5000)
    
EndFunc


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Sorry to revive this old, old, old thread.

But this new thread (Link; Aug 25, 2008) was made on this topic and Zedna redirected the user here.

Now, I had the same question - but I tried your example using Au3.2.12.1 and couldn't see the labels on top of the background image - just the background image covering everything.

Have one of the constants changed since 2006 or something?

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

Yeah, I am the one that Zedna sent here, but all I see is the windows flag thing, and then it closes. I don't see how this relates to setting an image as a background and then using controls on top of it...


Christianity: In the beginning, there was God, who always was there and created everything.Atheism: In the beginning, there was nothing, which exploded. Both sides look bad...

Share this post


Link to post
Share on other sites

Yeah, I am the one that Zedna sent here, but all I see is the windows flag thing, and then it closes. I don't see how this relates to setting an image as a background and then using controls on top of it...

Remove the $WS_EX_TRANSPARENT extended style from the Pic.

GUICtrlCreatePic(@SystemDir & "\oobe\images\wpaflag.jpg",0,0, 550,150, -1);, $WS_EX_TRANSPARENT )

then the labels will show.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

ok, I took that out, and it worked fine. So now to try and solve my own question, I substituted the original image location for the one I want to set, and it worked fine with the original image's dimensions (so the image is all scrunched up), but when I try to set it to a variable (which is defined by another function that finds the dimensions of the image I want), it doesnt work anymore. Any ideas? By the way, ignore the splashscreen stuff, I am just trying to build mine out of the one posted on here earlier. Here's the code:

CODE
#include <GDIPlus.au3>

#include <GuiComboBox.au3>

#include <File.au3>

#include <Array.au3>

#include <WindowsConstants.au3>

#include <GuiConstantsEx.au3>

#include <ButtonConstants.au3>

#Include <GuiListView.au3>

SplashScreen("Starting....")

; ----------------------------------------------------------------------------

; Info screen for user

; ----------------------------------------------------------------------------

Func SplashScreen($Splashtext)

; Load PNG file as GDI bitmap

_GDIPlus_Startup()

$pngSrc = "C:\Documents and Settings\Compaq_Administrator\Desktop\172_panel2.png"

$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)

; Extract image width and height from PNG

$width = _GDIPlus_ImageGetWidth($hImage)

$height = _GDIPlus_ImageGetHeight($hImage)

local $Font="Comic Sans MS"

Local $guiSplash = GUICreate("Title", $width, $height, -1, -1, BitOR($WS_POPUP, $WS_VISIBLE), BitOR($WS_EX_DLGMODALFRAME, $WS_EX_TOPMOST ))

GUICtrlCreatePic($pngSrc,0,0, $width,$height, -1)

GuiCtrlSetState(-1,$GUI_DISABLE)

;$WS_EX_TRANSPARENT

Local $Lbl= GUICtrlCreateLabel("TEST- TEST - TEST", 350, 25, 185, 30)

GUICtrlSetFont (-1,12, 400, 2, $Font)

GUICtrlSetBkColor($Lbl, $GUI_BKCOLOR_TRANSPARENT)

Local $Lbl2= GUICtrlCreateLabel($Splashtext, 30, 100, 230, 120)

GUICtrlSetFont (-1,12, 400, 4, $Font)

GUICtrlSetBkColor($Lbl2, $GUI_BKCOLOR_TRANSPARENT)

GUISetState()

Sleep(5000)

EndFunc

EDIT: I fixed part of the problem and swapped the code out for the partially fixed one, so now I get a big gray screen the size of the picture, but no picture.

Edited by theholycow

Christianity: In the beginning, there was God, who always was there and created everything.Atheism: In the beginning, there was nothing, which exploded. Both sides look bad...

Share this post


Link to post
Share on other sites

ok, I took that out, and it worked fine. So now to try and solve my own question, I substituted the original image location for the one I want to set, and it worked fine with the original image's dimensions (so the image is all scrunched up), but when I try to set it to a variable (which is defined by another function that finds the dimensions of the image I want), it doesnt work anymore. Any ideas? By the way, ignore the splashscreen stuff, I am just trying to build mine out of the one posted on here earlier. Here's the code:

CODE
#include <GDIPlus.au3>

#include <GuiComboBox.au3>

#include <File.au3>

#include <Array.au3>

#include <WindowsConstants.au3>

#include <GuiConstantsEx.au3>

#include <ButtonConstants.au3>

#Include <GuiListView.au3>

SplashScreen("Starting....")

; ----------------------------------------------------------------------------

; Info screen for user

; ----------------------------------------------------------------------------

Func SplashScreen($Splashtext)

; Load PNG file as GDI bitmap

_GDIPlus_Startup()

$pngSrc = "C:\Documents and Settings\Compaq_Administrator\Desktop\172_panel2.png"

$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)

; Extract image width and height from PNG

$width = _GDIPlus_ImageGetWidth($hImage)

$height = _GDIPlus_ImageGetHeight($hImage)

local $Font="Comic Sans MS"

Local $guiSplash = GUICreate("Title", $width, $height, -1, -1, BitOR($WS_POPUP, $WS_VISIBLE), BitOR($WS_EX_DLGMODALFRAME, $WS_EX_TOPMOST ))

GUICtrlCreatePic($pngSrc,0,0, $width,$height, -1)

GuiCtrlSetState(-1,$GUI_DISABLE)

;$WS_EX_TRANSPARENT

Local $Lbl= GUICtrlCreateLabel("TEST- TEST - TEST", 350, 25, 185, 30)

GUICtrlSetFont (-1,12, 400, 2, $Font)

GUICtrlSetBkColor($Lbl, $GUI_BKCOLOR_TRANSPARENT)

Local $Lbl2= GUICtrlCreateLabel($Splashtext, 30, 100, 230, 120)

GUICtrlSetFont (-1,12, 400, 4, $Font)

GUICtrlSetBkColor($Lbl2, $GUI_BKCOLOR_TRANSPARENT)

GUISetState()

Sleep(5000)

EndFunc

EDIT: I fixed part of the problem and swapped the code out for the partially fixed one, so now I get a big gray screen the size of the picture, but no picture.

png is not supported by GuiCtrlCreatePic so you need to use GDI functions.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I GOT IT! Thanks, I just resaved that png as a jpg and used the png for the dimensions and the jpg for the GUICTRLCREATEPIC , they have the same dimensions so it works. Thanks


Christianity: In the beginning, there was God, who always was there and created everything.Atheism: In the beginning, there was nothing, which exploded. Both sides look bad...

Share this post


Link to post
Share on other sites

...Except now I created a button and I can't push it.... And if i add a whilewend and take out the sleep, I can't close it unless I use task manager.

CODE
#include <GDIPlus.au3>; this is where the magic happens, people

#include <GuiComboBox.au3>

#include <File.au3>

#include <Array.au3>

#include <WindowsConstants.au3>

#include <GuiConstantsEx.au3>

#include <ButtonConstants.au3>

#Include <GuiListView.au3>

SplashScreen("Starting....")

; ----------------------------------------------------------------------------

; Info screen for user

; ----------------------------------------------------------------------------

Func SplashScreen($Splashtext)

; Load PNG file as GDI bitmap

_GDIPlus_Startup()

$pngSrc = "C:\Documents and Settings\Compaq_Administrator\Desktop\172_panel2.png"

$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)

; Extract image width and height from PNG

$width = _GDIPlus_ImageGetWidth($hImage)

$height = _GDIPlus_ImageGetHeight($hImage)

local $Font="Comic Sans MS"

Local $guiSplash = GUICreate("Title", $width, $height, -1, -1, BitOR($WS_POPUP, $WS_VISIBLE), BitOR($WS_EX_DLGMODALFRAME, $WS_EX_TOPMOST ))

GUICtrlCreatePic("C:\Documents and Settings\Compaq_Administrator\Desktop\172_panel.jpg",0,0, $width,$height, -1)

GuiCtrlSetState(-1,$GUI_DISABLE)

;$WS_EX_TRANSPARENT

Local $Lbl= GUICtrlCreateLabel("TEST- TEST - TEST", 350, 25, 185, 30)

GUICtrlSetFont (-1,12, 400, 2, $Font)

GUICtrlSetBkColor($Lbl, $GUI_BKCOLOR_TRANSPARENT)

Local $Lbl2= GUICtrlCreateLabel($Splashtext, 30, 100, 230, 120)

GUICtrlSetFont (-1,12, 400, 4, $Font)

GUICtrlSetBkColor($Lbl2, $GUI_BKCOLOR_TRANSPARENT)

$button = GUICtrlCreateButton("Button", 100, 100, 80, 30) ;THIS BUTTON DOES NOT WORK

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

Case $msg = $button

Exit

EndSelect

WEnd

EndFunc

GUICtrlCreateBUtton("Button 2", 100, 200, 80, 30) ;I CANNOT EVEN SEE THIS BUTTON


Christianity: In the beginning, there was God, who always was there and created everything.Atheism: In the beginning, there was nothing, which exploded. Both sides look bad...

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Remove the $WS_EX_TRANSPARENT extended style from the Pic.

GUICtrlCreatePic(@SystemDir & "\oobe\images\wpaflag.jpg",0,0, 550,150, -1);, $WS_EX_TRANSPARENT )

then the labels will show.

Thank you, Martin.

Edit:

What about the text portions of Groups and Radios? or will I have to use an MDIChild for those?

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

Nevermind, I figured it out.


Christianity: In the beginning, there was God, who always was there and created everything.Atheism: In the beginning, there was nothing, which exploded. Both sides look bad...

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