Re: Pass command line file name parameter
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Tue, 01 Aug 2006 10:05:02 -0400
But that doesn't require that the document or view get the file name. For example, if a
filename appears on the command line, you would do an OpenDocument in the CWinApp class,
passing in that name. Then the document class has a copy of the filename, which is what
it would provide. No need to access the original command line at all.
It sounds more like a dialog-based app would be better for this, in which case you can
access the __ARGC and __ARGV global structures and set the filename in the dialog class
before you call the DoModal in the app class. Note that you don't need a view unless you
want the user to see all the labels as they would be printed. When I took an old console
app I'd done to support one of our mailing lists and converted it to Windows, I did it as
a dialog-based app and retained nearly all of the original code. However, I didn't use a
filename on the command line, I just had an "open" button that opened the file. In my
case, it was complicated by the fact that we had a special label printer and I had to then
open LPT and send the actual control bytes out to the printer to format the labels
properly.
(I tried to find my address-label-printing program, but it has apparently been lost in
some upgrade of hardware)
joe
On Mon, 31 Jul 2006 15:50:01 -0700, ybc <ybc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hi Joe,Joseph M. Newcomer [MVP]
You?re right. I?m trying to convert an existing Unix C program to a Windows
program for our client. They want the program opens the input file name
passed as parameter in command line, format and display and print the labels.
I try two ways of doing that ? a console application to format and display
and print the file; and a document/view framework to do the job.
I?m not good with VC++, so helps are needed from everyone.
Thanks again,
ybc
"Joseph M. Newcomer" wrote:
I don't suppose it occurred to you to include the lines of code that generated these
errors? What, exactly, are we supposed to deduce from two error messages?
Note, by the way, that there is no sane way a document or view should ever be accessing a
filename or any other variable of your CWinApp class. This suggests there are very
serious flaws in your program structure if you think this is going to make sense.
Repeat this mantra "Object oriented programming is done in C++. C++ is not C". Don't
carry bad programming habits from C into C++. Take this as a good heuristic: if you need
to access a member of your CWinApp class from outside your CWinApp class, you've made a
design error. This will be correct so often that the exceptions will become obvious.
joe
On Sun, 30 Jul 2006 19:29:02 -0700, ybc <ybc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hi,Joseph M. Newcomer [MVP]
I have an application with classes Myapp, MyappDoc and MyappView. The input
filename from command line's parameter is stored as public variable sFilename
in Myapp.h which is included in MyappDoc.cpp and MyappView.cpp.
There're compiling errors:
MyappDoc.cpp : error C2065: 'sFilename' : undeclared identifier
MyappView.cpp : error C2065: 'sFilename' : undeclared identifier
Why?
If the input filename from command line's parameter is stored as public
variable in MyappDoc.h, how to access it from Myapp.cpp?
Thanks,
ybc
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Re: Pass command line file name parameter
- From: Joseph M . Newcomer
- Re: Pass command line file name parameter
- Prev by Date: Re: class-diagram-like editor - what and how?
- Next by Date: How to access password protected shared network drives while traversing the dialog created by using SHBrowseForFolder()
- Previous by thread: Re: Pass command line file name parameter
- Next by thread: Re: Pass command line file name parameter
- Index(es):