Month
Program Output Sample

Brief Information about the June 98 CSIG Meeting

VC++ Windows Envelop Printing by Bruce Arnold


Two months ago I presented a DOS program to address an envelope and print a bar code representing the zipcode. This month is the second of 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 printer, print preview, and finally printing. Other topics will include storing and retrieving data from the registry.

"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: The source code and executables will be available directly from the ACGNJ ftp server:

See SOURCE CODE links below.


Sample Code:


#define MAX_RET_LINES 5
char *name[] = {			// Registry names
		    "Return address line 1",
		    "Return address line 2",
		    "Return address line 3",
		    "Return address line 4",
		    "Return address line 5"	};


void CEnvView::PrintReturnAddress(CDC * pDC, int x, int y, int ht)
{
    CString s;	int i, line=0;	unsigned long sSize=100L;  char buff[100];
    long code;  HKEY handle; DWORD disposition, DataType;


    if (ERROR_SUCCESS== (code=RegCreateKeyEx(HKEY_CURRENT_USER,

	"Software\\Arnold\\Envelope",

	0, "REG_SZ", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
	NULL, &handle, &disposition))
	)
	
	{
	for (i=0; i<MAX_RET_LINES; i++)
	    {
	    code=RegQueryValueEx(handle, name[i], NULL, &DataType,
				    (unsigned char *)buff, &sSize);
	    s=buff;
	    pDC->TextOut(line*ht+x, y, s);
	    ++line;
	    sSize=100L;
	    }
	RegCloseKey(handle);
	}
}

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

SOURCE CODE

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