Shanheavel Posted December 30, 2010 Share Posted December 30, 2010 (edited) Hello,I know BMP doesn't support transparency. But I've picture and I know color (0xFF00FF).How can I change pink color to transparent using GUICtrlCreatePic? Edited December 31, 2010 by Adrian777 Link to comment Share on other sites More sharing options...
Shanheavel Posted December 31, 2010 Author Share Posted December 31, 2010 BUMP! Link to comment Share on other sites More sharing options...
UEZ Posted December 31, 2010 Share Posted December 31, 2010 (edited) Try this:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> $gui = GUICreate("", 144, 87, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xFF00FF) $hLabel = GUICtrlCreateLabel("", 32, 9, 72, 64, -1, $GUI_WS_EX_PARENTDRAG) $img = GUICtrlCreatePic(@ScriptDir & "\piclvq.bmp", 0, 0, 0, 0) GUISetState(@SW_SHOW) While 1 Sleep ( 250 ) If _IsPressed("1B") Then MsgBox(0,"_IsPressed", "Esc Key Pressed") ExitLoop EndIf WEnd ExitThe attached pic is a PNG. Convert it to a BMP before starting the script!For a transparent PNG image you can use this code:expandcollapse popup#include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("GuiOnEventMode", 1) Local Const $STM_SETIMAGE = 0x0172 Local $hGUI, $Pic, $hImage, $hBmp, $iW, $iH _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile("piclvq.png") $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $hBitmap = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iW, $iH, $GDIP_PXF32ARGB) $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() $hGUI = GUICreate("Test", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xFF00FF) GUISetState() $Pic = GUICtrlCreatePic("", 0, 0, 0, 0) GUICtrlSendMsg($Pic, $STM_SETIMAGE, 0, $hBmp) _WinAPI_DeleteObject($hBmp) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xFF00FF) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") GUICtrlSetOnEvent($Pic, "_Pic_Clicked") Do Until Not Sleep(1000) Func _Pic_Clicked() MsgBox(0, "Test", "You clicked on the pic!") EndFunc Func _Quit() GUIDelete($hGUI) Exit EndFuncBr,UEZ Edited December 31, 2010 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Shanheavel Posted December 31, 2010 Author Share Posted December 31, 2010 This code is great! Thank you Link to comment Share on other sites More sharing options...
Yashied Posted December 31, 2010 Share Posted December 31, 2010 (edited) #Include <Constants.au3> #Include <WinAPIEx.au3> #Include <WindowsConstants.au3> Global Const $STM_SETIMAGE = 0x0172 Global Const $STM_GETIMAGE = 0x0173 $hForm = GUICreate('MyGUI', 400, 400) $Pic = GUICtrlCreatePic('', 50, 50, 144, 87) $hPic = GUICtrlGetHandle(-1) $hDstDC = _WinAPI_CreateCompatibleDC(0) $hBitmap = _WinAPI_CreateSolidBitmap(0, _WinAPI_GetSysColor($COLOR_3DFACE), 144, 87, 0) $hDstSv = _WinAPI_SelectObject($hDstDC, $hBitmap) $hSrcDC = _WinAPI_CreateCompatibleDC(0) $hImg = _WinAPI_LoadImage(0, @ScriptDir & '\piclvq.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE) $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hImg) _WinAPI_TransparentBlt($hDstDC, 0, 0, 144, 87, $hSrcDC, 0, 0, 144, 87, 0xFF00FF) _WinAPI_SelectObject($hDstDC, $hDstSv) _WinAPI_DeleteDC($hDstDC) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hImg) _WinAPI_DeleteObject(_SendMessage($hPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)) $hPic = _SendMessage($hPic, $STM_GETIMAGE) If $hPic <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf GUISetState() Do Until GUIGetMsg() = -3piclvq.bmp Edited December 31, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Zedna Posted December 31, 2010 Share Posted December 31, 2010 Very educative examples UEZ/Yashied !!! Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
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