Jump to content
Sign in to follow this  
johnmcloud

Load Ico-Image from DLL

Recommended Posts

johnmcloud

Hi guys,

I'd like to create a DLL with the resource of the script. So i'd like to include:

1) Icon

2) Image

3) Exe ( if it is possible )

I Have created the resource DLL with I don't know if it is the best solution for create a resource DLL, if you have other suggestion please tell me ( i'l like to add also the version number to the DLL, the file description etc. but seems i can't with that UDF )

I have add tree icon:

  • ICON_1
  • ICON_2
  • ICON_3
And one image:
  • IMAGE
The test script:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>

Example()

Func Example()
 GUICreate("", 400, 380, -1, -1)
 GUICtrlCreateButton("my picture button", 10, 20, 40, 40, $BS_ICON)
 GUICtrlSetImage(-1, "DLLTest.dll", "ICON_1")
 GUICtrlCreateButton("my picture button", 50, 20, 40, 40, $BS_ICON)
 GUICtrlSetImage(-1, "DLLTest.dll", "-2")
 GUICtrlCreateButton("my picture button", 90, 20, 40, 40, $BS_ICON)
 GUICtrlSetImage(-1, "DLLTest.dll", "-3")
 GUICtrlCreatePic("", 0, 20, 400, 380)
 GUICtrlSetState(-1, $GUI_DISABLE)
 GUICtrlSetImageFromDLL(-1, "DLLTest.dll", "-4")
 GUISetState()

 While 1
  $msg = GUIGetMsg()
  If $msg = $GUI_EVENT_CLOSE Then ExitLoop
 WEnd
EndFunc   ;==>Example

Func GUICtrlSetImageFromDLL($controlID, $filename, $imageIndex)
 Local Const $STM_SETIMAGE = 0x0172
 $hLib = _WinAPI_LoadLibrary($filename)
 $hBmp = _WinAPI_LoadImage($hLib, $imageIndex, $IMAGE_BITMAP, 0, 0, $LR_DEFAULTCOLOR)
 GUICtrlSendMsg($controlID, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp)
 _WinAPI_FreeLibrary($hLib)
 _WinAPI_DeleteObject($hBmp)
EndFunc   ;==>GUICtrlSetImageFromDLL

I can see the icon, but i have a question:

Why i cant' put the name but i need to use negative values?

The IMAGE not work, don't know how i need to put in :D

You can find the example DLL in the attachment. Thanks for any help

DLLTest.rar

Edited by johnmcloud

Share this post


Link to post
Share on other sites
UEZ

I assume that you have created the image resource wrongly. Probably you have to use bitmap instead of a jpg.

Another possibility is to use binary strings and load them from memory -> check out File to Base64 String Code Generator.

Br,

UEZ

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

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
Sign in to follow this  

×