Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Columns in output?

Posted on 2004-04-22
3
Medium Priority
?
276 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 375 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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…
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

719 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