MikeP Posted May 9, 2008 Posted May 9, 2008 (edited) Hi. I'm looking to use a file with transparency (GIF...BMP..PNG.. whatever works) on my GUI and after a couple of hours I'm at the same point... the transparent regions displays white, so I've searched and searched and found that prospeed UDF could do the work, unfortunately almost all files on the website are down.. and I can't download and test prospeed. Anyone can help ? for my transparency problem or prospeed. Thanks Edited May 9, 2008 by MikeP
spudw2k Posted May 9, 2008 Posted May 9, 2008 (edited) Check out the AlphaBlend example included with AutoIt. C:\Program Files\AutoIt3\Examples\GUI\Advanced\AlphaBlend.au3 edit: only works with PNG i believe. Edited May 9, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
MikeP Posted May 9, 2008 Author Posted May 9, 2008 Thanks man ! this is a bit too much than what I wanted.. but in fact you led me in the right direction.. No idea why I was stucked using GUICtrlCreatePic and didn't even think of checking _GDIPlus stuff.. I've been on the pc for too long and I'm starting losing neurons
MikeP Posted May 9, 2008 Author Posted May 9, 2008 (edited) Ok .. I'm facing another problem. I used _GDIPlus_GraphicsDrawImageRectRect to display a PNG on my GUI (I just did the same as what's done in ShowPNG.au3 in the Examples) .. all good but the problem is when I'm putting a window over my GUI and putting it away my PNG disappears So I've put the function inside the main loop, which works since every loop the image is redrawn.. (no idea of the resource consumption..) but there comes another issue.. the shadows which were soft at start are added and added up to the point they're full black.. Sooo the answer would be .. to only redraw the image when it has been hidden by another window.. the fact is I have no clue how to detect if something's hiding the GUI, or part of the GUI... here is a sample script to demonstrate my problem : expandcollapse popup#include <GUIConstants.au3> #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #Include <WinAPI.au3> $redraw = False $gui = GUICreate("",200,200) GUISetBkColor(0xFFFFFF) GUISetState() GUICtrlCreateLabel("Hover another window over this and move it away ...the boat disappear"&@CRLF&@CRLF&@CRLF&"To correct this, we can redraw the picture non stop.. Press Enable to do it and check what's happening to the shadow", 90,2,105,180) $btn = GUICtrlCreateButton("Enable", 120, 180, 60, 20) _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile("sailboat.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($gui) _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImage, 0, 0, 84, 128, 5, 20, 84, 128) While 1 $msg = GUIGetMsg() Switch $msg Case $btn $redraw = True Case $GUI_EVENT_CLOSE mainwindowClose() EndSwitch If $redraw Then $hImage = _GDIPlus_ImageLoadFromFile("sailboat.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($gui) _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImage, 0, 0, 84, 128, 5, 20, 84, 128) EndIf Sleep(100) WEnd Func mainwindowClose () _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() Exit EndFunc and the files in attachment to test it. Thanks for your help.pngproblem.au3 Edited May 9, 2008 by MikeP
Zedna Posted May 9, 2008 Posted May 9, 2008 Ok .. I'm facing another problem. I used _GDIPlus_GraphicsDrawImageRectRect to display a PNG on my GUI (I just did the same as what's done in ShowPNG.au3 in the Examples) .. all good but the problem is when I'm putting a window over my GUI and putting it away my PNG disappears So I've put the function inside the main loop, which works since every loop the image is redrawn.. (no idea of the resource consumption..) but there comes another issue.. the shadows which were soft at start are added and added up to the point they're full black.. Sooo the answer would be .. to only redraw the image when it has been hidden by another window.. the fact is I have no clue how to detect if something's hiding the GUI, or part of the GUI... You have two choices: 1) catch WM_PAINT by GUIRegisterMsg() 2) use STM_SETIMAGE message ad 1) search forum for WM_PAINT ad 2) Look here: http://www.autoitscript.com/forum/index.php?showtopic=51103 Func _SetBitmapToCtrl($CtrlId, $hBitmap) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local Const $SS_BITMAP = 0xE Local Const $GWL_STYLE = -16 Local $hWnd = GUICtrlGetHandle($CtrlId) If $hWnd = 0 Then Return SetError(1, 0, 0) ; set SS_BITMAP style to control Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE) If @error Then Return SetError(2, 0, 0) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP)) If @error Then Return SetError(3, 0, 0) Local $oldBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hBitmap) If @error Then Return SetError(4, 0, 0) If $oldBmp[0] <> 0 Then _WinAPI_DeleteObject($oldBmp[0]) Return 1 EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search
MikeP Posted May 9, 2008 Author Posted May 9, 2008 Thanks.. I guess I really have to install the other package now because you're using AutoItWrapper and I don't have this (no clue what is too) ..and downloading ResHacker and putting it in my script dir or Autoit dir didn't work either... I guess that's my issue..
Zedna Posted May 9, 2008 Posted May 9, 2008 Thanks.. I guess I really have to install the other package now because you're using AutoItWrapper and I don't have this (no clue what is too) ..and downloading ResHacker and putting it in my script dir or Autoit dir didn't work either... I guess that's my issue..You don't need whole reources UDF. I just gave you link as example of use _SetBitmapToCtrl()Look here: http://www.autoitscript.com/forum/index.ph...st&p=517699 Resources UDF ResourcesEx UDF AutoIt Forum Search
MikeP Posted May 9, 2008 Author Posted May 9, 2008 (edited) Oh ok.. anyway I already saw that post about resources and I buffered it in my incredible list of "to do or to check" things so I would eventually have had to install it .. because the whole thing seems to be really useful ^^ /off-topic : oh god.. I installed Scite4 .. so AutoIt is getting far from being a simple scripting language .. that's just awesome what we can do and all the features in there. I loved when I compiled my script and got that big compile options popup I was like... WOW ! mmm k.. let's not get too much excited but I'll sum it up : AutoIt ROCKS Edited May 9, 2008 by MikeP
Zedna Posted May 9, 2008 Posted May 9, 2008 mmm k.. let's not get too much excited but I'll sum it up : AutoIt ROCKS Yes definitelly Also don't miss great AutoIt GUI designer - Koda http://www.autoitscript.com/forum/index.php?showtopic=32299 Resources UDF ResourcesEx UDF AutoIt Forum Search
MikeP Posted May 9, 2008 Author Posted May 9, 2008 (edited) I might be dumb but I can't get it to work.. anyone see what's wrong in here : expandcollapse popup#include <GUIConstants.au3> #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> $gui = GUICreate("", 200, 200) GUISetBkColor(0xFFFFFF) GUISetState() _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile("sailboat.png") $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $picCtrl = GUICtrlCreatePic("sailboat.png",0,0,84,128) _SetBitmapToCtrl($picCtrl, $hBitmap) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE mainwindowClose() EndSwitch Sleep(100) WEnd Func mainwindowClose() _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Exit EndFunc ;==>mainwindowClose Func _SetBitmapToCtrl($CtrlId, $hBitmap) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local Const $SS_BITMAP = 0xE Local Const $GWL_STYLE = -16 Local $hWnd = GUICtrlGetHandle($CtrlId) If $hWnd = 0 Then Return SetError(1, 0, 0) ; set SS_BITMAP style to control Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE) If @error Then Return SetError(2, 0, 0) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP)) If @error Then Return SetError(3, 0, 0) Local $oldBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hBitmap) If @error Then Return SetError(4, 0, 0) If $oldBmp[0] <> 0 Then _WinAPI_DeleteObject($oldBmp[0]) Return 1 EndFunc ;==>_SetBitmapToCtrl I've been trying to put that damn PNG for the whole day now and this is driving me crazy Edited May 9, 2008 by MikeP
Zedna Posted May 9, 2008 Posted May 9, 2008 Try this changed order: $gui = GUICreate("", 200, 200) GUISetBkColor(0xFFFFFF) _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile("sailboat.png") $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $picCtrl = GUICtrlCreatePic("sailboat.png",0,0,84,128) $hPicCtrl = GUICtrlGetHandle($picCtrl) _SetBitmapToCtrl($picCtrl, $hBitmap) GUISetState() Also try: $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\sailboat.png") Resources UDF ResourcesEx UDF AutoIt Forum Search
MikeP Posted May 9, 2008 Author Posted May 9, 2008 (edited) nope.. the picture doesn't display edit : YEEEEEEEEEEEEEEEEeeeeeeeeeeeeeeeeeeeeeeeeeeeeees I found the bug.. you will explain why it happens if you want haha.. but my thing works! the bug : loading image with _ImageLoadFromFile >> ok .. putting the same file in the GUICtrlCreatePic control >> NOT ok (no idea why) I just putted this : $picCtrl = GUICtrlCreatePic("", 0, 0, 84, 128) and it works now ! with your nice function I can hide the GUI behind a window and when i'm getting the GUI back on top the PNG still displays !!! Thanks Zedna ! (4000+ posts ! nice ) p.s : damn that looks ridiculous .."woohoo I found how to put a picture with transparency on my GUI !! the happiest man on Earth!" Edited May 9, 2008 by MikeP
Zedna Posted May 10, 2008 Posted May 10, 2008 (edited) GUICtrlCreatePic("sailboat.png",0,0,84,128) I didn't noticed you provided PNG filename here. I just copied your code. This is of course wrong because PNG is not supported inative mage type for GUICtrlCreatePic() so picture control hasn't been created (correctly). In such case you must always use empty filename. BTW: Thanks to 4000+ posts congratulation Edited May 10, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now