Program Output Sample

Brief Information about the May 98 CSIG Meeting

Windows Envelop Printing by Bruce Arnold

Last month I presented a DOS program to address an envelope and print a bar code representing the zipcode. This month begins a two part presentation of the same program converted into a Microsoft Visual C++, MFC, program. We will discuss program creation using the application generator, file input, graphic output to the screen, print preview, and finally printing.

Scott Murawski sent a C language "puzzle" concerning arrays. We will all try to solve the puzzle together during the "stdlib, etc." section of the meeting.

"Random Access" questions start at 7:30 Tuesday night. See you there.

You can get the source code and the executable programs from links on C User Group home page: The source code and executables are avialable directly from the ACGNJ ftp server:

See SOURCE CODE links below.

Leader: Bruce Arnold (b a r n o l d@b l a s t.n e t)

Summary by: Ron Murawski

User Group News

C/C++ User Group

The C/C++ User Group meets on the third Tuesday of every month. The May meeting began with a Random Access section where any computer-related comment is considered fair game. The Microsoft lawsuit and Apple's future plans were discussed. On a more technical level, the new Intel 440BX motherboard with a 100 MHz front-side bus was mentioned. A new, affordable internal PCI card K56-Flex V.90 modem from Diamond Multimedia was also mentioned.

The next part of the meeting was a puzzle of sorts. It was: "Why doesn't this code do what I want it to?". It was a short piece of code with some (subtlely) bad declarations and (subtlely) bad usage that compile without error using GCC (Gnu C Compiler). Visual inspection of the code by the members did not discover any errors. Bruce stated that the code would not compile using Microsoft Visual C++. Recent e-mail reveals that so far GCC is the only compiler that can successfully compile this code without error. Has the C/C++ User Group uncovered a latent bug in the Gnu C/C++ compiler?

The main presentation, by Bruce Arnold, was a continuation of last month's theme -- printing an envelope with a barcode conforming to US Postal regulations. This month's program, however, is written for Windows rather than for DOS. As a result, many new considerations had to be dealt with. The most pressing of these, of course, is the user interface.

Bruce used the Visual C++ compiler's built-in "Application Wizard" to write the template for his program. He chose a single-document interface with little else chosen except for "Printing and Print Preview". The skeleton program was then ready to be modified to achieve Bruce's purpose.

Most of Bruce's code enabled the on-screen display of the current envelope. Font sizes, landscape orientation and dynamic resizing of the displayed envelope to the current window's size were the biggest challenge.

This program will be continued in next month's meeting.

Sample Code:

CFont font1, font2;
CFont *oldfont = pDC->SelectObject(&font1);

if (pDC->IsPrinting())
    pDC->SetMapMode(MM_LOENGLISH);    // unit = 0.010 inch
    // Adjust the scale so that the envelope fits vertically on the screen
    pDC->SetWindowExt(910,-910);                  // logical envelope ht
    pDC->SetViewportExt(rect.bottom,rect.bottom); // physical window ht.

CString s;

s="Return Address 1";pDC->TextOut(                      +10,-890, s);
s="Return Address 2";pDC->TextOut(  logFont.lfHeight+10,-890, s);
s="Return Address 3";pDC->TextOut(2*logFont.lfHeight+10,-890, s);


p     = GetDocument()->m_pFileData;
count = GetDocument()->m_nDocLength;
for (line=i=0; i < count; i++)
    if (*p != '\r' && *p != '\n')
        s += *p++;
        if (!s.IsEmpty())
            pDC->TextOut(200+line*logFont.lfHeight, -600, s);
if (!s.IsEmpty()) pDC->TextOut(200+line*logFont.lfHeight,-600 , s);


"Random Access" questions start at 7:30 Tuesday night.


Source Code Files

For help, email me at b a r n o l d @ b l a s t . n e t
Back to C++ Main Page