Solved

Columns in output?

Posted on 2004-04-22
3
267 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

705 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

21 Experts available now in Live!

Get 1:1 Help Now