MadaraUchiha Posted December 20, 2013 Share Posted December 20, 2013 Hey, I like to add an icon to my MenuItem. I know there are many big UDF's out there like ModernMenu etc, but I am looking for a very short and clean solution. Just a function where I can add the Icon from file, without using a large UDF. My current code is this: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GUIConstants.au3> #include <GUIMenu.au3> $MenuItemIcons = GUICreate("MenuItem Icons", 180, 117, 192, 124,$WS_SYSMENU) $MenuItem1 = GUICtrlCreateMenu("Main") $MenuItem2 = GUICtrlCreateMenuItem("About", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem("Test", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem("Exit", $MenuItem1) $Label1 = GUICtrlCreateLabel("Testapplication with Icons", 16, 16, 127, 17) $Label2 = GUICtrlCreateLabel("in MenuItems.", 16, 32, 70, 17) GUICtrlSetImage($MenuItem2,0,'C:\Users\Domi\Desktop\arrow.ico') GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd (Icon Image added as attatchment) But this doesn't work... I also tried it with .png, .jpg, .bmp, .gif, .ico. None of these format worked, so I think my mistake is somethig else. Any help is appreciated arrow.ico Link to comment Share on other sites More sharing options...
UEZ Posted December 20, 2013 Share Posted December 20, 2013 Try this: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GUIConstants.au3> #include <GUIMenu.au3> #include <GDIPlus.au3> _GDIPlus_Startup() $MenuItemIcons = GUICreate("MenuItem Icons", 180, 117, 192, 124,$WS_SYSMENU) $MenuItem1 = GUICtrlCreateMenu("Main") $MenuItem2 = GUICtrlCreateMenuItem("About", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem("Test", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem("Exit", $MenuItem1) $Label1 = GUICtrlCreateLabel("Testapplication with Icons", 16, 16, 127, 17) $Label2 = GUICtrlCreateLabel("in MenuItems.", 16, 32, 70, 17) $hIcon = _WinAPI_LoadImage(0, @ScriptDir & "\arrow.ico", $IMAGE_ICON, 16, 16, $LR_LOADFROMFILE) $hBitmap = _GDIPlus_BitmapCreateFromHICON($hIcon) $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GUICtrlMenu_SetItemBmp(GUICtrlGetHandle($MenuItem1), 1, $hGDIBitmap) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_BitmapDispose($hBitmap) _WinAPI_DeleteObject($hGDIBitmap) _WinAPI_DestroyIcon($hIcon) _GDIPlus_Shutdown() Exit EndSwitch WEnd Func _GDIPlus_BitmapCreateFromHICON($hIcon) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromHICON", "handle", $hIcon, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc ;==>_GDIPlus_BitmapCreateFromHICON Br, 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...
MadaraUchiha Posted December 20, 2013 Author Share Posted December 20, 2013 (edited) Hey, thanks you so much, this is very close to perfekt. But I have 1 question. On windows Vista/7/8 it works very good: But Windows XP, the transparency gets lost. But on all other OS (higher) it works smoothless? How can I fix this for XP aswell? Because other public applications also have transparency for their icons on windows xp... Edited December 21, 2013 by MadaraUchiha Link to comment Share on other sites More sharing options...
UEZ Posted December 21, 2013 Share Posted December 21, 2013 (edited) I think on WinXP it is not a real transparency rather the background will be filled with the menu background color. Try this then:expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GUIConstants.au3> #include <GUIMenu.au3> #include <GDIPlus.au3> _GDIPlus_Startup() $MenuItemIcons = GUICreate("MenuItem Icons", 180, 117, 192, 124,$WS_SYSMENU) $MenuItem1 = GUICtrlCreateMenu("Main") $MenuItem2 = GUICtrlCreateMenuItem(" About", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem(" Test", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem(" Exit", $MenuItem1) $Label1 = GUICtrlCreateLabel("Testapplication with Icons", 16, 16, 127, 17) $Label2 = GUICtrlCreateLabel("in MenuItems.", 16, 32, 70, 17) $hIcon = _WinAPI_LoadImage(0, @ScriptDir & "\arrow.ico", $IMAGE_ICON, 16, 16, $LR_LOADFROMFILE) $hBitmap = _GDIPlus_BitmapCreateFromHICON($hIcon) $hGDIBitmap = _GDIPlus_Convert2HBitmap($hBitmap, $COLOR_MENU) _GUICtrlMenu_SetItemBmp(GUICtrlGetHandle($MenuItem1), 1, $hGDIBitmap) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_BitmapDispose($hBitmap) _WinAPI_DeleteObject($hGDIBitmap) _WinAPI_DestroyIcon($hIcon) _GDIPlus_Shutdown() Exit EndSwitch WEnd Func _GDIPlus_BitmapCreateFromHICON($hIcon) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromHICON", "handle", $hIcon, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc ;==>_GDIPlus_BitmapCreateFromHICON Func _GDIPlus_Convert2HBitmap($hBitmap, $iColor); removes alpha backround using system color and converts to gdi bitmap Local $iBgColor = _WinAPI_GetSysColor($iColor) $iBgColor = 0x10000 * BitAND($iBgColor, 0xFF) + BitAND($iBgColor, 0x00FF00) + BitShift($iBgColor, 16) Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap), $iHeight = _GDIPlus_ImageGetHeight($hBitmap) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "handle*", 0) Local $hBitmap_new = $aResult[6] Local $hCtx_new = _GDIPlus_ImageGetGraphicsContext($hBitmap_new) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $iBgColor) _GDIPlus_GraphicsFillRect($hCtx_new, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_GraphicsDrawImageRect($hCtx_new, $hBitmap, 0, 0, $iWidth, $iHeight) Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_new) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BitmapDispose($hBitmap_new) _GDIPlus_GraphicsDispose($hCtx_new) Return $hHBITMAP EndFunc ;==>_GDIPlus_Convert2HBitmapBr,UEZ Edited December 21, 2013 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...
AZJIO Posted December 21, 2013 Share Posted December 21, 2013 '?do=embed' frameborder='0' data-embedContent>> My other projects or all Link to comment Share on other sites More sharing options...
MadaraUchiha Posted December 21, 2013 Author Share Posted December 21, 2013 I think on WinXP it is not a real transparency rather the background will be filled with the menu background color. Try this then: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GUIConstants.au3> #include <GUIMenu.au3> #include <GDIPlus.au3> _GDIPlus_Startup() $MenuItemIcons = GUICreate("MenuItem Icons", 180, 117, 192, 124,$WS_SYSMENU) $MenuItem1 = GUICtrlCreateMenu("Main") $MenuItem2 = GUICtrlCreateMenuItem(" About", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem(" Test", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem(" Exit", $MenuItem1) $Label1 = GUICtrlCreateLabel("Testapplication with Icons", 16, 16, 127, 17) $Label2 = GUICtrlCreateLabel("in MenuItems.", 16, 32, 70, 17) $hIcon = _WinAPI_LoadImage(0, @ScriptDir & "\arrow.ico", $IMAGE_ICON, 16, 16, $LR_LOADFROMFILE) $hBitmap = _GDIPlus_BitmapCreateFromHICON($hIcon) $hGDIBitmap = _GDIPlus_Convert2HBitmap($hBitmap, $COLOR_MENU) _GUICtrlMenu_SetItemBmp(GUICtrlGetHandle($MenuItem1), 1, $hGDIBitmap) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_BitmapDispose($hBitmap) _WinAPI_DeleteObject($hGDIBitmap) _WinAPI_DestroyIcon($hIcon) _GDIPlus_Shutdown() Exit EndSwitch WEnd Func _GDIPlus_BitmapCreateFromHICON($hIcon) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromHICON", "handle", $hIcon, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc ;==>_GDIPlus_BitmapCreateFromHICON Func _GDIPlus_Convert2HBitmap($hBitmap, $iColor); removes alpha backround using system color and converts to gdi bitmap Local $iBgColor = _WinAPI_GetSysColor($iColor) $iBgColor = 0x10000 * BitAND($iBgColor, 0xFF) + BitAND($iBgColor, 0x00FF00) + BitShift($iBgColor, 16) Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap), $iHeight = _GDIPlus_ImageGetHeight($hBitmap) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "handle*", 0) Local $hBitmap_new = $aResult[6] Local $hCtx_new = _GDIPlus_ImageGetGraphicsContext($hBitmap_new) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $iBgColor) _GDIPlus_GraphicsFillRect($hCtx_new, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_GraphicsDrawImageRect($hCtx_new, $hBitmap, 0, 0, $iWidth, $iHeight) Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_new) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BitmapDispose($hBitmap_new) _GDIPlus_GraphicsDispose($hCtx_new) Return $hHBITMAP EndFunc ;==>_GDIPlus_Convert2HBitmap Br, UEZ Hey, thanks, thats already working very good, also on XP The background is now transparent: but when I hover the item with the icon with my mouse, it looks strange: Is there a way to make it also transparent when hovering with the mouse? ;o Link to comment Share on other sites More sharing options...
MadaraUchiha Posted December 21, 2013 Author Share Posted December 21, 2013 Also I wonder why it works on newer systems, and on XP it is so laggy O.o Link to comment Share on other sites More sharing options...
UEZ Posted December 21, 2013 Share Posted December 21, 2013 Look at ASJIO's link in post 5 for a solution. When item is selected the icon color will be inverted. Br, 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...
MadaraUchiha Posted December 21, 2013 Author Share Posted December 21, 2013 Look at ASJIO's link in post 5 for a solution. When item is selected the icon color will be inverted. Br, UEZ So when hovered, I need to create a "negative" of the icon? Can't I use you function for this: Link to comment Share on other sites More sharing options...
UEZ Posted December 21, 2013 Share Posted December 21, 2013 No, that it isn't the way how to do it. The invertion is made by the system. Just check out the link from post 5 and try to understand how the invertion is bypassed (catchword: callback). Br, 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...
MadaraUchiha Posted December 21, 2013 Author Share Posted December 21, 2013 I think you are reffering to Example3() ? But I am not sure how I could implement this ;o Link to comment Share on other sites More sharing options...
UEZ Posted December 21, 2013 Share Posted December 21, 2013 Why don't you use this UDF for you purposes? Br, 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...
MadaraUchiha Posted December 21, 2013 Author Share Posted December 21, 2013 I just like to create my own "little UDF", where I just can use it like "AddIcon($PathToIconFile, $ControlToSetIcon). Can't u help me with this last step, then I am finished ;D Link to comment Share on other sites More sharing options...
BrewManNH Posted December 21, 2013 Share Posted December 21, 2013 I'm not sure you have the required expertise to do this if you can't look at the code presented and use it in your script, or base something of your own off of it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
MadaraUchiha Posted December 21, 2013 Author Share Posted December 21, 2013 I wonder why simple functions like GuiCtrlSetImage for example are not working. Why can't I just simple choose my image path and set it to a control? And why are only bmp support (which cause a lot problems with transparency?) Link to comment Share on other sites More sharing options...
MadaraUchiha Posted December 21, 2013 Author Share Posted December 21, 2013 I think on WinXP it is not a real transparency rather the background will be filled with the menu background color. Try this then: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GUIConstants.au3> #include <GUIMenu.au3> #include <GDIPlus.au3> _GDIPlus_Startup() $MenuItemIcons = GUICreate("MenuItem Icons", 180, 117, 192, 124,$WS_SYSMENU) $MenuItem1 = GUICtrlCreateMenu("Main") $MenuItem2 = GUICtrlCreateMenuItem(" About", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem(" Test", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem(" Exit", $MenuItem1) $Label1 = GUICtrlCreateLabel("Testapplication with Icons", 16, 16, 127, 17) $Label2 = GUICtrlCreateLabel("in MenuItems.", 16, 32, 70, 17) $hIcon = _WinAPI_LoadImage(0, @ScriptDir & "\arrow.ico", $IMAGE_ICON, 16, 16, $LR_LOADFROMFILE) $hBitmap = _GDIPlus_BitmapCreateFromHICON($hIcon) $hGDIBitmap = _GDIPlus_Convert2HBitmap($hBitmap, $COLOR_MENU) _GUICtrlMenu_SetItemBmp(GUICtrlGetHandle($MenuItem1), 1, $hGDIBitmap) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_BitmapDispose($hBitmap) _WinAPI_DeleteObject($hGDIBitmap) _WinAPI_DestroyIcon($hIcon) _GDIPlus_Shutdown() Exit EndSwitch WEnd Func _GDIPlus_BitmapCreateFromHICON($hIcon) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromHICON", "handle", $hIcon, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc ;==>_GDIPlus_BitmapCreateFromHICON Func _GDIPlus_Convert2HBitmap($hBitmap, $iColor); removes alpha backround using system color and converts to gdi bitmap Local $iBgColor = _WinAPI_GetSysColor($iColor) $iBgColor = 0x10000 * BitAND($iBgColor, 0xFF) + BitAND($iBgColor, 0x00FF00) + BitShift($iBgColor, 16) Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap), $iHeight = _GDIPlus_ImageGetHeight($hBitmap) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "handle*", 0) Local $hBitmap_new = $aResult[6] Local $hCtx_new = _GDIPlus_ImageGetGraphicsContext($hBitmap_new) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $iBgColor) _GDIPlus_GraphicsFillRect($hCtx_new, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_GraphicsDrawImageRect($hCtx_new, $hBitmap, 0, 0, $iWidth, $iHeight) Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_new) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BitmapDispose($hBitmap_new) _GDIPlus_GraphicsDispose($hCtx_new) Return $hHBITMAP EndFunc ;==>_GDIPlus_Convert2HBitmap Br, UEZ If I try to create a Function using your code where I can specify the iconpath and the control which i like to add an image to as parameters, it won't work, no image appears... ? Link to comment Share on other sites More sharing options...
UEZ Posted December 21, 2013 Share Posted December 21, 2013 expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GUIConstants.au3> #include <GUIMenu.au3> #include <GDIPlus.au3> _GDIPlus_Startup() $MenuItemIcons = GUICreate("MenuItem Icons", 180, 117, 192, 124,$WS_SYSMENU) $Menu = GUICtrlCreateMenu("Main") $MenuItem1 = GUICtrlCreateMenuItem(" About", $Menu) $MenuItem2 = GUICtrlCreateMenuItem(" Test", $Menu) $MenuItem3 = GUICtrlCreateMenuItem(" Exit", $Menu) $Label1 = GUICtrlCreateLabel("Testapplication with Icons", 16, 16, 127, 17) $Label2 = GUICtrlCreateLabel("in MenuItems.", 16, 32, 70, 17) $aResources = GCM_SetIcon("c:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\AutoIt_Old4.ico", $Menu, 0) $aResources2 = GCM_SetIcon(@ScriptDir & "\arrow.ico", $Menu, 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_BitmapDispose($aResources[1]) _WinAPI_DeleteObject($aResources[2]) _WinAPI_DestroyIcon($aResources[0]) _GDIPlus_BitmapDispose($aResources2[1]) _WinAPI_DeleteObject($aResources2[2]) _WinAPI_DestroyIcon($aResources2[0]) _GDIPlus_Shutdown() Exit EndSwitch WEnd Func GCM_SetIcon($sFileIcon, $iMenu, $iItem, $iW = 16, $iH = 16) Local $aResources[3] $aResources[0] = _WinAPI_LoadImage(0, $sFileIcon, $IMAGE_ICON, $iW, $iH, $LR_LOADFROMFILE) ;$hIcon $aResources[1] = _GDIPlus_BitmapCreateFromHICON($aResources[0]) ;$hBitmap $aResources[2] = _GDIPlus_Convert2HBitmap($aResources[1], $COLOR_MENU) ;$hGDIBitmap _GUICtrlMenu_SetItemBmp(GUICtrlGetHandle($iMenu), $iItem, $aResources[2]) Return $aResources EndFunc Func _GDIPlus_BitmapCreateFromHICON($hIcon) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromHICON", "handle", $hIcon, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc ;==>_GDIPlus_BitmapCreateFromHICON Func _GDIPlus_Convert2HBitmap($hBitmap, $iColor); removes alpha backround using system color and converts to gdi bitmap Local $iBgColor = _WinAPI_GetSysColor($iColor) $iBgColor = 0x10000 * BitAND($iBgColor, 0xFF) + BitAND($iBgColor, 0x00FF00) + BitShift($iBgColor, 16) Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap), $iHeight = _GDIPlus_ImageGetHeight($hBitmap) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "handle*", 0) Local $hBitmap_new = $aResult[6] Local $hCtx_new = _GDIPlus_ImageGetGraphicsContext($hBitmap_new) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $iBgColor) _GDIPlus_GraphicsFillRect($hCtx_new, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_GraphicsDrawImageRect($hCtx_new, $hBitmap, 0, 0, $iWidth, $iHeight) Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_new) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BitmapDispose($hBitmap_new) _GDIPlus_GraphicsDispose($hCtx_new) Return $hHBITMAP EndFunc ;==>_GDIPlus_Convert2HBitmap Br, UEZ argumentum 1 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...
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