LoadBitmapFromResource hint |
Post Reply |
Author | |
AndyWilton
Groupie Joined: 03 June 2008 Status: Offline Points: 82 |
Post Options
Thanks(0)
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
|
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi Andy,
For an example look at post: https://forum.codejock.com/forum_posts.asp?TID=9901&KW=LoadBitmapFromResource&PID=32301#32301
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.... |
|
AndyWilton
Groupie Joined: 03 June 2008 Status: Offline Points: 82 |
Post Options
Thanks(0)
|
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:-
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
|
|
ijwelch
Senior Member Joined: 20 June 2006 Status: Offline Points: 262 |
Post Options
Thanks(0)
|
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= |
|
AndyWilton
Groupie Joined: 03 June 2008 Status: Offline Points: 82 |
Post Options
Thanks(0)
|
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 |
|
PatS
Groupie Joined: 11 May 2006 Status: Offline Points: 24 |
Post Options
Thanks(0)
|
Does the LoadBitmapFromResource method work with icons? I can't get this method to work either.
|
|
WaleedSeada
Groupie Joined: 29 March 2007 Location: Egypt Status: Offline Points: 88 |
Post Options
Thanks(0)
|
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 |
|
AndyWilton
Groupie Joined: 03 June 2008 Status: Offline Points: 82 |
Post Options
Thanks(0)
|
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 |
|
WaleedSeada
Groupie Joined: 29 March 2007 Location: Egypt Status: Offline Points: 88 |
Post Options
Thanks(0)
|
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 |
|
AndyWilton
Groupie Joined: 03 June 2008 Status: Offline Points: 82 |
Post Options
Thanks(0)
|
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 |
|
MadRiver
Groupie Joined: 21 August 2008 Location: United States Status: Offline Points: 22 |
Post Options
Thanks(0)
|
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. |
|
MadRiver
Groupie Joined: 21 August 2008 Location: United States Status: Offline Points: 22 |
Post Options
Thanks(0)
|
I believe icons are NOT supported. I have a dll with a bitmap and an icon; the bitmap loads, the icon does not. |
|
PatS
Groupie Joined: 11 May 2006 Status: Offline Points: 24 |
Post Options
Thanks(0)
|
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
|
|
nighthawk
Senior Member Joined: 11 June 2004 Status: Offline Points: 167 |
Post Options
Thanks(0)
|
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. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |