;~ By Crossdoor
;~ 从DLL文件中加载图片到图片控件
;~ _SetBitmap(DLL名称, 图片编号, 控件句柄)
;~ 成功返回1
;~ 示例:
;~ $pic = GUICtrlCreatePic("", 0, 0, 640, 480, 0x04000000)
;~ _SetBitmap('Res.dll', '#143', $pic)
Func _SetBitmap($sDll, $sBitmap, $hwnd)
$LoadLibraryA = DllCall("Kernel32.dll", "hwnd", "LoadLibraryA", "str", $sDll)
If @error Then Return SetError(@error, 0, 0)
$LoadBitmap = DllCall("User32.dll", "hwnd", "LoadBitmap", "hwnd", $LoadLibraryA[0], "str", $sBitmap)
If @error Then Return SetError(@error, 0, -1)
DllCall("user32.dll", "lparam", "SendMessage", "hwnd", GUICtrlGetHandle($hwnd), "int", 0x0172, "wparam", 0, "lparam", $LoadBitmap[0])
If @error Then Return SetError(@error, @extended, "")
DllCall("Kernel32.dll", "hwnd", "FreeLibrary", "hwnd", $LoadLibraryA[0])
Return 1
EndFunc