Mbee

The Case of the Non-Debugger Disappearing Controls

15 posts in this topic

#1 ·  Posted (edited)

Ok, so recently I changed my GUI app from calling GUICtrlCreatePic() with image file paths, to passing blank paths at first so that I can set the images later from internal binary memory using ProgAndy and Zedna's semi-UDF found here: Set image string directly to Control.

When I test it using the Graphical Debugger, once the GUI is up, all the pic controls show up perfectly.  But when I run the compiled script normally, none of them show up (or at least the disappear too fast for me to notice)!  What's up with that? Since the pics show fine with the debugger, that's gotta mean that the code for that portion (i.e, loading the pics to the control from memory) is working correctly, so what could be causing them to either never appear or disappear too fast to notice?

Do you think this might be related to $WM_PAINT events (I'm using On Event mode), or something similar? Because I don't currently have any $WM_PAINT (or whatever) handlers. Should I have such handlers? And what do I do there if I have it/them?

I'm very confused. Little help, please?

 

Edited by Mbee

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

In older version of AutoIt (<3.3.10?) i had same problems, but with actual stable there are no problems demostrating with this script:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled

Global $sPicPath = StringReplace(StringReplace(@AutoItExe, '_X64', ''), 'Autoit3.exe', '') & '\Examples\GUI\mslogo.jpg'
Global $idPic

Example()

Func Example()
    GUICreate("My GUI picture", 350, 165, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) ; will create a dialog box that when displayed is centered
    GUISetBkColor(0xE0FFFF)
    GUISetOnEvent($GUI_EVENT_CLOSE,'_Exit')
    $idPic = GUICtrlCreatePic('', 50, 50, 200, 50)
    GUICtrlCreateButton('&Show Pic', 10, 110, 330)
    GUICtrlSetOnEvent(-1,'_Show')
    GUISetState(@SW_SHOW)
    While 1
        Sleep(10000)
    WEnd
EndFunc   ;==>Example

Func _Show()
    GUICtrlSetImage($idPic, $sPicPath)
EndFunc   ;==>_Show

Func _Exit()
    GUIDelete()
    Exit
EndFunc   ;==>_Exit

if this examples run for you show a small reproducer script showing your issue.

Edited by AutoBert

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hey, thanks for your reply, AutoBert!

I have a hunch that I've found a key part of the problem (though I still don't understand why it worked with the debugger). I was actually in the process of preparing some example code to post here when I discovered a coding error in the initial code I got from @ProgAndy / @Zedna for setting a contol's image from binary data -- that'll screw things up, of course! For whatever reason, there was no error or crash from my big GUI app, but only when I tried to run the sample code I was putting together for posting.

This prompted me to read farther into the thread (I was stupid not to do so at first! :>), where I saw that ProgAncy had later realized the bug (see: here). He re-coded some related funcs to eliminate the bug(s), but he specifically pointed out that "... no plans to create the one-liner functions _SetImageBinaryToCtrl...", which is the function I needed and was using. My guess is that's the key to my problem (I'm hoping).

So right now I'm coding up the equivalent of _SetImageBinaryToCtrl() which uses the newer version of ProgAndy's functions, and once that's done, I'll try using it in my big app. If that doesn't work or hasn't solved my problem, I'll come back here and post the requested code sample for your kind review.

Thanks again!

Edited by Mbee

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hmm...  Well, I cobbled together a simple function named _Mod_Set_Control_From_Binary() which crudely and probably redundantly combined code from @UEZ, @ProgAndy, and @Zedna .  I'm not sure in the least whether UEZ's code actually needed the other code, but this deep image-related stuff is way over my head.

The very annoying thing is, the small sample I cobbled together for posting here works fine when run in normal compiled mode or with the debugger, but my big GUI app (which is thousands of lines long so I can't post it) still only shows the controls when I run it with the graphical debugger!  Perhaps the combined stuff from all those different coders has memory leaks (or a bug), and that's why it's not working right without the debugger (maybe the debugger allocates so much extra RAM that the memory leaks go undetected??)  Of course, I'm the first to admit the fault is probably my own somewhere.

Anyway, this the following sample code does NOT reproduce the disappearing controls problem, but perhaps you would be so kind as to look at the code from the others to see if there might be memory leaks or other buggy stuff there?  A more elegant approach to setting the images of various controls from binary data (rather than from files) seems strongly called for, but I'm not yet the person for the job...

#include <GDIPlus.au3>
#include <GDIPlusConstants.au3>
#include <GUIConstants.au3>
#include <Memory.au3>
#include <MemoryConstants.au3>

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
;
AutoItSetOption("WinTitleMatchMode", 1)
AutoItSetOption("MouseCoordMode", 0)
AutoItSetOption("GUICloseOnESC", 0 )

Global $ghGDIPDll = $__g_hGDIPDll

Global $MyGUI = GUICreate("MyGUI",289,280,-1,-1,BitOr($WS_CAPTION,$WS_SYSMENU,$WS_MINIMIZEBOX,$WS_VISIBLE),BitOr($WS_EX_ACCEPTFILES,$WS_EX_APPWINDOW))
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $MyGUI)

Global $Gc_OpenPicID1 = GUICtrlCreatePic("",102,20,85,30,-1,-1)
Global $Gc_OpenPicID2 = GUICtrlCreatePic("",102,54,85,30,-1,-1)
Global $Gc_OpenPicID3 = GUICtrlCreatePic("",102,88,85,30,-1,-1)
Global $Gc_OpenPicID4 = GUICtrlCreatePic("",102,120,85,30,-1,-1)
Global $Gc_OpenPicID5 = GUICtrlCreatePic("",102,154,85,30,-1,-1)
Global $Gc_OpenPicID6 = GUICtrlCreatePic("",102,184,85,30,-1,-1)

Global $G_BinOpenPic = _My_LoadOpenBtnPicBin()

_GDIPlus_Startup()

_Mod_Set_Control_From_Binary( $Gc_OpenPicID1, $G_BinOpenPic )
_Mod_Set_Control_From_Binary( $Gc_OpenPicID2, $G_BinOpenPic )
_Mod_Set_Control_From_Binary( $Gc_OpenPicID3, $G_BinOpenPic )
_Mod_Set_Control_From_Binary( $Gc_OpenPicID4, $G_BinOpenPic )
_Mod_Set_Control_From_Binary( $Gc_OpenPicID5, $G_BinOpenPic )
_Mod_Set_Control_From_Binary( $Gc_OpenPicID6, $G_BinOpenPic )

_GDIPlus_Shutdown()


While True
    Sleep(1000) ; Sleep for a second
WEnd


Func Close()
    GUIDelete($MyGUI)
    Exit
EndFunc


Func _Mod_Set_Control_From_Binary( $arg_ControlID, $arg_BinaryImage )

    Local $Lf_ControlHdl = GUICtrlGetHandle( $arg_ControlID )
    Local $Lf_HbitmapHdl = Load_BMP_From_Mem( $arg_BinaryImage, True )
    _GUICtrlStatic_SetImage($arg_ControlID, $Lf_HBitmapHdl)

EndFunc


Func Load_BMP_From_Mem($mem_image, $hHBITMAP = False) ;coded by UEZ - thanks to progandy for the MemGlobalAlloc and tVARIANT lines
    Local $memBitmap, $len, $tMem, $hImage, $hData, $pData, $hBitmap, $hStream, $tVARIANT, $aCall, $hHBmp
    $memBitmap = Binary($mem_image) ;load image  saved in variable (memory) and convert it to binary
    $len = BinaryLen($memBitmap) ;get length of image
    $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory  ($GMEM_MOVEABLE = 0x0002)
    $pData = _MemGlobalLock($hData) ;translate the handle into a pointer
    $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
    $hStream = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0)
    $hStream = $hStream[3]
    $hBitmap = DllCall($__g_hGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
    $hBitmap = $hBitmap[2]
    $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    $aCall = 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
        $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBmp
    EndIf
    Return $hBitmap
EndFunc   ;==>Load_BMP_From_Mem



; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_ImageLoadFromHGlobal
; Description ...: Creates an Image object based on movable HGlobal memory block
; Syntax.........: _GDIPlus_ImageLoadFromHGlobal($hGlobal)
; Parameters ....: $hGlobal - Handle of a movable HGlobal memory block
; Return values .: Success      - Pointer to a new Image object
;                  Failure      - 0 and either:
;                  |@error and @extended are set if DllCall failed:
;                  | -@error = 1 if could not create IStream
;                  | -@error = 2 if DLLCall to create image failed
;                  |$GDIP_STATUS contains a non zero value specifying the error code
; Author ........: ProgAndy
; Modified.......:
; Remarks .......: After you are done with the object, call _GDIPlus_ImageDispose to release the object resources.
;                  The HGLOBAL will be owned by the image and freed automatically when the image is disposed.
; Related .......: _GDIPlus_ImageLoadFromStream, _GDIPlus_ImageDispose
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _GDIPlus_ImageLoadFromHGlobal($hGlobal)
    Local $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $hGlobal, "bool", True, "ptr*", 0)
    If @error Or $aResult[0] <> 0 Or $aResult[3] = 0 Then Return SetError(1, @error, 0)
    Local $hImage = DllCall($ghGDIPDll, "uint", "GdipLoadImageFromStream", "ptr", $aResult[3], "int*", 0)
    Local $error = @error
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    Local $aCall = DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $aResult[3], "dword", 8 + 8 * @AutoItX64, "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT))
    If $error Then Return SetError(2, $error, 0)
    If $hImage[2] = 0 Then Return SetError(3, 0, $hImage[2])
    Return $hImage[2]
EndFunc   ;==>_GDIPlus_ImageLoadFromHGlobal


; #FUNCTION# ====================================================================================================================
; Name...........: _MemGlobalAllocFromBinary
; Description ...: Greates a movable HGLOBAL memory block from binary data
; Syntax.........: _MemGlobalAllocFromBinary($bBinary)
; Parameters ....: $bBinary - Binary data
; Return values .: Success      - Handle of a new movable HGLOBAL
;                  Failure      - 0 and set @error:
;                  |1  - no data
;                  |2  - could not allocate memory
;                  |3  - could not set data to memory
; Author ........: ProgAndy
; Modified.......:
; Remarks .......:
; Related .......: _MemGlobalAlloc, _MemGlobalFree, _MemGlobalLock
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _MemGlobalAllocFromBinary(Const $bBinary)
    Local $iLen = BinaryLen($bBinary)
    If $iLen = 0 Then Return SetError(1, 0, 0)
    Local $hMem = _MemGlobalAlloc($iLen, $GMEM_MOVEABLE)
    If @error Or Not $hMem Then Return SetError(2, 0, 0)
    DllStructSetData(DllStructCreate("byte[" & $iLen & "]", _MemGlobalLock($hMem)), 1, $bBinary)
    If @error Then
        _MemGlobalUnlock($hMem)
        _MemGlobalFree($hMem)
        Return SetError(3, 0, 0)
    EndIf
    _MemGlobalUnlock($hMem)
    Return $hMem
EndFunc   ;==>_MemGlobalAllocFromBinary

; #FUNCTION# ====================================================================================================================
; Name...........: _MemGlobalAllocFromMem
; Description ...: Greates a movable HGLOBAL memory block and copies data from memory
; Syntax.........: _MemGlobalAllocFromMem($pSource, $iLength)
; Parameters ....: $pSource  - Pointer to memorybloc to copy from
;                  $iLength  - Length of data to copy
; Return values .: Success      - Handle of a new movable HGLOBAL
;                  Failure      - 0 and set @error:
;                  |1  - invalid $pSource
;                  |2  - invalid $iLength
;                  |3  - could not allocate memory
; Author ........: ProgAndy
; Modified.......:
; Remarks .......:
; Related .......: _MemGlobalAlloc, _MemGlobalFree, _MemGlobalLock
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _MemGlobalAllocFromMem($pSource, $iLength)
    If Not $pSource Then Return SetError(1, 0, 0)
    If $iLength < 1 Then Return SetError(2, 0, 0)
    Local $hMem = _MemGlobalAlloc($iLength, $GMEM_MOVEABLE)
    If @error Or Not $hMem Then Return SetError(3, 0, 0)
    _MemMoveMemory($pSource, _MemGlobalLock($hMem), $iLength)
    _MemGlobalUnlock($hMem)
    Return $hMem
EndFunc   ;==>_MemGlobalAllocFromMem

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlStatic_SetImage
; Description ...: Sets a HBITMAP to a static control like image or label
; Syntax.........: _GUICtrlStatic_SetImage($iCtrlId, $hBitmap)
; Parameters ....: $iCtrlId  - CtrlId or handle of Control in the current process
;                  $hBitmap  - Pointer top Windows HBITMAP
; Return values .: Success      - 1
;                  Failure      - 0 and set @error:
;                  |1  - invalid $pSource
;                  |1  - invalid $pSource
; Author ........: ProgAndy, Zedna
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _GUICtrlStatic_SetImage($iCtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0xE
    Local Const $GWL_STYLE = -16

    If IsHWnd($iCtrlId) Then
        If WinGetProcess($iCtrlId) <> @AutoItPID Then Return SetError(1,0,0)
    Else
        $iCtrlId = GUICtrlGetHandle($iCtrlId)
        If Not $iCtrlId Then Return SetError(2,0,0)
    EndIf
    ; set SS_BITMAP style to control
    Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE)
    If @error Then Return SetError(3, 0, 0)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP))
    If @error Then Return SetError(4, 0, 0)
    Local $oldBmp = DllCall("user32.dll", "handle", "SendMessageW", "hwnd", $iCtrlId, "int", $STM_SETIMAGE, "wparam", $IMAGE_BITMAP, "handle", $hBitmap)
    If @error Then Return SetError(5, 0, 0)
    If $oldBmp[0] Then _WinAPI_DeleteObject($oldBmp[0])
    Return 1
EndFunc

;
;   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
;
Func _My_LoadOpenBtnPicBin ()                               ; Code Generated by BinaryToAu3Kompressor.
     Local $sFileBin = '/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ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xfY2Hwux1c030Qf3pMfMNl5Jfot9uObvhqp8lseFc/58X2Nh8LsdXNN9EH96THzDZeSX6Lfbjm74aqfJbHhXP+fF9jYfC7HVzTfRB/ekx8w2Xkl+i3245u+GqnyWx4Vz/nxfY2Hwux1c030Qf3pMfMNuBvBK9FRwED5vzaYB7wFvVe3/AKe3EbTOj3vSj9rNj8NtyLjyoF7SxSgD6pSY+YbXK0g+Dp8nvpMuEJkVOuWLLt6rM6lYq9MZFeJOY6Kk26R0WrlCuNihDi4bJqKAgvzBVCCqqO8RVU4kx1JPnuoOXKihBMU/JBwpocZCmIVQG6QEQKcCnOHGCYG0ObUf3h1X46CiIkSmYMEEFSpnRBybiXeCiqoRVREz1wZV2ZEyiaZxSMsKeqaehf3CaZ5yEIkQiaZCppplKRNMhQIQhCABSkIUoAUpSlAClKUAAAAAAAANsLZW2//Z'
    $sFileBin = Binary ( _Base64Decode ( $sFileBin ) )
    Return $sFileBin
EndFunc   ;==> _My_LoadOpenBtnPicBin

Func _Base64Decode($input_string) ; by trancexx
    Local $struct = DllStructCreate('int')
    Local $a_Call = DllCall('Crypt32.dll', 'int', 'CryptStringToBinary', 'str', $input_string, 'int', 0, 'int', 1, 'ptr', 0, 'ptr', DllStructGetPtr($struct, 1), 'ptr', 0, 'ptr', 0)
    If @error Or Not $a_Call[0] Then Return SetError(1, 0, '')
    Local $a = DllStructCreate('byte[' & DllStructGetData($struct, 1) & ']')
    $a_Call = DllCall('Crypt32.dll', 'int', 'CryptStringToBinary', 'str', $input_string, 'int', 0, 'int', 1, 'ptr', DllStructGetPtr($a), 'ptr', DllStructGetPtr($struct, 1), 'ptr', 0, 'ptr', 0)
    If @error Or Not $a_Call[0] Then Return SetError(2, 0, '')
    Return DllStructGetData($a, 1)
EndFunc   ;==>_Base64Decode

 

Many thanks, @AutoBert !

Edited by Mbee

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I shorten you code a little bit and added _WinAPI_DeleteObject($Lf_HbitmapHdl) to release the GDI resource.

 

#include <GDIPlus.au3>
#include <GDIPlusConstants.au3>
#include <GUIConstants.au3>
#include <Memory.au3>
#include <MemoryConstants.au3>

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
;
AutoItSetOption("WinTitleMatchMode", 1)
AutoItSetOption("MouseCoordMode", 0)
AutoItSetOption("GUICloseOnESC", 0 )

Global $ghGDIPDll = $__g_hGDIPDll

Global $MyGUI = GUICreate("MyGUI",289,280,-1,-1,BitOr($WS_CAPTION,$WS_SYSMENU,$WS_MINIMIZEBOX,$WS_VISIBLE),BitOr($WS_EX_ACCEPTFILES,$WS_EX_APPWINDOW))
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $MyGUI)

Global $Gc_OpenPicID1 = GUICtrlCreatePic("",102,20,85,30,-1,-1)
Global $Gc_OpenPicID2 = GUICtrlCreatePic("",102,54,85,30,-1,-1)
Global $Gc_OpenPicID3 = GUICtrlCreatePic("",102,88,85,30,-1,-1)
Global $Gc_OpenPicID4 = GUICtrlCreatePic("",102,120,85,30,-1,-1)
Global $Gc_OpenPicID5 = GUICtrlCreatePic("",102,154,85,30,-1,-1)
Global $Gc_OpenPicID6 = GUICtrlCreatePic("",102,184,85,30,-1,-1)

Global $G_BinOpenPic = _My_LoadOpenBtnPicBin()

_GDIPlus_Startup()

_Mod_Set_Control_From_Binary( $Gc_OpenPicID1, $G_BinOpenPic )
_Mod_Set_Control_From_Binary( $Gc_OpenPicID2, $G_BinOpenPic )
_Mod_Set_Control_From_Binary( $Gc_OpenPicID3, $G_BinOpenPic )
_Mod_Set_Control_From_Binary( $Gc_OpenPicID4, $G_BinOpenPic )
_Mod_Set_Control_From_Binary( $Gc_OpenPicID5, $G_BinOpenPic )
_Mod_Set_Control_From_Binary( $Gc_OpenPicID6, $G_BinOpenPic )

_GDIPlus_Shutdown()


While True
    Sleep(1000) ; Sleep for a second
WEnd


Func Close()
    GUIDelete($MyGUI)
    Exit
EndFunc


Func _Mod_Set_Control_From_Binary( $arg_ControlID, $arg_BinaryImage )

    Local $Lf_ControlHdl = GUICtrlGetHandle( $arg_ControlID )
    Local $Lf_HbitmapHdl = _GDIPlus_BitmapCreateFromMemory( $arg_BinaryImage, True )
    _GUICtrlStatic_SetImage($arg_ControlID, $Lf_HBitmapHdl)
    _WinAPI_DeleteObject($Lf_HbitmapHdl)

EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlStatic_SetImage
; Description ...: Sets a HBITMAP to a static control like image or label
; Syntax.........: _GUICtrlStatic_SetImage($iCtrlId, $hBitmap)
; Parameters ....: $iCtrlId  - CtrlId or handle of Control in the current process
;                  $hBitmap  - Pointer top Windows HBITMAP
; Return values .: Success      - 1
;                  Failure      - 0 and set @error:
;                  |1  - invalid $pSource
;                  |1  - invalid $pSource
; Author ........: ProgAndy, Zedna
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _GUICtrlStatic_SetImage($iCtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0xE
    Local Const $GWL_STYLE = -16

    If IsHWnd($iCtrlId) Then
        If WinGetProcess($iCtrlId) <> @AutoItPID Then Return SetError(1,0,0)
    Else
        $iCtrlId = GUICtrlGetHandle($iCtrlId)
        If Not $iCtrlId Then Return SetError(2,0,0)
    EndIf
    ; set SS_BITMAP style to control
    Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE)
    If @error Then Return SetError(3, 0, 0)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP))
    If @error Then Return SetError(4, 0, 0)
    Local $oldBmp = DllCall("user32.dll", "handle", "SendMessageW", "hwnd", $iCtrlId, "int", $STM_SETIMAGE, "wparam", $IMAGE_BITMAP, "handle", $hBitmap)
    If @error Then Return SetError(5, 0, 0)
    If $oldBmp[0] Then _WinAPI_DeleteObject($oldBmp[0])
    Return 1
EndFunc

;
;   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
;
Func _My_LoadOpenBtnPicBin ()                               ; Code Generated by BinaryToAu3Kompressor.
     Local $sFileBin = '/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAAeAGQDAREAAhEBAxEB/8QAHgAAAQQCAwEAAAAAAAAAAAAABwAFBggJCgIDBAv/xABBEAAABgEBAwYKCAQHAAAAAAABAgMEBQYHCAAREgkTFBUhMQoZGkFRVVdhlNQWF3GRlbHW8CIjMjNTZIGSoaTB/8QAHgEAAQQCAwEAAAAAAAAAAAAAAAUGBwgECQIDCgH/xABEEQAABgEBAwYKBwYGAwAAAAABAgMEBQYHEQAIEhMUFRchMRZBUVRVYZSV1NUYI3GBkbHBCSIyocXxJUVSY4TwhZLR/9oADAMBAAIRAxEAPwDbq1F6vm+PrHMVaJeJj1YotEiSNeppneOkkWhpd3ISZW4vYs8S+OvCNWMWoiv0xnIuHcgfjQax04UXGB5xg1kXKZgBwBXHEuicQSTEygNk0EBOCLgHKQEdKLOAOnySqBEkQ0OovUfL28EnUJqQhGDhMeZGUY8DRwmAuFipNzv3Dt4CRnDIzBwdWNbtWR0lecN3ay7owmSQZ0GmeUBuTRZQiU+cpQEwlL15bhEA3juATBZgE24O8dwb/d3bTQ0wpFKlKJmeo9mo8zjA17g7ujxAPL4/tEdR2qpI72FibnOCcqYoAI6B0nPiIB4gE3TQaiAd46Br36APdGh5RO9gPZPqf6ztuD/j6UDtn9RsP5iHsUWP9PD8tkYd7y1eKVEf/JT4f1zZ1gte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O46YEKRpAKpFIGhQGcsSogAetWWUMP3iO0bN4JnovMO82c83CI/5aph+TINsMbZPj3vij/wAJh8LsqFxvTC90Qf3rMj+cgO3DyS/Rb7cc3fD1T5LY8K57z4vsTD4Xbl1c030Qf3pMfMNl5Jfot9uObvhqp8lseFc/58X2Nh8LsdXNN9EH96THzDZeSX6Lfbjm74aqfJbHhXP+fF9jYfC7HVzTfRB/ekx8w2Xkl+i3245u+GqnyWx4Vz/nxfY2Hwux1c030Qf3pMfMNl5Jfot9uObvhqp8lseFc/58X2Nh8LsdXNN9EH96THzDZeSX6Lfbjm74aqfJbHhXP+fF9jYfC7HVzTfRB/ekx8w2Xkl+i3245u+GqnyWx4Vz/nxfY2Hwux1c030Qf3pMfMNuBvBK9FRwED5vzaYB7wFvVe3/AKe3EbTOj3vSj9rNj8NtyLjyoF7SxSgD6pSY+YbXK0g+Dp8nvpMuEJkVOuWLLt6rM6lYq9MZFeJOY6Kk26R0WrlCuNihDi4bJqKAgvzBVCCqqO8RVU4kx1JPnuoOXKihBMU/JBwpocZCmIVQG6QEQKcCnOHGCYG0ObUf3h1X46CiIkSmYMEEFSpnRBybiXeCiqoRVREz1wZV2ZEyiaZxSMsKeqaehf3CaZ5yEIkQiaZCppplKRNMhQIQhCABSkIUoAUpSlAClKUAAAAAAAANsLZW2//Z'
    $sFileBin = Binary ( _Base64Decode ( $sFileBin ) )
    Return $sFileBin
EndFunc   ;==> _My_LoadOpenBtnPicBin

Func _Base64Decode($input_string) ; by trancexx
    Local $struct = DllStructCreate('int')
    Local $a_Call = DllCall('Crypt32.dll', 'int', 'CryptStringToBinary', 'str', $input_string, 'int', 0, 'int', 1, 'ptr', 0, 'ptr', DllStructGetPtr($struct, 1), 'ptr', 0, 'ptr', 0)
    If @error Or Not $a_Call[0] Then Return SetError(1, 0, '')
    Local $a = DllStructCreate('byte[' & DllStructGetData($struct, 1) & ']')
    $a_Call = DllCall('Crypt32.dll', 'int', 'CryptStringToBinary', 'str', $input_string, 'int', 0, 'int', 1, 'ptr', DllStructGetPtr($a), 'ptr', DllStructGetPtr($struct, 1), 'ptr', 0, 'ptr', 0)
    If @error Or Not $a_Call[0] Then Return SetError(2, 0, '')
    Return DllStructGetData($a, 1)
EndFunc   ;==>_Base64Decode

 

Without seeing your full code I cannot say what's wrong with it (at least the GUI initializing part).

Edited by UEZ
1 person likes this

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Wow, that's vastly improved and optimized! You have my considerable gratitude, @UEZ !

And although I very much needed your help, I sincerely apologize for messaging you. I won't do it again.

Alas, although your optimized func works perfectly, the controls set that way still only show up when I run the debugger. What a bizzare situation...

Share this post


Link to post
Share on other sites

Aha! A vital clue!  If I use the directive: #AutoIt3Wrapper_UseX64=N to disable building 64-bit code, everything works correctly in normal exe mode!

Since the only significant change to my app that produced this strange situation was to switch from creating my GUI control pics and button images from files to setting their images from internal binary data, obviously something in that new code (thanks again, UEZ) doesn't work right in 64-bit mode!

I'm gonna look at the memory allocation stuff in there and see if I can figure out how to make it compatible with 64-bit code (although this stuff is mostly over my tiny little head!)

 

Share this post


Link to post
Share on other sites

Well, I haven't been able to figure out why the code UEZ & ProgAndy put together doesn't work correctly in my app when I compile it for 64-bits.

Any suggestions?

 

Share this post


Link to post
Share on other sites

I have modiefied @UEZ's example script Display images from memory in controls:

;coded by UEZ 2011
#include <buttonconstants.au3>
#include <guiconstantsex.au3>
#include <gdiplus.au3>
#include <memory.au3>

_GDIPlus_Startup()
;~ Global Const $IMAGE_BITMAP = 0
Global Const $STM_SETIMAGE = 0x0172

Global $hBmp_Logo, $hBmp_Button     ;needed for releasing the objekts
Global $msg
Global Const $hGUI = GUICreate("Example", 600, 250)
Global Const $idLogo = GUICtrlCreatePic("", 215, 20, 169, 68)
Global Const $idButton = GUICtrlCreateButton("", 266, 150, 78, 81, $BS_FLAT + $BS_BITMAP)

Global Const $hButton = GUICtrlGetHandle($idButton)
_SetImageFromMem($idLogo,'AutoIt_Logo',$hBmp_Logo)
_SetImageFromMem($hButton,'Merlin',$hBmp_Button)

Func _SetImageFromMem($Control,$MemFunc, ByRef $hGDIBmp)
    ;_SetImageFromMem($Control,$MemFunc, ByRef $hGDIBmp)
    ;Parameters:    $Control    the ControlID or the ControlHandle
    ;               $MemFunc    Functionname which returns the Memorydata
    ;               $hGDIBmp        the GDIPlusBitmaphandle
    $dImage=Call(Execute($MemFunc))
    ConsoleWrite($dImage&@CRLF)
    $hGDIBmp = _GDIPlus_BitmapCreateFromMemory($dImage, True)
    _WinAPI_DeleteObject(GUICtrlSendMsg($Control, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBmp))
    If IsHWnd($Control) Then
        ConsoleWrite('_WinAPI_UpdateWindow'&@CRLF)
        _WinAPI_UpdateWindow($Control)
    EndIf
EndFunc
#cs
Global Const $Bmp_Logo = _GDIPlus_BitmapCreateFromMemory(AutoIt_Logo(), True)
_WinAPI_DeleteObject(GUICtrlSendMsg($idLogo, $STM_SETIMAGE, $IMAGE_BITMAP, $Bmp_Logo))
Global Const $Bmp_Button = _GDIPlus_BitmapCreateFromMemory(Merlin(), True)
_WinAPI_DeleteObject(_SendMessage($hButton, $BM_SETIMAGE, $IMAGE_BITMAP, $Bmp_Button))
_WinAPI_UpdateWindow($hButton)
#ce

GUISetState()

While True
    $msg = GUIGetMsg()
    Switch $msg
        Case $idLogo
            MsgBox(0, "Information", "The picture has been clicked!")
        Case $idButton
            MsgBox(0, "Information", "the button has been clicked!")
        Case $GUI_EVENT_CLOSE
            _WinAPI_DeleteObject($hBmp_Logo)
            _WinAPI_DeleteObject($hBmp_Button)
            _GDIPlus_Shutdown()
            GUIDelete($hGUI)
            Exit
    EndSwitch
WEnd


Func AutoIt_Logo()
    Local $AutoIt_Logo
    $AutoIt_Logo &=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av9AFQ9AFZ/AACzywDVbQwy8AwA4sAAAZAAwAARAIWR3d8p0AMplgDWAALgAAwAL4PdnOIAwAy0AEII4ANMAAnwmu4AxuAkAA8NznU9gT/iYAslMNpAAEJoAAAT6Q4Rue3zgAnt8aDgAzLAAAKa7O89LYLS4AIlGdCdUQCAEAIAMmsA4Z4AMANQ4AUM7jPpAAAetgApv83C4AdAXsPOTAUuQAV6AKpPCsQLAAA8AgAGb+yZMA3GiBAORaLuQAXI4pi50JV/AA5aqgCk8KAqQAAAKBoArqfD4Ac66+Ev7mmNIA1HI+5+syRHMAIO4rgC7ojF4AEIp92IxddIoA3eiUXumWfukAmJ7pmr7pnB4AEAA7'
    $AutoIt_Logo = _Base64Decode($AutoIt_Logo)
    Local $tSource = DllStructCreate('byte[' & BinaryLen($AutoIt_Logo) & ']')
    DllStructSetData($tSource, 1, $AutoIt_Logo)
    Local $tDecompress
    _WinAPI_LZNTDecompress($tSource, $tDecompress)
    $tSource = 0
    Return Binary(DllStructGetData($tDecompress, 1))
EndFunc   ;==>AutoIt_Logo

Func Merlin()
    Local $Merlin
    $Merlin &= 'R0lGODlhRABHAPcAAP///xgxcRw1fRgtbRw5ghgtaRw1eRw5hsrKyhgxdRw9lhQkYRgxbRQoaRQ1fRg1eRw5ihg1dSBBkhQtZcLCwr6SlhQkWSA9kq6qrsaamrKytrq2tsrKzr6qQRQtdSA5ijldlhg1hhQxfaKenhAodRw9igwkVXl5eaJ9eRgxaUFpns6ioj1JVRAcSVVZWWFlYQAEHIaCghQ1jhgoYbaiPevr676+vhQtceeysiBBnrKOjhAkbS05Wd+mqhAkXY6KjqKWQWlpacqyQSAtSQggZcbGygwcUWFlVWl5kn1hYWGGshgxeaqqqsbGwpaSltvb3yQ9cYpxcSAxWRw1gt+uro59hqKmpjFFeYZpaaqCghQoXSAxaRAkZZKSjhAxhgQQNT1dkvPz8yhJmhQ5mhQgPTU5SX11SYaGjgwgWaKCguPj4wgQJK6aPZZxcUVFRTVZkklNYa6Kj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giBJKkJCTdKII9uIALjyDDKNsAh6y0hgp0gEMDBnCNRNwgFLmYxSweKUsB5AN9odCDC4iQDnLg4DiKIgoSspCBFWQgDvIgphkSUYoOzCIZv3OjLEUQDEWAAhQdWAcR4ODNFVSAHKgaChLekf+BDNThFqMYwASkwYYOdEAIwRCBOilJSXsoQhUdoAEQhtGINERhBbdAgVOQgALWkCEDUBhAA1hAAyEIQRiQZChDH2AARUSUBtJoRBTYsYI4oGA5Q7GGP7LzhSTgogAzWMAiPOEJA6T0AUhl6BKEIQSJSmEP7BhCGvxRCKdQog47hQY0GABULTTAAyJg6UojgNQHiOAFQtCDHtjAg058oQ7kSII3skKJRtAiCZxApBa0UIAEkHWsESArS9vxggSMQg9wSActCqGLuc7FDsDgxDV24AO+BuCvcoxAAjYb2Ah4wAMJ8EAlYjEEdXDiHogIzDDigYw+mIEFPkikX8u62QD/bPa2tdVHA4aADH54ZC6IYEE/+vAJcLghtgywLVKXkIAAONe5t3UuV4fAiXT8di6XQMYnzrEFNPA1uZu9Ai48EAB93OC5zyViAaSgjk5cNytg4IcdzDAIHlR2iLb1QB4wUQkSVGIR50UvA8iohXLkMjAqSAcXCmAGO6DBAmVMrn5pkIsjAMETAZYuVwtQYGc8IjDGMMEEGpACalgAwikYgD5G4QkgsIEGpbgBEZMbAPVy2AgWSAeIRVyACczAAnwtgDxKAYQOsOHIeZDxjGes13RYAFdzMYQFJkDlGfghyAyoxB7McGQagKMS+mBAmJkM1HQYQQsI3usMZqCFKyNyacCyWAQbznEEM7hAyWSeQJuvoALNwAIKUNBCC6b85hvAgQ2J2MEO5LFkG0/AAipILXNOAQYLxBaRN1hEOxqgygWseQYNaEBQfZCCFHxIBW8otTwYPYAUGGITIIi1rGP9BplB6da4TkhAAAA7'
    Return Binary(_Base64Decode($Merlin))
EndFunc   ;==>Merlin

Func _WinAPI_LZNTDecompress(ByRef $tInput, ByRef $tOutput, $iBufferSize = 0x800000)
    Local $tBuffer, $Ret
    $tOutput = 0
    $tBuffer = DllStructCreate('byte[' & $iBufferSize & ']')
    If @error Then Return SetError(1, 0, 0)
    $Ret = DllCall('ntdll.dll', 'uint', 'RtlDecompressBuffer', 'ushort', 0x0002, 'ptr', DllStructGetPtr($tBuffer), 'ulong', $iBufferSize, 'ptr', DllStructGetPtr($tInput), 'ulong', DllStructGetSize($tInput), 'ulong*', 0)
    If @error Then Return SetError(2, 0, 0)
    If $Ret[0] Then Return SetError(3, $Ret[0], 0)
    $tOutput = DllStructCreate('byte[' & $Ret[6] & ']')
    If Not _WinAPI_MoveMemory(DllStructGetPtr($tOutput), DllStructGetPtr($tBuffer), $Ret[6]) Then
        $tOutput = 0
        Return SetError(4, 0, 0)
    EndIf
    Return $Ret[6]
EndFunc   ;==>_WinAPI_LZNTDecompress

Func _Base64Decode($input_string)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $input_string, "int", 0, "int", 1, "ptr", 0, "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(1, 0, "")
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $input_string, "int", 0, "int", 1, "ptr", DllStructGetPtr($a), "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($a, 1)
EndFunc   ;==>_Base64Decode

the func _SetImageFromMem is bugy when using gif it's not working.

1 person likes this

Share this post


Link to post
Share on other sites

An updated version what AutoBert has posted:

;coded by UEZ 2012
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <Memory.au3>

_GDIPlus_Startup()
;~ Global Const $IMAGE_BITMAP = 0
Global Const $STM_SETIMAGE = 0x0172
Global $msg
Global Const $hGUI = GUICreate("Test", 600, 250)
Global Const $idLogo = GUICtrlCreatePic("", 215, 20, 169, 68)
Global Const $idButton = GUICtrlCreateButton("", 266, 150, 78, 81, BitOR($BS_FLAT, $BS_BITMAP))
Global Const $hButton = GUICtrlGetHandle($idButton)
Global $hBmp, $hBmp_Logo, $hBmp_Button
If @OSBuild < 6000 Then
    $hBmp = _GDIPlus_BitmapCreateFromMemory(AutoIt_Logo())
    $hBmp_Logo = ConvertBitmap($hBmp)
    _GDIPlus_BitmapDispose($hBmp)
Else
    $hBmp_Logo = _GDIPlus_BitmapCreateFromMemory(AutoIt_Logo(), True)
EndIf
_WinAPI_DeleteObject(GUICtrlSendMsg($idLogo, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp_Logo))

If @OSBuild < 6000 Then
    $hBmp = _GDIPlus_BitmapCreateFromMemory(Merlin())
    $hBmp_Button = ConvertBitmap($hBmp)
    _GDIPlus_BitmapDispose($hBmp)
Else
    $hBmp_Button = _GDIPlus_BitmapCreateFromMemory(Merlin(), True)
EndIf
_WinAPI_DeleteObject(_SendMessage($hButton, $BM_SETIMAGE, $IMAGE_BITMAP, $hBmp_Button))
;~ _WinAPI_UpdateWindow($hButton)
GUISetState()


While True
    Switch GUIGetMsg()
        Case $idLogo
            MsgBox(0, "Information", "Bild wurde geklickt!")
        Case $idButton
            MsgBox(0, "Information", "Button wurde geklickt!")
        Case $GUI_EVENT_CLOSE
            _WinAPI_DeleteObject($hBmp_Logo)
            _WinAPI_DeleteObject($hBmp_Button)
            GUIDelete($hGUI)
            _GDIPlus_Shutdown()
            Exit
    EndSwitch
WEnd

Func ConvertBitmap($hBitmap)
    Local $iButtonColor = _WinAPI_GetSysColor($COLOR_BTNFACE)
    $iButtonColor = 0x10000 * BitAND($iButtonColor, 0xFF) + BitAND($iButtonColor, 0x00FF00) + BitShift($iButtonColor, 16)
    Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap), $iHeight = _GDIPlus_ImageGetHeight($hBitmap)
    Local $hBitmap_New = _GDIPlus_BitmapCreateFromMemory($iWidth, $iHeight)
    Local $hCtx_new = _GDIPlus_ImageGetGraphicsContext($hBitmap_New)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $iButtonColor)
    _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   ;==>ConvertBitmap

Func AutoIt_Logo()
    Local $AutoIt_Logo
    $AutoIt_Logo &= '/z9HSUY4OWGpAEQA9wAAkpKSQEBAampr4eHhzdjjVom2ZJnGw83Yv7+/7e3tOmSN2+Pspb7WmrHHWpTMMzM1eaPIxsbGmb3gqqqq0Nvl5uzxp8LdlJ2mf39/hISE8fHxsLCwuMDJ6Ojo/Pz8o8PiISEltLjHTFhj1dXV9PT0W2h0cXJyRnGaUVxoTEyNAABCNjZ8mJiYoKGhpKSknZ2dzs7Oi5mlW1tbZ5W5ubm5NkdXi7TdZ3aEyMjIAAB7kqzFYGBhpa21Q2WGjY2NmrvbUlJSV4Or2dnZe4iUwcHBKkdkVI7HV3mZeYGL5OTkmaKuAABqAAAkAQE00dHRkrLRcHuFra2tQWyWx9Lcg6zUqbC7tra2AABU5ubmIyN5lLnefKnTYGx4g4yUq8nm3NzcSUlKfazZAABz+vr6ZXF9TYO6m62+h5GbVmNuqMbjQ0lWJzhKiqzNOlJpdJq5cqTTiYmJKiou1N7nJ0FbS32s9vb2ytXg+Pj4AAASh4enS3miERERIzxU6/D0k6Kwu8XPmJi5GBsmUn2m6urqZp3QYYeow8TQmbXSk7bYNFNxGBh8NEthbaLUMzpDRFFdmqez39/fjqO4eXl5eIygncDiiJ60jrDSR2F6o7nOAABgnqm1OF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RAHdSbw0gAQh3Uf5QDNMcABOc5c0VX1EAAHRY50NRF/UcAjDRESs0E58MA1Ljx01PNFlEA7dRUndHVIAAAHe3MLUAEZ1AAA+jwCuSgB4UAYNJuEA6nMNcA4QDTqCDOt/AACokwByKwAdwAcM4+sANxcJ4AQw0SUR3WG5EAA4pddIgtFGIAYA0CAAfs8AIAzayPJUBvPUAADkcQBIWACp4A7dmFUAhHMFMA61UDQxABE6AA0ywAB4K91AMABCyR8dg7kAEAAEDZPrwMUcAABYuQCK7QA7cAcATADdy3QA4ArwANiwANSFAAgzqNpxggA3EA0EevDduxXQ0AQCAJPsACto0AxstwATeARW0A/wANsiAL0PAA3WiABDzwDZ0A0AKTzQI+EL4AILDURifd3SEARA8gALTNAuwAkN8vMAEemg4Av9AFQ9AFZ/AACzywDVbQwy8AwA4sAAAZAAwAARAIWR3d8p0AMplgDWAALgAAwAL4PdnOIAwAy0AEII4ANMAAnwmu4AxuAkAA8NznU9gT/iYAslMNpAAEJoAAAT6Q4Rue3zgAnt8aDgAzLAAAKa7O89LYLS4AIlGdCdUQCAEAIAMmsA4Z4AMANQ4AUM7jPpAAAetgApv83C4AdAXsPOTAUuQAV6AKpPCsQLAAA8AgAGb+yZMA3GiBAORaLuQAXI4pi50JV/AA5aqgCk8KAqQAAAKBoArqfD4Ac66+Ev7mmNIA1HI+5+syRHMAIO4rgC7ojF4AEIp92IxddIoA3eiUXumWfukAmJ7pmr7pnB4AEAA7'
    $AutoIt_Logo = _Base64Decode($AutoIt_Logo)
    Local $tSource = DllStructCreate('byte[' & BinaryLen($AutoIt_Logo) & ']')
    DllStructSetData($tSource, 1, $AutoIt_Logo)
    Local $tDecompress
    _WinAPI_LZNTDecompress($tSource, $tDecompress)
    $tSource = 0
    Return Binary(DllStructGetData($tDecompress, 1))
EndFunc   ;==>AutoIt_Logo

Func Merlin()
    Local $Merlin
    $Merlin &= 'R0lGODlhRABHAPcAAP///xgxcRw1fRgtbRw5ghgtaRw1eRw5hsrKyhgxd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wtQYGc8IjDGMMEEGpACalgAwikYgD5G4QkgsIEGpbgBEZMbAPVy2AgWSAeIRVyACczAAnwtgDxKAYQOsOHIeZDxjGes13RYAFdzMYQFJkDlGfghyAyoxB7McGQagKMS+mBAmJkM1HQYQQsI3usMZqCFKyNyacCyWAQbznEEM7hAyWSeQJuvoALNwAIKUNBCC6b85hvAgQ2J2MEO5LFkG0/AAipILXNOAQYLxBaRN1hEOxqgygWseQYNaEBQfZCCFHxIBW8otTwYPYAUGGITIIi1rGP9BplB6da4TkhAAAA7'
    Return Binary(_Base64Decode($Merlin))
EndFunc   ;==>Merlin

Func _WinAPI_LZNTDecompress(ByRef $tInput, ByRef $tOutput, $iBufferSize = 0x800000)
    Local $tBuffer, $Ret
    $tOutput = 0
    $tBuffer = DllStructCreate('byte[' & $iBufferSize & ']')
    If @error Then Return SetError(1, 0, 0)
    $Ret = DllCall('ntdll.dll', 'uint', 'RtlDecompressBuffer', 'ushort', 0x0002, 'ptr', DllStructGetPtr($tBuffer), 'ulong', $iBufferSize, 'ptr', DllStructGetPtr($tInput), 'ulong', DllStructGetSize($tInput), 'ulong*', 0)
    If @error Then Return SetError(2, 0, 0)
    If $Ret[0] Then Return SetError(3, $Ret[0], 0)
    $tOutput = DllStructCreate('byte[' & $Ret[6] & ']')
    If Not _WinAPI_MoveMemory(DllStructGetPtr($tOutput), DllStructGetPtr($tBuffer), $Ret[6]) Then
        $tOutput = 0
        Return SetError(4, 0, 0)
    EndIf
    Return $Ret[6]
EndFunc   ;==>_WinAPI_LZNTDecompress

Func _Base64Decode($input_string)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $input_string, "int", 0, "int", 1, "ptr", 0, "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(1, 0, "")
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $input_string, "int", 0, "int", 1, "ptr", DllStructGetPtr($a), "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($a, 1)
EndFunc   ;==>_Base64Decode

 

1 person likes this

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

@Uez: The original i modified runs with gif's also, but i tried to build a function for easier use and this func fails with gif's.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

You may look at my Resources UDF (sources) where I fixed X64 compatibility many years ago.

Link to my Resources UDF is in my signature ...

 

EDIT: There is also derived ResourcesEx UDF by guinness which is compatible with latest AutoIt

 

Edited by Zedna
1 person likes this

Share this post


Link to post
Share on other sites

Hello again, and my considerable thanks go out to you all!  My family experienced some now-mostly-resolved crises starting around July 1 until today, which is why I haven't replied earlier.

Forgive me, but these final few replies have left me a trifle uncertain as to what to do next. @Zedna, I'm afraid I don't know if I should be using "resources" in the GUI app I'm developing, but I like the idea of them because they're essentially the Windows equivalent of Macintosh resources (which I very much loved when I was working on Macs). But perhaps using them at this point is premature, unless the ResourcesEX UDF you've kindly pointed me to works better than what AutoBert and UEZ have posted above.  Your advice?

As for @AutoBert and @UEZ, one set of your posted code appears to supersede the other. I don't plan to use GIFs for my control images, so it seems that I should borrow UEZ's code snippet. Or am I confused?

At any rate, thank you all for your helpful replies!

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Okay, this is what I've put together from AutoBert's & UEZ's code snippets.  Please advise if I've gotten something wrong...

;
;   By UEZ, AutoBert, Prog@ndy, and Zedna
;
Func _Set_Control_From_Binary( $arg_ControlID, $arg_BinaryImage )

    Local $Lf_BitmapHdl, $Lf_HbitmapHdl

    If @OSBuild < 6000 Then
        $Lf_BitmapHdl = _GDIPlus_BitmapCreateFromMemory( $arg_BinaryImage )
        $Lf_HbitmapHdl = _ConvertBitmapToHbitmap( $Lf_BitmapHdl )
        _GDIPlus_BitmapDispose( $Lf_BitmapHdl )
    Else
        $Lf_HbitmapHdl = _GDIPlus_BitmapCreateFromMemory( $arg_BinaryImage, True )
    EndIf

    _WinAPI_DeleteObject( GUICtrlSendMsg( $arg_ControlID, $STM_SETIMAGE, $IMAGE_BITMAP, $Lf_HbitmapHdl ) )

    SetError( 0, 0 )
    Return 0
EndFunc   ;==> _Set_Control_From_Binary
;
;   =   =   =
;
Func _ConvertBitmapToHbitmap($hBitmap)
    Local $iButtonColor = _WinAPI_GetSysColor($COLOR_BTNFACE)
    $iButtonColor = 0x10000 * BitAND($iButtonColor, 0xFF) + BitAND($iButtonColor, 0x00FF00) + BitShift($iButtonColor, 16)
    Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap), $iHeight = _GDIPlus_ImageGetHeight($hBitmap)
    Local $hBitmap_New = _GDIPlus_BitmapCreateFromMemory($iWidth, $iHeight)
    Local $hCtx_new = _GDIPlus_ImageGetGraphicsContext($hBitmap_New)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $iButtonColor)
    _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   ;==>_ConvertBitmapToHbitmap

 

Edited by Mbee

Share this post


Link to post
Share on other sites

Now that the button images from memory are working correctly in 64-bits, I'm suddenly having a problem with fonts from memory.  The following code fragment works fine in 32-bit, but not in 64-bit...

Func _SetupFont( $arg_FontBin, ByRef $arg_FontHdl, ByRef $arg_FontFamilyHdl, _
                 $arg_FontName, $arg_FontSize, $arg_Attrib, $arg_GUIWinHdl=0 )

    Local $Lf_FontStruct, $Lf_InstalledFontsHdl

    $Lf_FontStruct = DllStructCreate( 'byte[' & BinaryLen($arg_FontBin) & ']' )
    DllStructSetData( $Lf_FontStruct, 1, $arg_FontBin )
    $Lf_InstalledFontsHdl = _WinAPI_AddFontMemResourceEx( DllStructGetPtr($Lf_FontStruct), DllStructGetSize($Lf_FontStruct) )

EndFunc

When this is run in 64-bit mode, the return value from _WinAPI_AddFontMemResourceEx() is zero, indicating a failure somewhere. (Note that _GDIPlus_Startup() has already been called prior to this function).

Does the FontStruct need to be different in 64-bit mode? What else could I be doing wrong?

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now