April 28, 2024, 04:09:32 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


LoadresourceA Problem

Started by LarryMc, March 07, 2009, 11:03:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

in my program I have the following line of code:
#pc.cshell.hbmp_s=LoadImageA(0, #pc.cshell.bgbmp, IMAGE_BITMAP, rc.right,rc.bottom, LR_LOADFROMFILE)
where #pc.cshell.bgbmp is the complete path/filename to the desired bitmap.
when I use a path name like this everything works fine:
"c:\\_EBDev\\projects\\_ccdesignerv13\\seasky.bmp"
when I try to read it from my documents, like this it never works:
"c:\\Documents and Settings\\Larry\\My Documents\\CCDLM\\bmps\\seasky.bmp"
And that is a valid path on my computer.

Anyone got any ideas?

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

Enclose the path in embedded quotes if it contains spaces, it is a Windows thing.

I use a simple subroutine to do it.


sub MakeShellPath(string path),string
string ret = path
if(instr(ret," "))
ret = "\"" + path
ret += "\""
endif
return ret
endsub


#pc.cshell.hbmp_s=LoadImageA(0, MakeShellPath(#pc.cshell.bgbmp), IMAGE_BITMAP, rc.right,rc.bottom, LR_LOADFROMFILE)

Paul.
Ionic Wind Support Team

LarryMc

Thanks Paul,

As always I knew you'd have the answer.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Paul

The routine puts the quotes around the path as you said.

The file path passes a fileexist test but it still won't load.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

OK Then it probably wasn't the spaces in the path problem, perhaps it is just a LoadImageA API function problem, maybe it can't handle that path for some obscure reason.  A quick search through MSDN didn't reveal much though

Are you sure the bitmaps are the same?  Is it possible the one in My Documents got corrupted somehow?

Paul.

Ionic Wind Support Team

LarryMc

I deleted the images in My Docs and replaced them with new copies from another directory that works.

Still doesn't work from my docs.

I'll create me a little separate program that is easier to play with and do a bunch of experimenting.

I must be doing some little stupid thing that I'm not seeing although it's pretty straight forward.

Anyway, thanks for the help.

Larry

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Found a program I had that Sapero wrote that loaded thumbnails of bmps.

It had no problem loading the image with my original path name using LOADIMAGE.

I looked at the source for the LOADIMAGE command and seen that it used GetModuleHandle(0)

I plugged that in and it will read the my docs files without any problem and it doesn't need your embedded quote routine.

The MSDN led me to believe I needed to use a NULL instead of GetModuleHandle(0).

I wouldn't have found the problem had I not had the EBasic source code.

That's another reason for all of you out there to purchase the source code at the current super low price.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Quote from: Paul Turley on March 08, 2009, 12:02:04 AM
Are you sure the bitmaps are the same?  Is it possible the one in My Documents got corrupted somehow?

Seems that is the 2nd part of my problem.
If I manually copy the bmp into my docs then everything works fine.

But if I put this in the .rc file:
Quote308 BITMAP "C:\\_EBDev\\projects\\_CCDesignerV13\\bmp\\paper.bmp"
309 BITMAP "C:\\_EBDev\\projects\\_CCDesignerV13\\bmp\\seasky.bmp"
and then use this to put them in my docs it dosen't work

ExtractResource(308, @RESBITMAP, bpath2$+"paper.bmp")
ExtractResource(309, @RESBITMAP, bpath2$+"seasky.bmp")

the paper.bmp file shows to be the same size of the original but it still won't load.
the seasky.bmp file shows to be a different size.

Any ideas?

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

ExtractResource?

Are you using this example that I posted long ago on a different forum?


SUB ExtractResource(id:INT, ty:INT, fn:STRING),INT
   BFILE f
   MEMORY m
   INT retc
    retc = 0

   if loadresource(id, ty, m)
      if openfile(f, fn, "w")=0
         retc = __write(f, m, GetResourceLength(id,ty))
         closefile f
      endif
      freemem m
   endif

   return retc
ENDSUB
Ionic Wind Support Team

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

You can't extract a bitmap like that.   The bitmap file would need to be saved in resources as a "custom" type, so all file headers remain intact, and then extracted as a "custom" type.

In other words you get an exact duplicate of the file, doesn't matter what the contents of the file are.   

If you use LoadResource with the type of @RESBITMAP you are getting the bitmap suitable for displaying on the screen, but without the bitmap file header.  If you need to do both then you'll have to have duplicates in resources, one for displaying and one for extracting.  Well...actually you don't need both but recreating the bitmap file header manually would be a lot more code.

Paul.
Ionic Wind Support Team

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library