zz999 发表于 2010-7-20 22:06:51

请教如何用resources这个UDF将包里的图片内置进程序

我把文件打包,我是下的别人的一个程序进行测试下resources这个UDF的

试了好久没成功,现将程序打包求大家帮忙!

netegg 发表于 2010-7-21 06:42:50

官网不是有这个函数库的示例吗

republican 发表于 2010-7-21 08:13:01

resource的资源需要编译后才能显现出效果。

zz999 发表于 2010-7-21 11:45:00

回复 2# netegg


可我怎么修改就是没效果,只能来请各位帮帮忙 !

netegg 发表于 2010-7-21 11:46:38

我也没仔细研究过

zz999 发表于 2010-7-21 14:52:28

来人帮帮忙捏·~

zz999 发表于 2010-7-21 19:27:43

没人帮我呀!

republican 发表于 2010-7-22 08:04:34

不明白你怎么这么用...
新版AU3不需要ResHacker.

官方代码:#AutoIt3Wrapper_Res_File_Add=test_1.txt, rt_rcdata, TEST_TXT_1
#AutoIt3Wrapper_Res_File_Add=image1.bmp, rt_bitmap, TEST_BMP_1
#AutoIt3Wrapper_Res_File_Add=image2.bmp, rt_bitmap, TEST_BMP_2
#AutoIt3Wrapper_Res_File_Add=image3.jpg, rt_rcdata, TEST_JPG_3
;~ #AutoIt3Wrapper_Res_File_Add=binary1.dat, rt_rcdata, TEST_BIN_1
;~ #AutoIt3Wrapper_Res_File_Add=C:\WINDOWS\Media\tada.wav, sound, TEST_WAV_1

#include "resources.au3"

$gui = GUICreate("Data from resources example",820,400)
$pic1 = GUICtrlCreatePic("",0,0,400,300)
$pic2 = GUICtrlCreatePic("",400,0,400,150)
$pic3 = GUICtrlCreatePic("",400,150,400,150)
$pic4 = GUICtrlCreatePic("",600,320,400,100)
$label1 = GUICtrlCreateLabel("",20,320,380,100)
$label2 = GUICtrlCreateLabel("",400,320,200,100)
GUISetState(@SW_SHOW)

; get string from resource
$string = _ResourceGetAsString("TEST_TXT_1")
GUICtrlSetData($label1, $string)

; set BMP image to picture control from resourcebitmap
_ResourceSetImageToCtrl($pic1, "TEST_BMP_1", $RT_BITMAP)

; get bitmap from resource (as pointer)
$hBmp = _ResourceGet("TEST_BMP_2", $RT_BITMAP)
; and use it for whatever you like
_SetBitmapToCtrl($pic2, $hBmp)

; set JPG image to picture control from resource
_ResourceSetImageToCtrl($pic3, "TEST_JPG_3")

; set image to picture control from external DLL resource
_ResourceSetImageToCtrl($pic4, "#14355", $RT_BITMAP, @SystemDir & "\shell32.dll")

; get/use picture from resources as hImage type
$size1 = _ResourceGetImageSize("TEST_BMP_1", $RT_BITMAP)
$size2 = _ResourceGetImageSize("TEST_JPG_3")
GUICtrlSetData($label2, $size1 & @CRLF & $size2)

; save binary data or another type (image) from resource to file and get its size in bytes
$size1 = _ResourceSaveToFile(@ScriptDir & "\binary_data1.dat", "TEST_BIN_1")
$size2 = _ResourceSaveToFile(@ScriptDir & "\binary_data2.bmp", "TEST_BMP_1", $RT_BITMAP)

; save binary data from resource to file (create not existing directory)
_ResourceSaveToFile("C:\Dir1\SubDir2\binary_data1.dat", "TEST_BIN_1", $RT_RCDATA, 0, 1)
_ResourceSaveToFile("C:\Dir1\SubDir2\binary_data2.bmp", "TEST_BMP_1", $RT_BITMAP, 0, 1)

; play WAV from resource (sync/async)
_ResourcePlaySound("TEST_WAV_1")
_ResourcePlaySound("TEST_WAV_1", $SND_ASYNC)

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd

Func _ResourceGetImageSize($ResName, $ResType = 10) ; $RT_RCDATA = 10
        ; get/use picture from resources as hImage type
        $hImage = _ResourceGetAsImage($ResName, $ResType)
        _GDIPlus_Startup()
        $width =_GDIPlus_ImageGetWidth ($hImage)
        $height = _GDIPlus_ImageGetHeight($hImage)
        _GDIPlus_Shutdown()
       
        Return "Size of " & $ResName & " is: " & $width & "x" & $height
EndFunc

zz999 发表于 2010-7-22 10:13:08

回复 8# republican

请教你的这个不也是 Resource吗?
那我想把图片内置    用在循环里   怎么实现?

republican 发表于 2010-7-22 11:33:58

回复 9# zz999

你的使用了ResHacker,不是Resource。

官方示例已经有很明确的用法了,LZ能不能把示例先研究一下?


zz999 发表于 2010-7-22 13:27:11

回复 10# republican

我知道,但我测试了好几次   就是不显示!
所以来求具体修改方法!

republican 发表于 2010-7-22 16:33:58

回复 11# zz999

resource_test.au3集合了全部用法。

我在三楼说了,要编译后才有效果的。

78391493 发表于 2010-7-22 16:35:59

新版AU3不支持这个UDF,此问题无解。这个早在08年底就过时了。

afan 发表于 2010-7-22 19:01:29

这个我做界面时用过,刚刚测试了下,新版au3同样编译正常
有空看看~

republican 发表于 2010-7-22 20:28:19

回复 13# 78391493

3.3.6.1 也是可以用的。
编译我附件的resource_test.au3试试。
页: [1] 2
查看完整版本: 请教如何用resources这个UDF将包里的图片内置进程序