PDA

View Full Version : Converting the Gauge Project to Multi-Gauge Format



n4gix
11-15-2005, 04:32 PM
This is a continuation of the previous tutorial, which discussed setting up the MSVC++ .NET 2003 IDE for gauge development. In particular, the sample gauge file used in that tutorial will be used in this new installment.

Using the gauge code already discussed, I am now going to illustrate the process by which we need to modify the original code such that it will be ready for conversion to a true multi-gauge format.

NOTE: I suffer no illusions that this is the "best" way to handle the conversion of Easy Gauge source files to a multi-gauge format! However, it is simple, logical and most importantly, IT WORKS! ;)

As a first step, I have created a new subfolder in my gauge project and named it \subgauges. I have moved the xxxG.c file to this new subfolder:

http://img342.imageshack.us/img342/4403/cplustut016fj.jpg

Now I need to modify the main .c file to show where I've now located the xxxG.c file:

http://img247.imageshack.us/img247/3186/cplustut022oy.jpg

Next, I need to make the resource id's for this subgauge unique. I have adopted the convention of addint a three-four letter 'prefix' to designate the subgauge's revisions. In this case, MAP_ seems to be a logical choice.

Here is the revised .h file:

http://img247.imageshack.us/img247/7236/cplustut039wl.jpg

Now I'll modify the .rc file:

http://img39.imageshack.us/img39/2280/cplustut045bw.jpg

The final step in this process is a bit longer and I'll have to use a number of pictures to illustrate the full process. I'll continue this in the next section.

n4gix
11-15-2005, 04:42 PM
Using the same 'prefix' convention, I'll now modify the main gauge source file (xxxG.c) as illustrated in the series of pictures following.

I've made ample notes on the pictures, so I'll keep the explanation short... ;)

http://img256.imageshack.us/img256/8917/cplustut05a9dx.jpg
http://img256.imageshack.us/img256/2036/cplustut05b3hy.jpg
http://img256.imageshack.us/img256/2772/cplustut05c8oj.jpg
http://img440.imageshack.us/img440/4461/cplustut05d8lb.jpg
http://img440.imageshack.us/img440/5553/cplustut05e5sn.jpg
http://img440.imageshack.us/img440/3333/cplustut05f1tg.jpg

The final step I need to take prior to attempting a new compile of this project is to 'fix' a little path problem with the IDE.

If you remember, I added the xxxG.c file to the project and set its Properties to "Excluded from Build." Well, since I've moved that file to a new subfolder, I need to let the IDE know about that move... ;)

Highlight the xxxG.c filename and right-click. Choose the "Remove" option to delete the filename. Now, right-click on the "Source Files" again, an choose "Add/Add Existing Item." Navigate to the subgauge folder and highlight the xxxG.c file again.

Now, right-click on the xxxG.c filename, and using Properties, set the file to be "Exluded from Build" again.

Now I will rebuild the gauge project and check for any errors... Since I was very careful, I have none! Hooray!

In the next installment, I'll discuss adding a new subgauge to this project. Once that's done, you should be able to successfully continue adding subgauges until your project is finished. ;)

n4gix
11-15-2005, 05:57 PM
Now, I'll add another gauge to the Project to make this a true 'multi-gauge!' ;)

First, I copy/paste the existing .c, .h, .rc. and G.c source code to the Project's \subgauges folder:

http://img402.imageshack.us/img402/9307/cplustut068kw.jpg

Next, copy/paste all the .bmp files to the Project's \res folder:

http://img402.imageshack.us/img402/9742/cplustut071me.jpg

Next, open the new gauge's .c file and copy/paste the highlighted entries to the Project's master .c file:

http://img402.imageshack.us/img402/5024/cplustut083yv.jpg
http://img402.imageshack.us/img402/8282/cplustut095fd.jpg

Next, copy/paste the GAUGE_TABLE_ENTRY line from the x.c file as illustrated. Now you may delete the x.c file from the \subgauges folder to keep things tidy... ;)

http://img248.imageshack.us/img248/571/cplustut107ck.jpg

Now, open the x.h file and copy the resource lines to the master .h file as shown below. Add the 'prefix' you want to the RecX entries. Now you may close and delete the x.h file to keep things tidy...

http://img248.imageshack.us/img248/2581/cplustut118xl.jpg

Now, open the x.rc file and copy the bitmap entries to the master .rc file, and make the edits as shown below. Close the file and delete the x.rc file from the subfolder. There should now only be xG.c files remaining in the \subgauges folder! ;)

http://img46.imageshack.us/img46/8545/cplustut121sj.jpg

The last step I'm not going to "illustrate," since it is basically the same thing that's been covered already. You need to edit the xG.c file for the new subgauge to add the 'prefix' as shown previously, and make the other edits & deletions of unnecessary and redundant code.

Finally, run Rebuild MyNewGauge and check for errors. If you've been careful, you should have none!