March 28, 2024, 04:15:09 PM

News:

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


IWGrid resource

Started by Brian, January 11, 2014, 04:32:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

Larry,

Just wondered whether it would be possible to load an image into a cell from a resource ID?

Because I have failed miserably in being able to output the contents of my grid as a PDF,
I was wondering whether to load all the bitmaps as resources, and then I could just
distribute the exe file as a complete entity, with only the mdb file as an extra

InitCellDat is expecting a string, of course, and does not accept an ID integer

Brian

LarryMc

Right now the grid is looking for a file name.
I'll add it to my list to make it easy to add from a resource (but it's going to be a good while before I get to it)

There's no reason you can't add your images and mdb file as resources to your exe right now.
All you have to do is set things up this way.
Have your exe create and ini file the first time it is run
then check and see if the version # stored in the ini file is the same as the current exe version#
When the exe is run the 1st time the version numbers will not match.
When that happens you extract the database and images to a directory.
then you have what you need to load the grid.
then you update the version number in the ini file

the next time the exe is run the version #s will match so nothing happens.

if you determine there is a need to update the mdb or images you send the users a new exe with a different version #.
now the version #s are different so you extract the images and mdb and overwrite the cold ones
then update the ini and load the grid.

That way you only have  the one exe file to distribute to your users.

I'll also look and see if I could make a special opendb command to use a resource ID.(I don't think I'll have any luck there but I'll look anyway)

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

Brian

OK, Larry,

Well, I'm a patient guy, and I guess I can wait for you to get round to it

Of course, your suggestion is one way of doing it, but as I don't have IWB
on a PC at work, would be fiddly to implement

Brian

LarryMc

Quote from: Brian Pugh on January 11, 2014, 12:23:46 PM
Of course, your suggestion is one way of doing it, but as I don't have IWB
on a PC at work, would be fiddly to implement
you can install IWB2.5 beta on a memory stick
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Brian

Yes, I know that, but all the USB slots are disabled on our PCs - seems they don't trust us!
Oh, and the CD/DVD drives, as well . . .

Bit paranoic, I reckon, but they are "their" PCs, not ours. Although the data we work
on is a bit sensitive, I suppose

Thanks for your reply,

Brian

LarryMc

then how do you load the exe and run it?
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Brian

Well, I make a copy of the exe at home, take off the extension, and then zip it.
Then I take the extension off the zip file, and then send it to myself at work.
That's the only way I can sneak it through the inward email checking!

Brian

LarryMc

okay, I understand. Are you zipping the images and mdb also to get them to work also?

BTW, I've been up all night and decided to look into the loading from resource idea.
At first it look pretty difficult.  but I gather different pieces of code together along with what I already had and started arranging all of it and removing stuff I didn't need.  The more I did the easier it started looking. And I was able to find one piece of code that I absolutely need and wouldn't have known how to do otherwise.

I figure that in 24-36 hours I will be creating a test project with the resources and see what happens.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

After a 7 hr nap I got back up and continued with the coding. 
After several more hours of massaging code I wound up dumping all that code.

What I had discovered is that removing a few lines of code in my existing IWGrid and following some specific rules it will be easy for you to load your images from a resource file.

First of all your application will have to be built as a project and not a single file executable,.  That's because you can only add resources to projects in IWBasic.

Right now typical image setup command is:
IWG_InitCellDat(main,  501, 6, 3, getstartpath+"back.jpg",@IWGIMAGE,0)
IWG_InitCellDat(main,  501, 8, 4, getstartpath+"bug1.bmp",@IWGIMAGE,@IWG_NOSCALE)

the same images loaded from a resource file would look like this
IWG_InitCellDat(main,  501, 6, 3, "#234",@IWGIMAGE,0)
IWG_InitCellDat(main,  501, 8, 4, "#2222",@IWGIMAGE,@IWG_NOSCALE)

The corresponding entries in the resource file look like this:
2222 RTIMAGE "c:\!iwgrid\bug1.bmp"
234   RTIMAGE "c:\!iwgrid\back.jpg"


The entries in the rc file must have numeric IDs like the 234 and 2222 and they must be unique
The type in the rc file must be  RTIMAGE
And the image must be a scalable bmp,jpg, or gif.

When adding the resource from inside the IDE select "Scalable Image" as the resource type and make sure the ID is changed to a unique number value.

When initializing the cell with the IWG_InitCellDat use the resource ID number preceded by # all in quotes. i.e  "#2222"

This feature will be in the next beta release.

@Brian - I'll email you a temp lib so you can finish what you are doing in the next 12-18 hours.

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

Brian

Larry,

That looks good, and entirely manageable. Looking forward to a test run!

Brian

LarryMc

Quote from: Brian Pugh on January 13, 2014, 02:32:44 AM
Larry,

That looks good, and entirely manageable. Looking forward to a test run!

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