Jump to content

Resources UDF


Zedna
 Share

Recommended Posts

Quick question,

When installing Resource hacker and AutoIT3Wrapper, where should i place them so they work correctly?

This is a great UDF and once i've gotten the above issue solved i'll be sure to use it :)

AutoIT3Wrapper is part of Scite4AutoIt3 package. It installs into "c:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\" directory by default.

On my computer I put ResHacker.exe into AutoIt3Wrapper directory and also into some "Windows search path" directory (or in some dir listed in PATH env) for example C:\Windows\

Link to comment
Share on other sites

An other function to load the image from resource to use it with GDIplus, I think with transparency :)

CODE
;===============================================================================

;

; Function Name: _ResourceGetImageToGDIPImage(

; Description:: Loads the Image into GDIplus-Image, Transparency should be used :(

; Parameter(s): ResourceName, ResourceType, Optional Dll-Filename to Load from :D

; Requirement(s): Resources.au3 with Dll extension

; Return Value(s): GDIP-Image Handle

; Author(s): Prog@ndy, from _ResourceSetImageToCtrl()

;

; Remarks: Needs _GDIplus_StartUP() before call

;

;===============================================================================

;

Func _ResourceGetImageToGDIPImage($ResName, $ResType = 10,$DLL=-1); $RT_RCDATA = 10

Local $ResData, $nSize, $hData, $pData, $pStream, $pBitmap, $hBitmap

$ResData = _ResourceGet($ResName, $ResType,0,$DLL)

If @error Then Return SetError(1, 0, 0)

$nSize = @extended

; thanks ProgAndy

$hData = _MemGlobalAlloc($nSize,2)

$pData = _MemGlobalLock($hData)

_MemMoveMemory($ResData,$pData,$nSize)

_MemGlobalUnlock($hData)

$pStream = DllCall( "ole32.dll","int","CreateStreamOnHGlobal", "int",$hData, "long",1, "Int*",0)

$pStream = $pStream[3]

$pBitmap = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromStream", "ptr",$pStream, "int*",0)

$pBitmap = $pBitmap[2]

_WinAPI_DeleteObject($pStream)

_MemGlobalFree($hData)

Return $pBitmap

EndFunc

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

  • 5 weeks later...

It works with $SND_RESOURCE, too :

Global Const $SND_RESOURCE = 0x00040004
; ( REsource saved as WAVE Resource, name = WAV1 )
_ResourcePlaySound("WAV1",0,@ScriptDir&"\Resource.dll")

; thanks Larry
; MSDN: http://msdn2.microsoft.com/en-us/library/ms712879.aspx
; default flag is $SND_SYNC = 0
Func _ResourcePlaySound($ResName, $Flag = 0,$DLL=-1)
    If $DLL == -1 Then
        $hInstance = 0
    Else
        $hInstance = DllCall("kernel32.dll","int","LoadLibrary","str",$DLL)
    EndIf
    $hInstance = $hInstance[0]
    Local $ret = DllCall("winmm.dll", "int", "PlaySound", "str", $ResName, "hwnd", $hInstance, "int", BitOr($SND_RESOURCE,$Flag))
    If @error Then Return SetError(1, 0, 0)
    Return $ret[0]
    If $DLL <> -1 Then DllCall("Kernel32.dll","int","FreeLibrary","str",$hInstance)
EndFunc

Or, the other way: http://msdn.microsoft.com/en-us/library/ms712876(VS.85).aspx

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Updated first post.

2008-06-25
- big thanks to ProgAndy for ideas,improvements!
- added _ResourceGetAsImage(), _ResourceGetAsBitmap()
- added optional $DLL parameter to all functions - for loading resources from external EXE,DLL files
- fixed previous limitation in _ResourceSaveToFile() - now supports also RT_BITMAP type
- new examples in resource_test.au3
Link to comment
Share on other sites

Hi everybody,

i need some help.. I´ try to view an animated Gif in an compiled script. I tried this Code.

CODE
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_UseUpx=n

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, test.gif, rcdata, TEST, 0

;#AutoIt3Wrapper_Run_After=upx.exe --best "%out%

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include "resources.au3"

#include <IE.au3>

Local $gui, $sFile, $pic1, $oIE, $GUIActiveX

$gui = GUICreate("Test", 425, 188, 235, 218)

$pic1 = GUICtrlCreatePic("",0,0,48,48)

;Local $sFile = "c:\temp\test.gif"

$oIE = ObjCreate("Shell.Explorer.2")

$GUIActiveX = GUICtrlCreateObj($oIE, 344, 8, 48, 48)

$oIE.navigate("about:blank")

While _IEPropertyGet($oIE, "busy")

Sleep(100)

WEnd

$oIE.document.body.background = $sFile

$oIE.document.body.scroll = "no"

GUISetState(@SW_SHOW)

msgbox (0,"Test","before")

_ResourceSetImageToCtrl($pic1, "TEST") ;<-- This works, but only as static gif

msgbox (0,"Test","after")

_ResourceSetImageToCtrl($oIE.document.body.background, "TEST") ; This doesn´t work <- Why ?? What' wrong?

While 1

If GUIGetMsg() = -3 Then Exit

WEnd

What is wrong ?? I searched for a solution, perhaps i´m blind.. Hopefully you folks can help.

Link to comment
Share on other sites

Hi everybody,

i need some help.. I´ try to view an animated Gif in an compiled script. I tried this Code.

CODE
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_UseUpx=n

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, test.gif, rcdata, TEST, 0

;#AutoIt3Wrapper_Run_After=upx.exe --best "%out%

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include "resources.au3"

#include <IE.au3>

Local $gui, $sFile, $pic1, $oIE, $GUIActiveX

$gui = GUICreate("Test", 425, 188, 235, 218)

$pic1 = GUICtrlCreatePic("",0,0,48,48)

;Local $sFile = "c:\temp\test.gif"

$oIE = ObjCreate("Shell.Explorer.2")

$GUIActiveX = GUICtrlCreateObj($oIE, 344, 8, 48, 48)

$oIE.navigate("about:blank")

While _IEPropertyGet($oIE, "busy")

Sleep(100)

WEnd

$oIE.document.body.background = $sFile

$oIE.document.body.scroll = "no"

GUISetState(@SW_SHOW)

msgbox (0,"Test","before")

_ResourceSetImageToCtrl($pic1, "TEST") ;<-- This works, but only as static gif

msgbox (0,"Test","after")

_ResourceSetImageToCtrl($oIE.document.body.background, "TEST") ; This doesn´t work <- Why ?? What' wrong?

While 1

If GUIGetMsg() = -3 Then Exit

WEnd

What is wrong ?? I searched for a solution, perhaps i´m blind.. Hopefully you folks can help.

You can't use it this way.

$oIE.document.body.background expects path to file on disk 

Link to comment
Share on other sites

Hi Zedna,

thx for reply. How can i solve this ?? As i wrote before I want to display an embedded animated gif.. Can you give an example ?

I don't know how to do it directly without temporary file.

So use FileInstall() or my _ResourceSaveToFile().

You will have only one EXE with embeded GIF and at runtime it will create temporary file on disk and will use it.

Finally you can delete this temporary file.

Link to comment
Share on other sites

ok, i thought i would be possible with your UDF. i will use FileInstall.

Perhaps this could be a nice addon for further version of your udf.

See my first post!

I tested my resource_test_ie.au3 - example script for using HTML resources with embeded IE COM object (without using UDF)

It works fine also with animated GIF images but only with

$oIE.navigate("res://" & @AutoItExe & "/test_gif_1")

This is not working:

$oIE.document.body.background = "res://" & @AutoItExe & "/test_gif_1"
Link to comment
Share on other sites

For some reason this doesn't work for me. Its being really retarded and nothing is happening. I'm using

#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, login.jpg, rcdata, LOGIN, 0oÝ÷ Ø  Ý":`ȧ¶¢W^®íë®*mjwl¢+zÁÚrG«{ÒÊ!j÷­+ºÚ"µÍÌÍÓÙÚ[ÔXÈHÕRPÝÜX]TXÊ    ][ÝÉ][ÝËLL
BÔÛÝÙTÙ][XYÙUÐÝ
    ÌÍÓÙÚ[ÔXË    ][ÝÓÑÒS][ÝÊ

And yea. Nothing shows up on the GUI i made.

Link to comment
Share on other sites

For some reason this doesn't work for me. Its being really retarded and nothing is happening. I'm using

And yea. Nothing shows up on the GUI i made.

Try to compile/run my original examples first. Also post whole related code.

Are you using #AutoIt3Wrapper_useupx=n?

Also check by reshacker tool output compiled EXE file if your LOGIN JPEG resource is inside EXE.

EDIT:

Also try to put ResHacker.exe into AutoIt3Wrapper directory or into some directory which is in "Windows search path".

Edited by Zedna
Link to comment
Share on other sites

Hey there.

I'm trying to use this to embed an image into a command button. I think I have an understanding of how it works with exe/bmp files for their own controls, but how do I set the loaded resources to display on a command button? When I compile it, I end up with a giant button (as I should) but no image associated with it.

Here's the sample code I have that I tried based on your sample. This is just a generic test sample to try and see how it all works.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_UseUpx=n

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, image1.bmp, bitmap, TEST_BMP_1, 0

#AutoIt3Wrapper_Run_After=upx.exe --best --compress-resources|0 "%out%"

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include "resources.au3"

#include <GUIConstants.au3>

$gui = GUICreate("Data from resources example",820,400)

$pic1 = GUICtrlCreatebutton("",0,0,400,300,$BS_BITMAP)

GUISetState(@SW_SHOW)

; set BMP image to picture control from resource bitmap

_ResourceSetImageToCtrl($pic1, "TEST_BMP_1", $BS_BITMAP)

while 1

WEnd

Any help is appreciated.

Link to comment
Share on other sites

Hey there.

I'm trying to use this to embed an image into a command button. I think I have an understanding of how it works with exe/bmp files for their own controls, but how do I set the loaded resources to display on a command button? When I compile it, I end up with a giant button (as I should) but no image associated with it.

Here's the sample code I have that I tried based on your sample. This is just a generic test sample to try and see how it all works.

Any help is appreciated.

Read carefully whole my first post!!!

There is mentioned it works only with static controls (no buttons).

This is limitation of Windows STM_SETIMAGE message used for setting image to control.

Link to comment
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
 Share

  • Recently Browsing   0 members

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