JackDinn Posted October 22, 2009 Share Posted October 22, 2009 (edited) I know there are lots of posts involving this subject but is there a simple way to make the background of an icon transparent without having to add masses of code ? im looking to put a .ico onto a coloured GUI with GUICtrlCreateIcon() but i dont want the white square with icon in middle. sorry for not finding the info but iv been searching and reading for ages now and its all getting a bit complicated. cheers. Edited October 22, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
Yashied Posted October 23, 2009 Share Posted October 23, 2009 expandcollapse popup#Include <Icons.au3> #Include <WinAPIEx.au3> GUICreate('MyGUI', 350, 250) $Pic1 = GUICtrlCreatePic('', 0, 0, 350, 250) $hPic1 = GUICtrlGetHandle($Pic1) $Pic2 = GUICtrlCreatePic('', 40, 40, 48, 48) $hPic2 = GUICtrlGetHandle(-1) GUISetState() Dim $aVertex[2][3] = [[0, 0, 0x0000FF], [350, 250, 0x000000]] ; Set Gradient $hDC = _WinAPI_GetDC($hPic1) $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, 350, 250) _WinAPI_SelectObject($hMemDC, $hBitmap) _WinAPI_GradientFill($hMemDC, $aVertex, 0, -1, 1) _WinAPI_ReleaseDC($hPic1, $hDC) _WinAPI_DeleteDC($hMemDC) _SetHImage($Pic1, $hBitmap) _WinAPI_FreeObject($hBitmap) ; Set Icon $hDC = _WinAPI_GetDC($hPic2) $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, 48, 48) _WinAPI_SelectObject($hMemDC, $hBitmap) $hIcon = _WinAPI_ShellExtractIcons(@SystemDir & '\shell32.dll', 130, 48, 48) _WinAPI_DrawIconEx($hMemDC, 0, 0, $hIcon, 48, 48, 0, 0, 2) _WinAPI_ReleaseDC($hPic2, $hDC) _WinAPI_DeleteDC($hMemDC) _SetHImage($Pic2, $hBitmap) _WinAPI_FreeObject($hBitmap) _WinAPI_FreeIcon($hIcon) Do Until GUIGetMsg() = -3 GUIDelete()Icons.au3WinAPIEx.au3 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...
JackDinn Posted October 23, 2009 Author Share Posted October 23, 2009 ok many thx, not quite the "simple" method i was hoping for but still i do appreciate the help. It works fine, i just need to spend a bit of time understanding how it works and what all the added UDF's are about included with you WinAPIEx.au3, ( I dont like just using script iv been given without a proper understanding, which is the least i can do when someone has done so much work to produce.) looks like autoit is moving more and more towards VB ! having to read the MSDN library more and more, but it's all good. many thx. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
JackDinn Posted October 23, 2009 Author Share Posted October 23, 2009 great stuff . iv pulled it about a bit to get a function that i can easily use. I will be able to do all sorts of neat stuff now. expandcollapse popup#include <Icons.au3> #include <WinAPIEx.au3> $GUIH = GUICreate('MyGUI', 350, 250) GUISetBkColor(0xf453f5) GUISetState() ;~ $icon1 = iconx($GUIH, "C:\Documents and Settings\Greg\desktop\JDAST pack\1256250803_Arrow Down.ico", 0, 10, 10, 40, 40);### for .ICO files $icon1 = iconx($GUIH, @SystemDir & "\shell32.dll", 176, 70,100); for icon packs eg .DLL $icon2 = iconx($GUIH, @SystemDir & "\shell32.dll", 11, 100,100); for icon packs eg .DLL ;############# just some fun, but i can really play with this ######### Sleep(1000) For $y = 0 To 5 for $x=10 to 40 GUICtrlSetPos($icon1, $x, 100) Sleep(1) Next Next GUICtrlSetPos($icon2, 100, 100) For $x = 50 To 100 GUICtrlDelete($icon2) $icon2 = iconx($GUIH, @SystemDir & "\shell32.dll", 11, 100, 100, $x, $x) Sleep(10) Next ;###################################################################### Do Until GUIGetMsg() = -3 GUIDelete() Exit ; Set Icon Func iconX($gui_handel, $icon_path, $icon_number = 0, $icon_x = 0, $icon_y = 0, $icon_width = 48, $icon_hight = 48) GUISwitch($gui_handel) $Pic2 = GUICtrlCreatePic('', $icon_x, $icon_y, $icon_width, $icon_hight) $pic_handel = GUICtrlGetHandle(-1) $hDC = _WinAPI_GetDC($pic_handel) $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $icon_width, $icon_hight) _WinAPI_SelectObject($hMemDC, $hBitmap) $hIcon = _WinAPI_ShellExtractIcons($icon_path, $icon_number, 48, 48) _WinAPI_DrawIconEx($hMemDC, 0, 0, $hIcon, $icon_width, $icon_hight, 0, 0, 2) _WinAPI_ReleaseDC($pic_handel, $hDC) _WinAPI_DeleteDC($hMemDC) _SetHImage($pic_handel, $hBitmap) _WinAPI_FreeObject($hBitmap) _WinAPI_FreeIcon($hIcon) Return $Pic2 EndFunc ;==>iconX again many thx. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
Yashied Posted October 23, 2009 Share Posted October 23, 2009 (edited) If you save your icons as PNG, the code would look like (without WinAPI): _SetImage($Pic, "C:\...\MyIcon.png") Edited October 23, 2009 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...
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