abb Posted May 16, 2008 Share Posted May 16, 2008 Hello hello! I've been using AutoIt for many years now but am pretty new to working with DLLs in AutoIt. I've been struggling with outputting a bitmap from a DLL to an image in my GUI. I have the functioning code in Pascal but need to convert it to AutoIt so, two questions: 1) Does anyone know of a tool to convert Pascal to AutoIt? 2) What is the AutoIt pseudo-code for achieving this? So far I've got $dll = DllOpen("mydll.dll") $dllResult = DllCall($dll,"int","LoadBitMap","none","AD0") LoadBitMap is the DLL's function and the bitmap name is AD0. I'm unsure how to procede from here tho Help would be greatly appreciated! Link to comment Share on other sites More sharing options...
zorphnog Posted May 16, 2008 Share Posted May 16, 2008 There is no way that you are sending a string with a datatype of 'none'. Provide the documentation for your dll and maybe we can help you. Link to comment Share on other sites More sharing options...
abb Posted May 16, 2008 Author Share Posted May 16, 2008 There is no way that you are sending a string with a datatype of 'none'. Provide the documentation for your dll and maybe we can help you. Right. I wan't 100% sure what "Type1" should be so I put "none" in there thinking it was probably wrong LoadBitMap returns a pointer so I believe the code should be: $dll = DllOpen("mydll.dll") $dllResult = DllCall($dll,"ptr","LoadBitMap","int","AD0") Please correct me if I am wrong. The Pascal code I'm attempting to convert to AutoIt is: expandcollapse popupprocedure TMainForm.ChangeAdImage(); var h : THandle; b1: TBitmap; // hRes : THandle; {handle to the resource} buf: Array[0..255] of char; sBitMapName:Array[0..3] of char; iNum: integer; begin if m_bUseDefaultImage then begin m_bUseDefaultImage:=false; m_iCurrentAdImage:=0; end; h := LoadLibrary('eximg.dll'); if h >= 32 then begin b1 := TBitmap.Create; StrCopy(sBitMapName,'AD'); StrCat(sBitMapName,PChar(IntToStr(m_iCurrentAdImage))); b1.handle := LoadBitMap(h, sBitMapName); if b1.handle<>0 then begin AdImage.Picture.Bitmap := b1; b1.Free; iNum:=LoadString(h,m_iCurrentAdImage,@buf,sizeof(buf)); if iNum >0 then m_sAdWebSite:=buf else m_sAdWebSite:=CONST_DEFAULT_ADWEB; end; end; m_iCurrentAdImage:=m_iCurrentAdImage+1; if m_iCurrentAdImage >= CONST_NUM_ADS then m_bUseDefaultImage:=true; if h>0 then FreeLibrary(h); end; Hopefully this helps. Thanks! Link to comment Share on other sites More sharing options...
zorphnog Posted May 16, 2008 Share Posted May 16, 2008 Well it should probably be: $dll = DllOpen("mydll.dll") $dllResult = DllCall($dll,"ptr","LoadBitMap","str","AD0") Don't forget that if the dll call executes properly, the result is an array. So the pointer will be returned to $dllResult[0]. Link to comment Share on other sites More sharing options...
Zedna Posted May 16, 2008 Share Posted May 16, 2008 Look here:http://www.autoitscript.com/forum/index.php?showtopic=51103http://www.autoitscript.com/forum/index.ph...st&p=510710 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
abb Posted May 16, 2008 Author Share Posted May 16, 2008 It seems DllCall is returning @error = 3 meaning the function "LoadBitMap" is not found in the DLL file. So part of my problem is I interpreted the Pascal snippet incorrectly. My bad. Is there another way to "stream out" the bitmap from the DLL into memory then update an image control perhaps? Thanks for all your help in this Zorphnoq Link to comment Share on other sites More sharing options...
abb Posted May 16, 2008 Author Share Posted May 16, 2008 Thanks Zedna. This looks like what I need but for the life of me I don't entirely understand how to use it. Link to comment Share on other sites More sharing options...
Zedna Posted May 16, 2008 Share Posted May 16, 2008 Thanks Zedna. This looks like what I need but for the life of me I don't entirely understand how to use it. I haven't implemented into my UDF optional $DLL parameter as proposed by ProgAndy yet.I will do it later. So you must use ProgAndy's code for now.Post your DLL file ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ProgAndy Posted May 16, 2008 Share Posted May 16, 2008 (edited) I made it for the Newest resources.au3: http://www.autoitscript.com/forum/index.ph...st&p=522569(With demo) Edited May 16, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
abb Posted May 16, 2008 Author Share Posted May 16, 2008 Perfect. Thank You Very Much! With your help Progandy and Zedna I'm up and running again. Kudos! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now