Retrieve picture by using DLL-method 
Author Message
 Retrieve picture by using DLL-method

Hi all,

I read a picture by using an ActiveX DLL-method. The method works fine, but
when
the method "returns" to the calling function in the EXE-module, my
application
crashes. Someone in this newsgroup mentioned to use the IPictureDisp as
return-type
but that doesn't work either.

Anybody has an idea to solve this ? Anybody does know how to pass pictures
between a DLL and an EXE ?

Thanks in advance !

Jean-Marie De Smet


My code:

EXE-module
---------------

...

Private objPic As Pic.GetPictures
...
private sub Form_load()

    on error goto errhandler

    Set objPic = CreateObject("Pic.GetPictures")            ' works fine

    call imgToolbar.ListImages.Add(1, , GetIcon(1))         ' jumps to
errhandler when GetIcon() returns

    exit sub

errhandler
    logerror (LOG_ERROR, "loading form failed")

end sub

Form_unload()
    set objPic = nothing
end sub



Mon, 14 Jan 2002 03:00:00 GMT  
 Retrieve picture by using DLL-method
I just successfully passed a picture to a PictureBox using a DLL without
having the BMP or the Resource file in the actual application.  Inside you
ActiveX DLL or EXE, include the resource file.  Then, create a global
function of type Picture, which will become a method of the class.  The
function should accept 2 input parameters, the index of the image, type
integer, and the format of the image, type LoadResConstants.  Inside the
Function, set the function equal to the LoadResPicture.  Here is a sample
function for the class:

        Public Function LoadBitmap(Index as Integer, Format as LoadResConstants)
as Picture
                Set LoadBitmap = LoadResPicture(Index, Format)
                Exit Function
        End Function

Now, inside your application, reference the DLL in the properties, and
declare a new instance of the class you created.  You can then retrieve any
image by Index and Format using the LoadBitmap method:

        Dim MyResource as New resourceclass
        Picture1.Picture = MyResource.LoadBitmap(ImageIndex, vbResBitmap)

Variations can be used to load any acceptable resource format.  Have fun!

-BT



Quote:
> Hi all,

> I read a picture by using an ActiveX DLL-method. The method works fine,
but
> when
> the method "returns" to the calling function in the EXE-module, my
> application
> crashes. Someone in this newsgroup mentioned to use the IPictureDisp as
> return-type
> but that doesn't work either.

> Anybody has an idea to solve this ? Anybody does know how to pass
pictures
> between a DLL and an EXE ?

> Thanks in advance !

> Jean-Marie De Smet


> My code:

> EXE-module
> ---------------

> ...

> Private objPic As Pic.GetPictures
> ...
> private sub Form_load()

>     on error goto errhandler

>     Set objPic = CreateObject("Pic.GetPictures")            ' works fine

>     call imgToolbar.ListImages.Add(1, , GetIcon(1))         ' jumps to
> errhandler when GetIcon() returns

>     exit sub

> errhandler
>     logerror (LOG_ERROR, "loading form failed")

> end sub

> Form_unload()
>     set objPic = nothing
> end sub



Mon, 14 Jan 2002 03:00:00 GMT  
 Retrieve picture by using DLL-method
Brian,

My problem is solved! I distributed my problem to other newsgroups but they
all
replied the same examples as you did. They had no problems, but I did.
My error was: "automation error, catastrophic failure".

Than I had the smart idea to compile my DLL and to use this DLL, instead of
using
the running Visual Basic project DLL (which is handy to debug). Instead of
using
2 visual basic projects (my EXE-module and my DLL-module), I used inly one
(my EXE-module) with a reference to the compiled DLL. Doing this way works
fine !!!
All icons are passed correctly now !

So the problem seems to be in Visual Basic when 2 projects (an EXE and a
DLL)
are running in debug mode at the same time and they have to pass pictures.

Many thanks for your comment !

Regards,

Jean-Marie De Smet
3Logics (Belgium)


Quote:
> I just successfully passed a picture to a PictureBox using a DLL without
> having the BMP or the Resource file in the actual application.  Inside you
> ActiveX DLL or EXE, include the resource file.  Then, create a global
> function of type Picture, which will become a method of the class.  The
> function should accept 2 input parameters, the index of the image, type
> integer, and the format of the image, type LoadResConstants.  Inside the
> Function, set the function equal to the LoadResPicture.  Here is a sample
> function for the class:

> Public Function LoadBitmap(Index as Integer, Format as LoadResConstants)
> as Picture
> Set LoadBitmap = LoadResPicture(Index, Format)
> Exit Function
> End Function

> Now, inside your application, reference the DLL in the properties, and
> declare a new instance of the class you created.  You can then retrieve
any
> image by Index and Format using the LoadBitmap method:

> Dim MyResource as New resourceclass
> Picture1.Picture = MyResource.LoadBitmap(ImageIndex, vbResBitmap)

> Variations can be used to load any acceptable resource format.  Have fun!

> -BT



Tue, 15 Jan 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Retrieve pictures by using DLL-method

2. Retrieving Pictures From a SQL Server using ASP

3. Help!! - clipping pictures using the paintpicture method

4. Out of memory using SSPanel and Picture Box Controls w/graphics methods - Please Help

5. Flip a Picture in PictureBox control using PaintPicture Method

6. picture object render method - has anyone used it successfully

7. how to retrieve the file size using wininet.dll

8. How to retrieve file size using wininet.dll

9. Retrieve web page using an ActiveX DLL?

10. Retrieving the version of DLL's used

11. Problem using AXTIVEX DLL method from ASP

12. Using an object parameter in a DLL method

 

 
Powered by phpBB® Forum Software