Kyan Posted September 14, 2012 Posted September 14, 2012 Hi everyone When I try to set the tip text to a image created from binary with GDIPlus...nothing happens, can someone tell me if I'm doing something wrong? expandcollapse popup#include #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <StaticConstants.au3> #include <GDIPlus.au3>Global Const $STM_SETIMAGE = 0x0172 $form1 = GUICreate("Test",150,80) $icon = "0x89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7A" & _ "F4000000097048597300000EC400000EC401952B0E1B000002714944415458C3" & _ "ED96CD6B134118C69F3061FF85D239C4B454A588896E2420E231A51050DA8BC5" & _ "6B6EDEF4A424F6A4987FC2534E5E3DA637A9D2ACE68356B44231A5346B0F4242" & _ "42BE36D979BD64CB669BDDCE461B2F7D21CC6461F7F9EDF37ECC06E0124CE171" & _ "00AF6C9732A6A16B98553085E735AD4C44449A5626A6F03C66194CE1640FA670" & _ "BA089D20FE735C0204FDD60580AD9974C5A42274760553B8B5E6476D7BB100E7" & _ "00D961F84C009CFF0B8512ED148AF44F20FC00082188299C86C3210D0603FAF8" & _ "49931E5C7FD5054474FA030021048410506FDF048084140053780AC0A3D10D5B" & _ "6ED5BD99793626FC32FD1442883100D33441441042F8B3BAA69F1011514D3FB1" & _ "F217775A6E596D9AE6A9D5866150BFDFA76EB74B99CD2CB5DB6D6AB55AD46C36" & _ "E547375378DE02B0E537EFCCF124E15EAF479D4E674CB8D16850BD5E97060802" & _ "C884C22A8E0E4B093E3F070018F66B8974E6CD99FCDA736E59ED5CADBDF42434" & _ "0D5D630A7F170AABC6D16129C9E7E7404478F86075A2989BF0D40000601AFA5B" & _ "A67084C22A06BDE3241121168B8C3D7092B8DBBE54DE03806F320001473DFCDC" & _ "FEF07EE14E2C2AF5D66EFB2B8BF1ECE8C55EF805480158EBB4AA492F9BCF0358" & _ "BC7AB70A60DD34F48AAF41344A455AD34A50D588949813AC52F90A005D19F133" & _ "0ED85DA8FFDE4F4E03706DF9BEB4FD6EA3380720FDF94B05B7A2377C038CA6EA" & _ "FAD41F24A6A11B4CE1AF575637D67E1D579232A2D6BABBF7DD97FD5E87510E40" & _ "BA58DC4524B2EC597CF62ED978FC24EBF7400B788CE81480A5EAC1CE73AF6EB0" & _ "EFA3EA8A74F5CB1CC73900FBF613CE29ECC83D00303FE29E00A35A3858BA7E6F" & _ "C1C7F37EE0322EC367FC014A18D5CCF9B2326F0000000049454E44AE426082" Global $bIcon = Binary($icon) $Iconpic = GUICtrlCreatePic("", 67, 20, 32, 32,$SS_BITMAP) GUICtrlSetTip($Iconpic,"Tip") $hIcon = GUICtrlGetHandle($Iconpic) $hHBITMAPIcon = Load_BMP_From_Mem($bIcon, True) _GDIPlus_Startup() _WinAPI_DeleteObject(_SendMessage($hIcon, $STM_SETIMAGE, 0, $hHBITMAPIcon)) _WinAPI_UpdateWindow($hIcon) _GDIPlus_Shutdown() GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ;====================================================================================== ; Function Name: Load_BMP_From_Mem ; Description: Loads a image which is saved as a binary string and converts it to a bitmap or hbitmap ; ; Parameters: $mem_image: the binary string which contains any valid image which is supported by GDI+ ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created ; ; Remark: hbitmap format is used generally for GUI internal images ; ; Requirement(s): GDIPlus.au3, Memory.au3 ; Return Value(s): Success: handle to bitmap or hbitmap, Error: 0 ; Error codes: 1: $mem_image is not a binary string ; ; Author(s): UEZ ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines ; Version: v0.95 Build 2011-06-11 Beta ;======================================================================================= Func Load_BMP_From_Mem($mem_image, $hHBITMAP = False) If Not IsBinary($mem_image) Then Return SetError(1, 0, 0) Local $declared = True Local $GMEM_MOVEABLE = 0x0002 If Not $ghGDIPDll Then _GDIPlus_Startup() $declared = False EndIf Local Const $memBitmap = Binary($mem_image) ;load image saved in variable (memory) and convert it to binary Local Const $len = BinaryLen($memBitmap) ;get length of image Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002) Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE Local $hStream = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) $hStream = $hStream[3] Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface $hBitmap = $hBitmap[2] Local Const $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr") DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _ "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak $tMem = 0 If $hHBITMAP Then Local Const $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) If Not $declared Then _GDIPlus_Shutdown() Return $hHBmp EndIf If Not $declared Then _GDIPlus_Shutdown() Return $hBitmap EndFunc ;==>Load_BMP_From_Mem thanks in advance Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
UEZ Posted September 14, 2012 Posted September 14, 2012 It has something to do with the style $SS_BITMAP. Use this instead. $Iconpic = GUICtrlCreatePic("", 67, 20, 32, 32);,$SS_BITMAP) 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Kyan Posted September 14, 2012 Author Posted September 14, 2012 It has something to do with the style $SS_BITMAP. Use this instead. $Iconpic = GUICtrlCreatePic("", 67, 20, 32, 32);,$SS_BITMAP) Br, UEZ wow, thanks UEZ, I thought $SS_BITMAP was needed Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
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