#include <GDIPlus.au3>
GUICreate("从dll中载入位图", 440,200)
$pic1 = GUICtrlCreatePic("",10,10,410,70)
$pic2 = GUICtrlCreatePic("",10,100,410,70)
GUISetState(@SW_SHOW)
Func _ResourceGet($ResName, $DLL = -1)
If $DLL = -1 Then
$hInstance = _WinAPI_GetModuleHandle("")
Else
$hInstance = _WinAPI_LoadLibrary($DLL)
EndIf
If $hInstance = 0 Then Return SetError(1, 0, 0)
$hBitmap = _WinAPI_LoadImage($hInstance, $ResName, 0, 0, 0, 0)
If @error Then Return SetError(2, 0, 0)
Return $hBitmap ; returns handle to Bitmap
EndFunc
Func _SetBitmapToCtrl($CtrlId, $hBitmap)
Local $hWnd = GUICtrlGetHandle($CtrlId)
If $hWnd = 0 Then Return SetError(1, 0, 0)
Local $oldStyle = _WinAPI_GetWindowLong($hWnd, -16)
If @error Then Return SetError(2, 0, 0)
_WinAPI_SetWindowLong($hWnd, -16,BitOR($oldStyle, 0xE))
If @error Then Return SetError(3, 0, 0)
Local $oldBmp = _SendMessage($hWnd, 0x0172, 0, $hBitmap)
If @error Then Return SetError(4, 0, 0)
If $oldBmp <> 0 Then _WinAPI_DeleteObject($oldBmp)
Return 1
EndFunc
Func _ResourceSetImageToCtrl($CtrlId, $ResName, $DLL = -1)
$ResData = _ResourceGet($ResName, $DLL)
_SetBitmapToCtrl($CtrlId, $ResData)
If @error Then Return SetError(2, 0, 0)
Return 1
EndFunc
_ResourceSetImageToCtrl($pic1, "#131", @SystemDir & "\shell32.dll")
_ResourceSetImageToCtrl($pic2, "#130", @SystemDir & "\shell32.dll")
While 1
If GUIGetMsg() = -3 Then Exit
WEnd 学习了,我顶顶顶。 看不明白。呵。以后会用到。先马克 回复 16# wan6376 win7看不到 哈哈!真管用!认真领悟中。。。。 我是来学习的,,感谢P版给出答案。。 学习了,谢谢各位大X们;
页:
1
[2]