Solved

Columns in output?

Posted on 2004-04-22
3
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

734 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