Sign in to follow this  
Followers 0
ValkuR

Picture from DLL

11 posts in this topic

HI @ALL.

How to load a Picture from .DLL? I´ve try this load as Icon from DLL but don´t work.

I hope so, somebody can help me.

thx

Share this post


Link to post
Share on other sites



HI @ALL.

How to load a Picture from .DLL? I´ve try this load as Icon from DLL but don´t work.

I hope so, somebody can help me.

thx

http://www.autoitscript.com/forum/index.ph...st&p=242546

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

oha, thx for fast answer :)

Share this post


Link to post
Share on other sites

oha, thx for fast answer :)

YW, I saw it earlier, so it wasn't hard to find, you can give a big thanks to Larry for that one.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

ok, thx Larry :). i will try this one.

OK. Don´t work for me. Dll as File Attachment

$gui = GUICreate("",500,345)
$pic = GUICtrlCreatePic(".\PIC1_BMP.BMP",500,345,200,200)

GUISetState()

SetBitmapResourceToPicCtrl($gui,$pic,"new.dll",0)

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


Func SetBitmapResourceToPicCtrl($hwnd,$ctrl,$file,$resource)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $LR_CREATEDIBSECTION = 0x2000
    Local Const $LR_COPYDELETEORG = 8

    $hwnd = ControlGetHandle($hwnd,"",$ctrl)
   
    Local $DLLinst = DLLCall("kernel32.dll","hwnd","LoadLibrary","str",$file)
    $DLLinst = $DLLinst[0]

    Local $hBitmap = DLLCall("user32.dll","hwnd","LoadImage","hwnd",$DLLinst,"int",$resource, _
            "int",$IMAGE_BITMAP,"int",0,"int",0,"int",0)
    $hBitmap = $hBitmap[0]
   
    DeleteObject(_SendMessage($hwnd,$STM_SETIMAGE,$IMAGE_BITMAP,$hBitmap,0,"int","int","hwnd"))
   
    DLLCall("kernel32.dll","int","FreeLibrary","hwnd",$DLLinst)
EndFunc

Func _SendMessage($hWnd, $msg, $wParam = 0, $lParam = 0, $r = 0, $t1 = "int", $t2 = "int", $t3 = "long")
    Local $ret = DllCall("user32.dll", $t3, "SendMessage", "hwnd", $hWnd, "int", $msg, $t1, $wParam, $t2, $lParam)
    If @error Then Return SetError(@error, @extended, "")
    If $r >= 0 And $r <= 4 Then Return $ret[$r]
    Return $ret
EndFunc; _SendMessage()
Func DeleteObject($hObj)
    Local $bResult = DllCall('gdi32.dll', 'int', 'DeleteObject', _
            'hwnd', $hObj)
    Return $bResult[0]
EndFunc  ;==>DeleteObject

Edited by ValkuR

Share this post


Link to post
Share on other sites

:) Thx Larry this works :P . is this the only way to load a picture from dll file?

i like the GUICtrlCreateIcon function :D

Share this post


Link to post
Share on other sites

ok, thanks again LARRY.

Share this post


Link to post
Share on other sites

Don't give us that humble crap... you know your sh!t don't stink.


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

larry

is this working with jpg,mp3,wav files to ?

jpam

Share this post


Link to post
Share on other sites

hi

has someone time to expiriment with other data from dll ?

i made a Resource.dll with different data inside

larry has made a very nice udf for bitmap loading from dll

but bitmaps are very large

mybe someone can do the same for jpg's mp3's and other file types !

1 bmp file (works with larry's udf i included it for testing)

2 wave file

3 RC_DATA contains jpg, midi and mp3

jpam

Resource.dll

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

larry's function with resize

$gui = GUICreate("",500,345)

$pic = GUICtrlCreatePic("",0,0,0,0)

GUISetState()

SetBitmapResourceToPicCtrl($gui,$pic,50,50,50,100,".\new.dll","PIC1_BMP","str")

Sleep(1000)

SetBitmapResourceToPicCtrl($gui,$pic,50,50,100,100,".\new.dll","PIC1_BMP","str")

While 1

If GUIGetMsg() = -3 Then Exit

WEnd

Func SetBitmapResourceToPicCtrl($hwnd,$ctrl,$posw,$posh,$picw,$pich,$file,$resource,$type = "int")

Local Const $STM_SETIMAGE = 0x0172

Local Const $IMAGE_BITMAP = 0

Local Const $LR_CREATEDIBSECTION = 0x2000

Local Const $LR_COPYDELETEORG = 8

$hwnd = ControlGetHandle($hwnd,"",$ctrl)

Local $DLLinst = DLLCall("kernel32.dll","hwnd","LoadLibrary",$type,$file)

$DLLinst = $DLLinst[0]

Local $hBitmap = DLLCall("user32.dll","hwnd","LoadImage","hwnd",$DLLinst,"str",$resource, _

"int",$IMAGE_BITMAP,"int",0,"int",0,"int",0)

$hBitmap = $hBitmap[0]

DeleteObject(_SendMessage($hwnd,$STM_SETIMAGE,$IMAGE_BITMAP,$hBitmap,0,"int","int","hwnd"))

DLLCall("kernel32.dll","int","FreeLibrary","hwnd",$DLLinst)

GUICtrlSetPos($ctrl,$posw,$posh,$picw,$pich)

EndFunc

Func _SendMessage($hWnd, $msg, $wParam = 0, $lParam = 0, $r = 0, $t1 = "int", $t2 = "int", $t3 = "long")

Local $ret = DllCall("user32.dll", $t3, "SendMessage", "hwnd", $hWnd, "int", $msg, $t1, $wParam, $t2, $lParam)

If @error Then Return SetError(@error, @extended, "")

If $r >= 0 And $r <= 4 Then Return $ret[$r]

Return $ret

EndFunc; _SendMessage()

Func DeleteObject($hObj)

Local $bResult = DllCall('gdi32.dll', 'int', 'DeleteObject', _

'hwnd', $hObj)

Return $bResult[0]

EndFunc ;==>DeleteObject

Edited by jpam

Share this post


Link to post
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
Sign in to follow this  
Followers 0