Jump to content

Recommended Posts

Posted

I am having a problem trying to embed a small bitmap into an exe file.

Here, I think, are the relevant code fragments

image.png.ac6065d9cee13b27fcae422d5f7eeb73.png

When I run the script the bitmap shows up exactly as intended.

After compiling-

  • Using  _Resource_SetToCtrlID  the picture doesn't show up at all

  • I switched to  _Resource_GetAsBitmap then _Resource_SetBitmapToCtrlID, the bitmap shows up but is not "transparent"

I've been struggling with this for hours, would very much appreciate someone telling me what I'm doing wrong.

  • Solution
Posted

Please use tags when you post code as described in the link.

Maybe this :

#AutoIt3Wrapper_Res_File_Add=Check.bmp, RT_BITMAP, BMP_1

#include <WinAPISys.au3>
#include <WinAPIRes.au3>
#include <StaticConstants.au3>
#include <GUIConstants.au3>

GUICreate("Test")
Local $idPic = GUICtrlCreatePic("", 10, 10, 50, 50, -1, $WS_EX_TRANSPARENT)
Local $hInstance = _WinAPI_GetModuleHandle(0)
Local $hBitmap = _WinAPI_LoadImage($hInstance, "BMP_1", $IMAGE_BITMAP, 0, 0, 0)
If Not $hBitmap Then Exit ConsoleWrite("ERROR" & @CRLF)
GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

 

Posted
On 4/16/2022 at 1:37 PM, Nine said:

Please use tags when you post code as described in the link.

Maybe this :

#AutoIt3Wrapper_Res_File_Add=Check.bmp, RT_BITMAP, BMP_1

#include <WinAPISys.au3>
#include <WinAPIRes.au3>
#include <StaticConstants.au3>
#include <GUIConstants.au3>

GUICreate("Test")
Local $idPic = GUICtrlCreatePic("", 10, 10, 50, 50, -1, $WS_EX_TRANSPARENT)
Local $hInstance = _WinAPI_GetModuleHandle(0)
Local $hBitmap = _WinAPI_LoadImage($hInstance, "BMP_1", $IMAGE_BITMAP, 0, 0, 0)
If Not $hBitmap Then Exit ConsoleWrite("ERROR" & @CRLF)
GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

 

That works perfectly. Thanks very, very much.

Is that method documented somewhere that I should have been able to find?  I had searched and searched trying to find something that would work.

I apologize for not using tags in the code I  posted. I won't make that mistake again.

Posted
36 minutes ago, oldtimer said:

Is that method documented somewhere that I should have been able to find?  I had searched and searched trying to find something that would work.

I do not remember all the codes that I have created over time.  With well over 1500 scripts, I use my search tool (see signature) to find what I want inside my scripts directory tree.  As for where to find the documentation, MSDN is the best place to get the exact information you seek for.

Glad I gave you a solution for your problem.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...