Re: Icons on menu[INFO]

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Tom

I tried this as follows called from VBA code in my Access app:

Dim hMod As Long, hImage As Long
hMod = LoadLibrary(CurrentDBDir & "CustMan.dll")
hImage = LoadImage(hMod, ByVal 101&, IMAGE_ICON, 16, 16, 0)
FreeLibrary hMod

(CurrentDBDir supplies a path)

LoadLibrary and FreeLibrary return correctly but hImage returns 0 with
LastDllError 0 too.
Icon 101 in the res file is known good (loads fine with LoadImage
LR_LOADFROMFILE)

Maybe I created the dll incorrectly:

OpenVB, New ActiveX Dll, Resource Editor - Add Icon
Save resource File, save project
Make dll from main file menu

BTW .lib & .exp files are also created when the Dll is made. Would these
need distributing with the dll (assuming it worked of course!)

TIA

Jon

"Tom Esh" <tjeshGibberish@xxxxxxxxxx> wrote in message
news:49m6e2lgipg5127lrdl6n57uvhun4hjr51@xxxxxxxxxx
On Wed, 16 Aug 2006 12:51:47 +0100, "Jon Lewis"
<jon.lewis@xxxxxxxxxxxxxx> wrote:

Tom

'scuse me for busting in on this thread

I program mainly in MS Access but I use LoadImage alot to load icon files
for use as form icons etc. I either distribute all the many icon files
seperately or store the icons as binary data within the Access MDB/E file
in
which case I'm writing an icon from binary data to file on the hard disk
file before using LoadImage to LOADFROMFILE

I was wondering whether it would be possible to create a res file using vb
containing all my images, wrap that up in a VB executable and then use
LoadImage from a seperate application to load an icon to memory for use by
that application?

Yes, but it would not have to be an exe if that's all you're using it
for. A dll would work just as well, and it would not even need to be
registered if you plan to use strictly Api methods to load the images.
Works like this:

hMod = LoadLibrary("mydll.dll")
hImage = LoadImage(hMod, ByVal 101&, _
IMAGE_BITMAP, 13, 13, 0)
FreeLibrary hMod

Note LoadLibrary, FreeLibrary would not typically be used each time
you load an image, but rather once to wrap all calls to LoadImage.

One thing important to keep in mind is this is only useful if you plan
to use strictly Api methods to manipulate the images.
You could not for example use it to fetch a COM Picture object and
assign it to a control property. For that you're better off building a
COM (registered) dll with a public class and methods to fetch Picture
objects.


-Tom
MVP - Visual Basic
(please post replies to the newsgroup)


.



Relevant Pages

  • Re: WinLoadDlg fails on a WSeB system (WinGetLastError = 0x00081003), works fine for me with eCS 1.0
    ... I added one new kind of control to this dialog window - a standard pushbutton with a mini-icon picture instead of text. ... This resource resides in a DLL, which also has an icon in the "#2" slot. ... The executable itself only has a single resource of an icon in the "#1" slot. ...
    (comp.os.os2.programmer.misc)
  • Re: Icons on menu[INFO]
    ... I program mainly in MS Access but I use LoadImage alot to load icon files ... LoadImage from a seperate application to load an icon to memory for use by ... registered if you plan to use strictly Api methods to load the images. ...
    (microsoft.public.vb.winapi)
  • Re: Eigene Icons für DOS-Applikationen
    ... die ich als "irfanview Icon Files" bereits ... Nur wird z.B. bei DOS-Anwendungen immer eine Bibliothek (DLL) ... welche Art von Verknüpfung ich auf dem Desktop ...
    (microsoft.public.de.german.windowsxp.sonstiges)
  • Re: WinLoadDlg fails on a WSeB system (WinGetLastError = 0x00081003), works fine for me with eCS 1.0
    ... window - a standard pushbutton with a mini-icon picture instead of text. ... This resource resides in a DLL, which also has an icon in the "#2" slot. ...
    (comp.os.os2.programmer.misc)
  • Re: Icons on menu[INFO]
    ... I program mainly in MS Access but I use LoadImage alot to load icon files ... LoadImage from a seperate application to load an icon to memory for use by ... LoadImage will load app resource images as well. ...
    (microsoft.public.vb.winapi)