Hey everyone... I know you are all probably most accustomed to using GAPI and mostly no Win32, but I'm sure there are some experts around :)
I'm trying to load up an icon resource using this command:
g_TreeViewIL = ImageList_LoadImage(g_hInst, L"IDI_FOLDERS", 16, 20, CLR_DEFAULT, IMAGE_ICON, 0);
Laugh all you want, this is mainly for testing and I don't care too much about having a couple globals here and there ;)
Anyway - whats happening is I'm getting a NULL value back, which means it has failed. GetLastError() doesn't seem to hold any valuable information for this particular command unless I'm retarded and I don't understand it.. which is possible.
I've checked out the hInst and it appears to be assigned... so the only thing I think could possibly be causing a problem here is the icon resource file. The way I understand this command, the image should be a horizontal list of images that are the same width and a possibly different height.
The icon resource I'm trying to load is a 32x16x256 image.
No workie :) Can anyone help me out here? Am I being retarded? Any pointers (no pun intended)?
Thanks!
I'm not really sure about this. But, the documentation says that the second parameter should be the name of the image resource. This is pretty vague but it's possible that they mean that you should pass the name of the bitmap file that is included. If you view the properties of the image resource it should also have a name. Try passing that instead of L"IDI_FOLDERS". IDI_FOLDERS is typically called an identifier instead of a name. Worth trying, perhaps.
Actually that wouldn't work - the second param is supposed to be a long pointer to a filename OR a null terminated string containing the resource name - which is what I'm using right now. It wont compile with an int there ;)
I meant that you should pass L"bitmap1.bmp" or whatever the image is called. That is my interpretation of the documentation...
It says if you specify an hInstance to the module, you are supposed to be able to just use the resource name... not an external file - it is the second condition listed in the help. Still haven't been able to get it to work...
Thanks for replying anyway.
Yes, but bitmaps retain their original filenames within resources as well (I think). However, the IDI_FOLDERS is just an identifier with a certain value. The fact that the string "IDI_FOLDERS" points out a certain resource is not available when using the resources. The only way I could see that working is to specify MAKEINTRESOURCE(IDI_FOLDERS) as the second parameter.
Sorry, but that is not quite right. Just to try and figure this out, I've put the file on my PPC as icon1.ico and tried loading it up, and that doesn't work either.
It is definitely some kind of a problem with the resource size or something like that... can someone give me an example size of an icon and a line where this function DOES work?
Thanks,
Var
IDI_FOLDERS looks like an integer, not a resource name.
Try MAKEINTRESOURCE(IDI_FOLDERS) instead of L"IDI_FOLDERS".
I'm already doing this... please guys. I'm sure I have the command right - its gotta be a problem with the format of the image I'm using. It compiles already! I just get a NULL pointer :)
When trying to load the bitmap from a file, you did use the LR_LOADFROMFILE flag, right?
The documentation indicates that the third parameter, cx, is the width of each image. You have 16 in your code, yet you say that the image is 32x16x256. Shouldn't you have 32 in your code?
Also, are you actually working with an icon (.ico) file or some graphics format file like .bmp? It seems like you are dealing with an image file, in which case I believe the 6th parameter, uType. should be IMAGE_BITMAP instead of IMAGE_ICON as you have.
Both of those stuck out at me as possible problems.
Variant wrote:
I'm already doing this... please guys. I'm sure I have the command right - its gotta be a problem with the format of the image I'm using. It compiles already! I just get a NULL pointer :)
If it compiles and you get a NULL pointer, then most probably don't have your command "right". It could also be your image format, why not generate a MFC app and grab the icon in there to test it?
Just to let everyone know, I tried everything I could think of including all your suggestions.. which were very thoughtful, but not helpful unfortunately ;)
In the end, I switched to just using ImageList_Create() and using ImageList_AddIcon() in conjunction with the LoadIcon() function, and using two images instead of one. It gave me more flexibility anyway in creating the image list, and its probably a better way of doing things. It works great.
I still kinda wish I knew what was causing that problem, but I couldn't figure it out for the life of me.
Oh well.
By the way, is it a common thing for a new PocketPC developer learning Win32 API to write a file explorer app? There are a few out there but none of them really were as "native" looking as I wanted.. I tried DEXplor (nice job Dan!), AIDEM File Explorer (looked close to native but wasn't quite there, and was a bit er, unoptimized)... and in the end... I decided to write my own. Good ol' necessity eh.
I'm pretty new to the PPC dev community, but I have noticed that you all are pretty cheap most of the time :) I think that quality software can demand a fair price though.. 30 bucks for a lame file explorer is not a fair price.. maybe 5 bucks at the most. However, I completely believe that 20-30 bucks is fair for a game like Anthelion or Tower Mogul (very, very nice job guys!) or quite a few others.. a lot more work goes into making a game than a simple file explorer app requires.
Anyway, I've rambled way too much in this thread.. I should probably get some sleep :)
Laterz,
-Var
Well, if you want comfort, I wasn't able to do it either when I tried. Win32 tends to be frustrating like that...
Variant wrote:
I'm already doing this... please guys. I'm sure I have the command right - its gotta be a problem with the format of the image I'm using. It compiles already! I just get a NULL pointer
By the way, remember that a handle is not a pointer.
Very good point... I'll keep that in mind. Thanks!

Try Resco File Explorer. With all due respect to Dan, I find it to be the best file explorer out there.