Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - LoadBitmapFromResource hint
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

LoadBitmapFromResource hint

 Post Reply Post Reply
Author
Message
AndyWilton View Drop Down
Groupie
Groupie
Avatar

Joined: 03 June 2008
Status: Offline
Points: 82
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndyWilton Quote  Post ReplyReply Direct Link To This Post Topic: LoadBitmapFromResource hint
    Posted: 27 August 2008 at 9:19am
Hi,
 
I'm struggling to get 'LoadBitmapFromResource' working - can anybody help on this, eg, examples of the parameters etc.
 
I'm developing in a language called Clarion.  So far, I have tried a few examples but non are working.  I presume I passing it incorrect parameters.
 
Regards,
 
Andy Wilton
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 27 August 2008 at 9:41am
Hi Andy,
 
 
It is VB code but maybe you can figure it out
 
 
And also (this has to do with what you can do with your signature) have a look at post: https://forum.codejock.com/forum_posts.asp?TID=11225
 
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
AndyWilton View Drop Down
Groupie
Groupie
Avatar

Joined: 03 June 2008
Status: Offline
Points: 82
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndyWilton Quote  Post ReplyReply Direct Link To This Post Posted: 27 August 2008 at 10:25am

Hi,

I've looked at the above example in the past but don't understand the 2nd parameter on the 'LoadBitmapFromResource' function.  The help says:-
 
Resource

Specifies the image to load in the resources of the module

I presume this would be the handle to the icon / image within the DLL / EXE, but the example uses a value of 1000? :-
 
ImageManager1.Icons.LoadBitmapFromResource oRes.hModule, 1000, IDS(), xtpImageNormal
 
Is there something I'm missing?
 
Regards,
 
Andy
Back to Top
ijwelch View Drop Down
Senior Member
Senior Member


Joined: 20 June 2006
Status: Offline
Points: 262
Post Options Post Options   Thanks (0) Thanks(0)   Quote ijwelch Quote  Post ReplyReply Direct Link To This Post Posted: 27 August 2008 at 9:33pm
Hi,

Yes, the 2nd Param (1000 in the example) is the id of the image strip in the resource file.

For completeness, there's another related thread here:
https://forum.codejock.com/forum_posts.asp?TID=11351&KW=

Back to Top
AndyWilton View Drop Down
Groupie
Groupie
Avatar

Joined: 03 June 2008
Status: Offline
Points: 82
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndyWilton Quote  Post ReplyReply Direct Link To This Post Posted: 28 August 2008 at 9:37am
Hi,
 
I'm sorry but I still don't get it.  Basically, I'm compiling a single PNG file into my app.
 
I can get the handle of the EXE/DLL that the image is compliled into, and I can get handle of the Image within the EXE/DLL but I don't understand where I would specify the handle to the image within the command?
 
A more detailed explanation would be greatfully received.
 
Many thanks in advance,
 
Regards,
 
Andy
Product: Xtreme SuitePro (ActiveX) v11.2.1 -> v15.2.1
Platform: Windows XP / Vista / Win 7
Language: Clarion 5.5 -> C8.x
======================================
Andy Wilton
Back to Top
PatS View Drop Down
Groupie
Groupie


Joined: 11 May 2006
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote PatS Quote  Post ReplyReply Direct Link To This Post Posted: 02 September 2008 at 12:37pm
Does the LoadBitmapFromResource method work with icons?  I can't get this method to work either.
Back to Top
WaleedSeada View Drop Down
Groupie
Groupie
Avatar

Joined: 29 March 2007
Location: Egypt
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote WaleedSeada Quote  Post ReplyReply Direct Link To This Post Posted: 04 September 2008 at 3:05am
Hello Andy,
 
First of all you should create a single image that represent your imgs that you will use for the commandbar....
 
 
This image is a collection of 13 image of each 32x32 pixel that makes a 416x32 pixel of the main image.
 
You then add this image to your resource file using resource editor like (Restorator2007) and give that resource (img) an ID = 1000.
 
You should use a function (or API) to load the .Dll that contains the resource (.bmp,.png,. ...etc) this function should return a handle to the .dll
example: dllhandle = LoadLibraryA("Resource.dll")
 
Define an array of integers with relative ID of your buttons that will use the images example:
ImageList = {101,102,103,104,105}
 
and remember that the image should have the same count as the items in the array as we have here 13 image in our main img with 32x32 each, your array should have 13 Button ID's.
 
Call the iconmanager.Loadbitmap(... passing that handle and the imageID to LoadBitmapfromResource to get back the array of the images that will be created look at this :
IconMgr.Icons.LoadBitmapFromResource(dllhandle, ImageID, ImageList, xtpImageNormal)
 
I hope this can help...
 
Best regards
:Powerbuilder 10.5
:Codejock suite 11.2.2
=========================
Waleed Seada
Back to Top
AndyWilton View Drop Down
Groupie
Groupie
Avatar

Joined: 03 June 2008
Status: Offline
Points: 82
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndyWilton Quote  Post ReplyReply Direct Link To This Post Posted: 04 September 2008 at 5:53am
Hi Waleed,
 
Many thanks for your example code.
 
However, the language I develop in is called Clarion and its interface to compiling in Resource images is quite a bit different.  One problem I have is that I can't control the ID of any of the compiled in Resources.
 
To combat this, I use an API to obtain a handle to the Compiled in Image Resource, but when I use this as a parameter it doesn't work.
 
Does anybody have any examples of getting the "LoadBitmapFromResource" to work from such a handle?
 
One thing to note is that each image file will only ever contain 1 image.
 
 
Thanks in advance,
 
Andy
Product: Xtreme SuitePro (ActiveX) v11.2.1 -> v15.2.1
Platform: Windows XP / Vista / Win 7
Language: Clarion 5.5 -> C8.x
======================================
Andy Wilton
Back to Top
WaleedSeada View Drop Down
Groupie
Groupie
Avatar

Joined: 29 March 2007
Location: Egypt
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote WaleedSeada Quote  Post ReplyReply Direct Link To This Post Posted: 04 September 2008 at 6:51am
Hi Andy,
If clarion is capable of dealing with .dll's I guess you can create the .dll using other tool as I suggest to you (Restorator2007).... It is possible to assign ID to img's this way ...
 
Then you can referance the Img using the API ...
 
Right ?!
 
:Powerbuilder 10.5
:Codejock suite 11.2.2
=========================
Waleed Seada
Back to Top
AndyWilton View Drop Down
Groupie
Groupie
Avatar

Joined: 03 June 2008
Status: Offline
Points: 82
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndyWilton Quote  Post ReplyReply Direct Link To This Post Posted: 08 September 2008 at 1:17pm
Hi Waleed,
 
That gives me a couple of ideas?  I shall try it out.
 
Thanks,
 
Andy
Product: Xtreme SuitePro (ActiveX) v11.2.1 -> v15.2.1
Platform: Windows XP / Vista / Win 7
Language: Clarion 5.5 -> C8.x
======================================
Andy Wilton
Back to Top
MadRiver View Drop Down
Groupie
Groupie


Joined: 21 August 2008
Location: United States
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote MadRiver Quote  Post ReplyReply Direct Link To This Post Posted: 11 September 2008 at 4:43pm
I am having trouble using this with C++ (not MFC).

My dll has one resouce, a 32 x 32 icon.
    HRESULT hr;
    HMODULE hMod = 0;

    int cmds[1];
    cmds[0] = M_FILE_CLOSE;
    CComSafeArray<int> safeCommands(_countof(cmds));
    for (int i = 0; i < _countof(cmds); ++i) {
        safeCommands.SetAt(i, cmds);
    }

    hMod = LoadLibrary(pszNameDLL);
    hr = pIcons->LoadBitmapFromResource((long) hMod, 105, CComVariant((LPSAFEARRAY)safeCommands), xtpImageNormal);
    ATLASSERT(SUCCEEDED(hr));

I suspect that the problem may be due somehow to having to cast the hMod to long.  Unfortunately, hr == S_OK.
When I open the dll in VisStudio, the one resource has the ID 105.

When I create a button control, I call
    pControl->PutIconID(M_FILE_CLOSE);

No icon appears on the button.

What am I doing wrong?

UPDATE:  It appears icons are not supported, only bitmaps.


Back to Top
MadRiver View Drop Down
Groupie
Groupie


Joined: 21 August 2008
Location: United States
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote MadRiver Quote  Post ReplyReply Direct Link To This Post Posted: 12 September 2008 at 1:09pm
Originally posted by PatS PatS wrote:

Does the LoadBitmapFromResource method work with icons?  I can't get this method to work either.

I believe icons are NOT supported.  I have a dll with a bitmap and an icon; the bitmap loads, the icon does not.

Back to Top
PatS View Drop Down
Groupie
Groupie


Joined: 11 May 2006
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote PatS Quote  Post ReplyReply Direct Link To This Post Posted: 19 September 2008 at 11:24am
I have a resource dll containing icons, not bitmaps.  Is there a known way to load icons from a resource file to be used in my Codejock commandbars?  I'd prefer to deal with icons instead of bitmaps.
 
Thanks,
Pat
 
Back to Top
nighthawk View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 June 2004
Status: Offline
Points: 167
Post Options Post Options   Thanks (0) Thanks(0)   Quote nighthawk Quote  Post ReplyReply Direct Link To This Post Posted: 21 September 2008 at 5:05am
Years ago when I designed my system for bringing icons and bitmaps into the CodeJock ImageManager, I ran into several problems when I went directly from the resource file to the ImageManager.  Unfortunately, I don't remember exactly what the problems were but the workaround I came up with solved my problem and it may help you as well.  It is quite simple, save the icon/bitmap into a temporary file and then use the LoadIcon/LoadBitmap function to bring it into the ImageManager. 

To move the resource item into a temporary file, I use a function called SaveResItemToDisk.  Just google it to get all the code and examples of its use.  One trick I found works well is to save the resource as a "CUSTOM" type instead of a "BITMAP" or "ICON" type.  Once it is in a temp file, it is just data so type is irrelevant.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.