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.
See SOURCE CODE links below.
#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); } }