Solved

Columns in output?

Posted on 2004-04-22
3
271 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
Login Script to Copy Folders 12 42
Get filename and folder into excel 7 79
unable to delete all specified values regedit 38 560
java ^ examples 8 69
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 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