MatthiasG Posted September 5, 2009 Posted September 5, 2009 Hello there! I tried to a transparent picture together with another. My Background was the following: And the icon this one here: test.ico But instead of getting a new picture, I got this one: I tried also to make it with GDI+, but the result wasn't as good as I expected: As you can see, you can count the pixels. How can I make this nicer? Have a nice day, Matthias
Yashied Posted September 5, 2009 Posted September 5, 2009 (edited) Try this, but there is one problem - it only works with icons that have the Alpha channel.expandcollapse popup#Include <WinAPIEx.au3> $hForm = GUICreate('MyGUI', 178, 192) GUICtrlCreatePic('index.jpeg', 0, 0, 178, 192) $Icon = GUICtrlCreatePic('', 65, 60, 48, 48) ; (!) ;_SetIconAlpha($Icon, @SystemDir & '\shell32.dll', 130, 48, 48) _SetIconAlpha($Icon, 'test.ico', 0, 48, 48) GUISetState() Do Until GUIGetMsg() = -3 Func _SetIconAlpha($hWnd, $sIcon, $iIndex, $iWidth, $iHeight) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If $hWnd = 0 Then Return SetError(1, 0, 0) EndIf EndIf Local $hIcon = _WinAPI_ShellExtractIcons($sIcon, $iIndex, $iWidth, $iHeight) If $hIcon = 0 Then Return SetError(1, 0, 0) EndIf Local $hBitmap, $hObj, $hDC, $hMem, $hSv $hDC = _WinAPI_GetDC($hWnd) $hMem = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) $hSv = _WinAPI_SelectObject($hMem, $hBitmap) _WinAPI_DrawIconEx($hMem, 0, 0, $hIcon, $iWidth, $iHeight, 0, 0, 2) _WinAPI_ReleaseDC($hWnd, $hDC) _WinAPI_SelectObject($hMem, $hSv) _WinAPI_DeleteDC($hMem) _WinAPI_DestroyIcon($hIcon) _WinAPI_DeleteObject(_SendMessage($hWnd, 0x0172, 0, 0)) _SendMessage($hWnd, 0x0172, 0, $hBitmap) $hObj = _SendMessage($hWnd, 0x0173) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf Return 1 EndFunc ;==>_SetIconAlphaWinAPIEx.au3If you save your icon as a PNG image, you can use the Icons.au3 library.#Include <Icons.au3> $hForm = GUICreate('MyGUI', 178, 192) GUICtrlCreatePic('index.jpeg', 0, 0, 178, 192) $Pic = GUICtrlCreatePic('', 65, 60, 48, 48) _SetImage($Pic, 'test.png') GUISetState() Do Until GUIGetMsg() = -3Icons.au3 Edited September 5, 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...
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