-
February 19th, 2004, 07:49 PM
#1
Tip of the day Component
Hi guys.!
Well, it's been a long time since I used VC++ and I started again in December. Now, I have made a little "encryption" program using the Julius Ceasar algorithm in VC++ and I added a Tip of the Day component when the program starts.
The thing is that this component is relying on a file called Tips.txt but what I want to know, is ...
Is there a way to get rid of the tips.txt and somehow make the component look for the tips internally (you know, so I don't have to pack the exe with a txt file)?
P.S. if you want to see the executable and test it a little, just post and I might be able to put it up for download :P
-
February 19th, 2004, 11:00 PM
#2
Put them in a resource...string table or binary resource perhaps.
Or put the entire contents of the file in an const array.
gg
-
February 19th, 2004, 11:11 PM
#3
Wouldn't using arrays limit the number of characters per tip?
So this would make the Resources a better option?
-
February 19th, 2004, 11:23 PM
#4
Resources are more flexible and can be changed without a recompile or stored in seperate DLL's.
I was suggesting that you put the entire contents of the file into a single array. Consider that if the file is small and you have no need to modify the data once the code is built. Upside is that it's a quick and easy way to get the text "inside" the exe.
gg
-
February 19th, 2004, 11:30 PM
#5
OK.
If I choose to go the Resource route, whatever I put there (let's say I called the ID -> IDS_TIP and put whatever text) it's going to be a structure type or something similar while the Tip of the Day function uses a String variable.
Do you have an example to pass the IDS_TIP to the string variable?
Also, can you provide an code example of the array you are suggesting? (I'm only going to use one tip so ...).
Thanks a bunch.
And by the way, if you want to test the program
http://gelocks.topcities.com/DataDEEN.ZIP
-
February 20th, 2004, 01:47 AM
#6
Just create a string table resource. Each string can be it's own tip.
Use
LoadString() to access strings in your string table.
gg
-
February 20th, 2004, 11:03 AM
#7
Well.. it seems that functions requires an Instance and I'm not using API I'm using MFC.
So I tried changing a created variable (the component created it) that opens the file tips.txt to a CString so I could do:
CString m_pStream;
m_pStream.LoadString(IDS_TIP);
but it gives me errors (since the rest of the component thinks I'm opening a file!). If I take out everything related to file manipulation, the program compiles but when it is time to execute it just gives me a fatal error (still can't find it!!!).
I'll keep trying though.
Any other suggestions welcomed.
-
February 20th, 2004, 11:40 AM
#8
Duh...
Nevermind, I was doing something stupidly wrong!
It works like a charm so thanks for the help Codeplug.
Can you download the program again and tell me if it works (the zip is not suppossed to have the file tips.txt this time around).
Thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|