Solved

Columns in output?

Posted on 2004-04-22
3
270 Views
Last Modified: 2013-11-20
Howdy,
I'm using MFC with VC++ 6 for a personal project and just to dabble in something new.
I have a few questions though.  The first is a more general C/C++ question, not necassarily MFC.

Is it possible (surely it is) to get columns to line up when printing out strings to a file?
A simple solution i'm thinking is using a fixed width font, but how would i do that?

The information i'm printing out is a copy of dialog box that i have broken up into columns.
I want to keep this information as well as print it out, and my solution was to put it to a text file, then just manually print the text file.
Would it be easier to just send the dialog box to the printer?  If so how would i do that?

Thanks,
Jason
0
Comment
Question by:solman66
3 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 10896355
>> Is it possible (surely it is) to get columns to line up when printing out strings to a file?
A simple solution i'm thinking is using a fixed width font, but how would i do that?

Printing to file? Do you mean text file? In this case font doesn't matter, use tabs to align columns.
0
 
LVL 14

Accepted Solution

by:
wayside earned 125 total points
ID: 10901360
The thing I don't like about tabs is that you are now making assumptions about the tab settings of whatever device you are printing to or whatever program you are using to view the text file. If you guess wrong, your columns may no longer appear lined up. (This is one of the primary reasons I never ever use tabs in my code, I have VC++ convert tabs to spaces; in fact our company coding standards prohibit tab characters.)

So I would would pad each column entry with however many spaces is needed to make the columns line up. Of course, if your printer doesn't use a fixed width font to print text files, this approach won't work.

There's no framework support for printing dialogs, so I think your approach of writing the info to a file and printing the file is reasonable.
0
 
LVL 2

Author Comment

by:solman66
ID: 10906072
Hey, thanks for the replies.

I hate that about tabs as well.  I was just putting the information in a textfile and it defaults to open with notepad, but for future compatibility i decided tabs won't work too well.

I had also padded the spaces out, but i don't like having to use a fixed width font, its not usually a default font.

Anyway thanks for the advice,  I decided instead to throw the output into a simple html file with tables.  Its very clean and prints nicely.  It also allows me to seperate things much nicer.

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 54
sum67 challenge 35 97
Updating statistics with error notification email in SQL server 4 94
Is there a simple front-end menu system. 9 88
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now