Jump to content

Recommended Posts

Posted (edited)

I unzip resource_au3.zip in the same folder with resource_test.au3. Build it through AutoIt3Wrapper.exe. Start. Hear "tada!" and see big window with only one small picture of window's logo. Close it. Go to C:\Dir1\SubDir2 and found only binary_data2.bmp with 0kb size only. Where is binary_data1.dat & why size is 0?

Edited by VitAl2013
Posted

I unzip resource_au3.zip in the same folder with resource_test.au3. Build it through AutoIt3Wrapper.exe. Start. Hear "tada!" and see big window with only one small picture of window's logo. Close it. Go to C:\Dir1\SubDir2 and found only binary_data2.bmp with 0kb size only. Where is binary_data1.dat & why size is 0?

Read carefully WHOLE my first topic!!

You must comile it from full Scite4Autoit3 by F7.

For running my examples you must unpack also data files from second ZIP file.

You can use ResHacker to check if resources are successfuly added in compiled EXE file.

If you are not so skilled to understand these basics information then you may use simpler FileInstall().

Posted

Hi Zedna, currently I'm using the UDF to load an external dll file. Do you have any working example on how I can load animated cursor from an external dll?

Right now, I have this example that load from file :

#include <GuiConstants.au3>
#include <WindowsConstants.au3>

$Gui = GuiCreate("Test", 300, 200,750)
GUISetState()

GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR')

$Cur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str", @ScriptDir&"\mycursor.ani")  ; this will load from file

While 1
    $Msg = GUIGetMsg(1)
    Select
    Case $Msg[0] = $GUI_EVENT_CLOSE
    Exit
    EndSelect
WEnd

Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam)
    If $hWnd = $Gui Then
    DllCall("user32.dll", "int", "SetCursor", "int", $Cur[0])
    Return 0
    EndIf
EndFunc

Thanks,

slayerz

AUTOIT[sup] I'm lovin' it![/sup]

  • 1 month later...
Posted

Ok, I got it to work... but the included "image3.jpg" will not display in any of the example scripts, nor will any other *.jpg I replace it with. Does this not work correctly with JPG's?

Posted

All I have to say is : AMAZING WORK. :mellow:

I've been looking for something like this forever. I wanted to build a board game, but didn't want to require people to download the images for use. Once again, another epic script from another amazing user! :P

AutoIt Stuff:

 

UDFs: {Grow}

Posted

@slayerz

Look at my first post there is link to topic about animated GIFS.

@ultimist

Read carefully whole first post of this topic. All information are stated there.

If it's not enough for you then read also all posts in this topic,

your question (or similar ones) was asked many times already and I answered many times too.

@cembry90

Thanks for compliments :-)

  • 2 weeks later...
Posted

I was able to load a PNG file into the GUI. But while my PNG file has dimension of 32x32, it's displayed on the GUI as 48x48 :mellow: How can I fix this?

Posted Image Posted Image

#AutoIt3Wrapper_Res_File_Add=setup.png, RT_RCDATA, SETUP_ICON_1

#include "Resources.au3"
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#Include <WinAPI.au3>

$hGUI = GUICreate("Show PNG", 250, 250)

_GDIPlus_StartUp()
$hImage   = _ResourceGetAsImage("SETUP_ICON_1")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
GUISetState()

do
until GUIGetMsg() = $GUI_EVENT_CLOSE

_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ShutDown()

Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
    _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE)
    Return $GUI_RUNDEFMSG
EndFunc
Posted (edited)

I was able to load a PNG file into the GUI. But while my PNG file has dimension of 32x32, it's displayed on the GUI as 48x48 :mellow: How can I fix this?

Try to use GUICtrlCreatePic() and _ResourceSetImageToCtrl() as in my examples,

you don't need hooking of WM_PAINT in this case.

Edited by Zedna
Posted

Try to use GUICtrlCreatePic() and _ResourceSetImageToCtrl() as in my examples,

you don't need hooking of WM_PAINT in this case.

OK I tried and it worked fine :mellow:

Posted (edited)

Hi Zedna,

i'm trying to use it to embeed images to buttons, since you stated that now it's supported, but i can't get it to work:

#AutoIt3Wrapper_Res_File_Add=cuori_b.bmp, rt_rcdata, cuori_b.bmp
...
$fiori = GUICtrlCreateButton("",103,8,44,44, $BS_BITMAP )
$pic1 = GUICtrlSetImage($fiori,"fiori.bmp",0,0)
_ResourceSetImageToCtrl($pic1, "fiori.bmp")

Can you please give me some hint to manage it?

Thanks,

Marco

Edited by marko001
Posted (edited)

Hi Zedna,

i'm trying to use it to embeed images to buttons, since you stated that now it's supported, but i can't get it to work:

Can you please give me some hint to manage it?

Thanks,

Marco

Try this
#AutoIt3Wrapper_Res_File_Add=cuori_b.bmp, rt_bitmap, cuori_b
...
$fiori = GUICtrlCreateButton("",103,8,44,44, $BS_BITMAP )
_ResourceSetImageToCtrl($fiori, "cuori_b", $RT_BITMAP)

EDIT: Don't forget to download/use latest Resources UDF ;-)

Edited by Zedna
  • 2 weeks later...
Posted

Hi Zedna,

How to get the data from Message Table?

MsgBox(4096, "Read BSOD", _ResourceGetAsString(1073741951, $RT_MESSAGETABLE, 0, $@SystemDir & "\ntoskrnl.exe"))
Does not work...

You have got syntax mistake: $@SystemDir should be @SystemDir

But this your way it's completely wrong.

There are two possible ways to get "MessageTable" resources:

1)

use _ResourceGet() to get pointer to resource data and

apply DllStructCreate (typecast) to it with these structures

MESSAGE_RESOURCE_DATA

MESSAGE_RESOURCE_BLOCK

MESSAGE_RESOURCE_ENTRY

and loop through their entries

2)

use LoadLibrary and FormatMessage API functions

this is much simpler and you don't need my Resources UDF

not tested:

Const $FORMAT_MESSAGE_FROM_HMODULE = 0x0800
Const $FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x0100

$tBuffer = DllStructCreate("wchar[1]") ; I'm not sure here about the size/type of buffer, buffer will be auto alocated
$pBuffer = DllStructGetPtr($tBuffer)
$iFlags = BitOr($FORMAT_MESSAGE_FROM_HMODULE, $FORMAT_MESSAGE_ALLOCATE_BUFFER)
$MessageID = 1 ; Id of message you want to get, replace by your desired number
$iLanguageID = 0 ; neutral lang

$hModule = _WinAPI_LoadLibrary(@SystemDir & "\ntoskrnl.exe") ; path to your EXE/DLL module
_WinAPI_FormatMessage($iFlags, $hModule, $iMessageID, $iLanguageID, $pBuffer, 0, 0)

MsgBox(4096, "Read BSOD", DllStructGetData($tBuffer,1))
Posted (edited)

#AutoIt3Wrapper_Res_File_Add=C:\AutoIT\mainprog.ico, RT_ICON, MAIN_PROGRAM_ICON_1

$GUI_ImageList = _GUIImageList_Create(16, 16, 5)
_GUIImageList_AddIcon($GUI_ImageList, "C:\AutoIT\mainprog.ico", 0, True)
$GUI_Toolbar = _GUICtrlToolbar_Create($GUI, BitOR($WS_CLIPSIBLINGS,$TBSTYLE_FLAT))
_GUICtrlToolbar_SetImageList($GUI_Toolbar, $GUI_ImageList)
_GUICtrlToolbar_AddButton($GUI_Toolbar, 0, 0)

The _AddIcon function requires a path so I tried "res://" & @AutoItExe & "/MAIN_PROGRAM_ICON_1" but it didn't show up. The _AddButton function requires an index so I can't find a way to get the UDF to work with toolbar. Are there any solution for me :blink: ?

Edited by Who
Posted (edited)

#AutoIt3Wrapper_Res_File_Add=C:\AutoIT\mainprog.ico, RT_ICON, MAIN_PROGRAM_ICON_1

$GUI_ImageList = _GUIImageList_Create(16, 16, 5)
_GUIImageList_AddIcon($GUI_ImageList, "C:\AutoIT\mainprog.ico", 0, True)
$GUI_Toolbar = _GUICtrlToolbar_Create($GUI, BitOR($WS_CLIPSIBLINGS,$TBSTYLE_FLAT))
_GUICtrlToolbar_SetImageList($GUI_Toolbar, $GUI_ImageList)
_GUICtrlToolbar_AddButton($GUI_Toolbar, 0, 0)

The _AddIcon function requires a path so I tried "res://" & @AutoItExe & "/MAIN_PROGRAM_ICON_1" but it didn't show up. The _AddButton function requires an index so I can't find a way to get the UDF to work with toolbar. Are there any solution for me :blink: ?

This should work fine, no need to use my UDF for this

#AutoIt3Wrapper_Res_Icon_Add=C:\AutoIT\mainprog.ico

; replace 3 by your desired icon index
; remember there are some standard Autoit's icons in compiled EXE
; so your first added icon is not first in EXE
_GUIImageList_AddIcon($GUI_ImageList, @AutoItExe, 3, True)
Edited by Zedna

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...