1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
void
TPrevWindow::Paint(TDC& dc, bool erase, TRect& rect)
{
// declare variables for this function.
long int datecomponent,monthvar,dayvar,yearvar, pagevar;
int exta,a,b,f,r,t,ext1,ext2,ext3,ext4,ext44,MarkVar1,MarkVar2,ext5,ext6,ext7;
float linecounter;
char var[3],Date_[MAXDAT],var2[5];
char Idate[MAXDAT],Ino[MAXINVNO],Inamt[MAXSELL],Idescr[MAXNOTE2],Icomp[MAXCOMPANY2];
char Indescr[MAXNOTE2],Indisc[MAXSELL],Inpay[MAXSELL],Idr[MAXSELL],Ie_desc[MAXNOTE];
char Ivalue[MAXSELL2],Icr[MAXSELL],Ibal[MAXSELL],Ivend[MAXCOMPANY2],Icode[MAXCCODE];
char Ipd[MAXDAT],Iinv[MAXDAT],Icrx[13],Ibalx[13],Idrx[13];
struct dosdate_t d;
ldiv_t n;
TSize extent;
// take the current page number of the print preview and
// convert to chars to be stored in the char array “var2”.
Pagevar = PageCount;
for(a=0; a<5; a++) var2[a] = 32;
var2[4] = 48;
b=4;
do {
n = ldiv(pagevar,10L);
pagevar = n.quot;
if(n.rem==0) var2[b] = 48;
if(n.rem==1) var2[b] = 49;
if(n.rem==2) var2[b] = 50;
if(n.rem==3) var2[b] = 51;
if(n.rem==4) var2[b] = 52;
if(n.rem==5) var2[b] = 53;
if(n.rem==6) var2[b] = 54;
if(n.rem==7) var2[b] = 55;
if(n.rem==8) var2[b] = 56;
if(n.rem==9) var2[b] = 57;
b--;
} while(pagevar > 0);
var2[5]=0;
// take the current date components month, day and year and
// convert to chars to be stored in the char array “Date_”.
_dos_getdate(&d);
monthvar = d.month;
dayvar = d.day;
yearvar = d.year;
// take the current date components month, day and year and
// convert to chars to be stored in the char array “Date_”.
for(a=0; a<MAXDAT; a++) Date_[a] = 32;
Date_[2] = 47;
Date_[5] = 47;
t=0;
do {
if(t == 0) datecomponent = monthvar;
if(t == 1) datecomponent = dayvar;
if(t == 2) {
datecomponent = yearvar;
// y2k adjustment.
if (datecomponent < 2000 )
datecomponent = datecomponent - 1900;
else
datecomponent = datecomponent - 2000;
}
var[0] = 48;
var[1] = 48;
var[2] = 32;
b=1;
do {
n=ldiv(datecomponent,10L);
datecomponent =n.quot;
if(n.rem==0) var[b] = 48;
if(n.rem==1) var[b] = 49;
if(n.rem==2) var[b] = 50;
if(n.rem==3) var[b] = 51;
if(n.rem==4) var[b] = 52;
if(n.rem==5) var[b] = 53;
if(n.rem==6) var[b] = 54;
if(n.rem==7) var[b] = 55;
if(n.rem==8) var[b] = 56;
if(n.rem==9) var[b] = 57;
b--;
} while(datecomponent > 0);
if(t==0) for(a=0; a<2; a++) Date_[a] = var[a];
if(t==1) for(a=0; a<2; a++) Date_[3+a] = var[a];
if(t==2) for(a=0; a<2; a++) Date_[6+a] = var[a];
t++;
} while(t < 3);
Date_[MAXDAT-1] = 0;
// set the print preview to scale 100 logical units per
// inch of screen width. set the mapping mode to “MM_LOENGLISH”
// and save the current device context.
const UnitsPerInch = 100;
dc.SaveDC();
dc.SetMapMode(MM_LOENGLISH);
int x1 = 0;
int y1 = 0;
// using a bold "Times New Roman" font, paint the heading
// and column labels of the print preview.
TFont fontBold2("Times New Roman", 20, 8, 0, 0, FW_BOLD);
dc.SelectObject(fontBold2);
dc.TextOut(x1 + ( 0.40 * UnitsPerInch ), y1 - ( 0.20 * UnitsPerInch ), "Page:", 5);
extent = dc.GetTextExtent("Page:", 5);
ext1 = extent.cx;
dc.TextOut(x1 + ( 0.40 * UnitsPerInch ), y1 - ( 0.40 * UnitsPerInch ), "Date:", 5);
extent = dc.GetTextExtent("Date:", 5);
ext2 = extent.cx;
dc.TextOut(x1 + ( 5.65 * UnitsPerInch ), y1 - ( 0.20 * UnitsPerInch ), "Acme Company", 12);
dc.TextOut(x1 + ( 5.65 * UnitsPerInch ), y1 - ( 0.40 * UnitsPerInch ), "123 Acme Blvd.", 14);
dc.TextOut(x1 + ( 5.65 * UnitsPerInch ), y1 - ( 0.60 * UnitsPerInch ), "Anywhere, Anystate 44444", 24);
dc.TextOut(x1 + ( 2.55 * UnitsPerInch ), y1 - ( 0.85 * UnitsPerInch ), "Reconciliation", 14);
dc.TextOut(x1 + ( 0.15 * UnitsPerInch ), y1 - ( 1.15 * UnitsPerInch ), "Starting Balance", 16);
dc.TextOut(x1 + ( 1.75 * UnitsPerInch ), y1 - ( 1.15 * UnitsPerInch ), "Deposits", 8);
dc.TextOut(x1 + ( 3.00 * UnitsPerInch ), y1 - ( 1.15 * UnitsPerInch ), "Checks/Withdrawals", 18);
dc.TextOut(x1 + ( 6.00 * UnitsPerInch ), y1 - ( 1.15 * UnitsPerInch ), "Ending Balance", 14);
// using a normal "Times New Roman" font, paint the extracted
// check register data previously stored in the 2 2-dimensional
// char arrays “Xvault2_” and “Xvault4_”.
TFont fontNorm2("Courier", 20, 8, 0, 0, FW_NORMAL);
dc.SelectObject(fontNorm2);
linecounter = 1.35;
f = 0;
MarkVar1 = 0;
MarkVar2 = 0;
do {
for(r=0; r<MAXSELL-1; r++) Idr[r] = Xvault2_[r][f];
for(r=0; r<MAXSELL-1; r++) Icr[r] = Xvault4_[r][f];
for(r=0; r<MAXSELL; r++) {
if(Sellvarq_[r] < 33 || Sellvarq_[r] > 126) Sellvarq_[r] = 32;
if(Idr[r] < 33 || Idr[r] > 126) Idr[r] = 32;
if(Icr[r] < 33 || Icr[r] > 126) Icr[r] = 32;
if(totpay[r] < 33 || totpay[r] > 126) totpay[r] = 32;
}
Sellvarq_[MAXSELL-1] = 0;
Idr[MAXSELL-1] = 0;
Icr[MAXSELL-1] = 0;
totpay[MAXSELL-1] = 0;
if ( PageCount == 1 && MarkVar1 == 0 ) {
dc.TextOut(x1 + ( 0.15 * UnitsPerInch ), y1 - ( rr * UnitsPerInch ), Sellvarq_, MAXSELL-1);
MarkVar1 = 1;
}
dc.TextOut(x1 + ( 1.75 * UnitsPerInch ), y1 - ( rr * UnitsPerInch ), Idr, MAXSELL-1);
dc.TextOut(x1 + ( 3.00 * UnitsPerInch ), y1 - ( rr * UnitsPerInch ), Icr, MAXSELL-1);
if ( PageCount == mPage2 && MarkVar2 == 0 && Xvault4_[MAXSELL-2][f+1] == 32 ) {
dc.TextOut(x1 + ( 6.00 * UnitsPerInch ), y1 - ( rr * UnitsPerInch ), totpay, MAXSELL-1);
MarkVar2 = 1;
}
linecounter = linecounter + 0.20;
f++;
} while(f < 50);
var2[5] = 0;
dc.TextOut(x1 + ( 0.46 * UnitsPerInch ) + ext1, y1 - ( 0.20 * UnitsPerInch ), var2, 5);
Date_[MAXDAT-1] = 0;
dc.TextOut(x1 + ( 0.46 * UnitsPerInch ) + ext2, y1 - ( 0.40 * UnitsPerInch ), Date_, MAXDAT-1);
dc.RestoreObjects();
}
| |