I'm hoping this is easy, but google search is entirely failing me, as
the text "readme" causes every application ever written to appear in
the results.
I have an mfc dialog app utility that I want to ship with my main
application. The main application has a readme, and I really don't
want to add additional files to fileset, as it is confusing enough.
The utility has some fairly extensive command line support, and I'd
like to include documentation with it, but I don't want to include it
as additional files. To the user, I want my utility, that's it. When
they run the application, I want them to be able to view the readme,
even if it's just in a textbox. But despite wracking my brain, the
only thing I can think of is to load the readme at runtime from a
separate file, which is exactly what I want to avoid.
What's the best way of doing this? I'd really like to avoid having
additional files if I can.
Thanks,
~Scoots
> But despite wracking my brain, the
> only thing I can think of is to load the readme at runtime from a
> separate file, which is exactly what I want to avoid.
if you want exactly to avoid this, then you can add a resource file
to your application and compile the readme text into the resource
file, then compile your application with the resource file and access
the resource files data within your binary with the windows resource
functions.
http://msdn.microsoft.com/en-us/library/aa380599%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms632583%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms674841%28VS.85%29.aspx
Regards
Kerem
--
-----------------------
Beste Gr�sse / Best regards / Votre bien devoue
Kerem G�mr�kc�
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
In that case I'd look into having the "file" as a resource. The
following may help point you in the right direction:
http://www.codeproject.com/KB/cpp/usingtextfile_resources.aspx
Dave
Depending on how long the text is you could just have it as a string
resource as well. I think you can have several K of text in a single
string.
Tom
"Scoots" <linki...@msn.com> wrote in message
news:12f4d859-221e-4dfe...@a31g2000yqn.googlegroups.com...
"A Rich Edit Control That Displays Bitmaps and Other OLE Objects" at
http://www.codeproject.com/KB/edit/COleRichEditCtrl.aspx
As suggested by others above, the actual text is contained in a
resource file that's compiled into the program, not a separate file
that must be distributed to the end user.
In your resource file, go to the option to manually edit the resource file and add the
line:
1 README "readme.txt"
DO NOT just hand-edit this into your resource file; it won't work. Alternatively, place
it in your .rc2 file, which you CAN hand-edit.
Then do, in your OnInitDialog handler:
HRSRC readrsrc = ::FindResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(1), _T("README"));
if(readrsrc == NULL)
... deal with error
HGLOBAL readglbl = ::LoadResource(AfxGetInstanceHandle(), readrsrc);
if(readglbl == NULL)
... deal with error
char * readme = ::LockResource(readglbl);
LPSTR readme = ::LockResource(readglbl);
your choice of type, but *NOT* LPTSTR!
Note that while most resources are stored as Unicode, user-defined resources defined by a
file are stored as bitwise copies of the contents of the file, so if it was an ANSI file
(the usual case) the resource is ANSI (8-bit characters).
(or
LPWSTR readme = ::LockResource(readglbl);
if the resource is a Unicode text file)
if(readme == NULL)
... deal with error
If your app is Unicode, you can then do
CString ReadMeStr(readme);
which will accept either a char */LPSTR or LPWSTR and make sure the string is a Unicode
string.
c_ReadMeText.SetWindowText(ReadMeStr);
The text of the file appears in the control c_ReadMeText.
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
-JJ
"Joseph M. Newcomer" <newc...@flounder.com> wrote in message
news:d2djf5pp5scscop0f...@4ax.com...