File: PROTOCOL\TProtocolManagePrintDlg.cpp
1 //******************************************************************************
2 //Datei : TProtocolManagePrintDlg.cpp
3 //Projekt : XCTL
4 //Subsystem : Protokollbuch
5 //Autor : Jens Klier <klier@informatik.hu-berlin.de>
6 // Institut fuer Informatik,
7 // Humboldt-Universitaet Berlin
8 //Inhalt : Implementation der Klasse TProtocolManagePrintDlg
9 //******************************************************************************
10 //!neu klier Protokollbuch
11 #include "internls\evrythng.h"
12 #include "winresrc\rc_prtow.h" // Ressourcen-IDs
13 #include <commdlg.h>
14 #include <commctrl.h>
15
16 #include "protocol\TProtocolLanguage.h"
17 #include "protocol\TProtocol.h"
18 #include "protocol\TProtocolDlg.h"
19 #include "protocol\TProtocolParameterDlg.h"
20 #include "protocol\TProtocolManagePrintDlg.h"
21
22 //--||--\\--||--//--||--\\--||--//--||--\\--||--//--||--\\--||--//--||--\\--||--
23
24 extern TProtocolLanguage *ProtocolLanguage;
25
26 TProtocolManagePrintDlg::TProtocolManagePrintDlg(int Feldelemente, int x, int y) : Felder(Feldelemente),
27 PrintX(x), PrintY(y), bDelete(FALSE), bSearchActiv(FALSE)
28 {}
29 ;
30
31 void TProtocolManagePrintDlg::EnableButton( BOOL Status )
32 {
33 EnableWindow( GetDlgItem(hwndDlg, IDSEARCH), Status);
34 EnableWindow( GetDlgItem(hwndDlg, IDVIEW), Status);
35 if (!Protocol->IsProtocolOn())
36 {
37 EnableWindow( GetDlgItem(hwndDlg, IDDELETE), Status);
38 EnableWindow( GetDlgItem(hwndDlg, IDIMPORT), Status);
39 EnableWindow( GetDlgItem(hwndDlg, IDPRINT), Status);
40 EnableWindow( GetDlgItem(hwndDlg, id_Parameter), Status);
41 }
42 };
43
44 void TProtocolManagePrintDlg::SearchNew( )
45 {
46 if (bSearchActiv)
47 SendMessage(hwndDlg, WM_COMMAND, IDSEARCH, 0);
48 };
49
50
51 BOOL TProtocolManagePrintDlg::PListView_InsertColumn(HWND hLVCtrl, int iCol, LPCSTR ColText)
52 {
53 LV_COLUMN lvc;
54 char buf[MaxString];
55
56 // Initialize the LV_COLUMN structure.
57 lvc.mask= LVCF_TEXT | LVCF_FMT;
58 lvc.fmt= LVCFMT_LEFT;
59 lvc.pszText= buf;
60
61 // Add the columns.
62 lvc.iSubItem= iCol;
63 strcpy(buf, ColText);
64 lvc.cx=ListView_GetStringWidth(hLVCtrl,buf);
65 if (ListView_InsertColumn(hLVCtrl, iCol, &lvc) == -1)
66 return FALSE;
67
68 ListView_SetColumnWidth(hLVCtrl,iCol,LVSCW_AUTOSIZE_USEHEADER);
69
70 return TRUE;
71 };
72
73 void TProtocolManagePrintDlg::PListView_InsertItem(HWND hLVCtrl, int iIndex, LPCSTR ItemText)
74 {
75 char buf[MaxString];
76 int iCol=0,cx;
77 LVITEM pitem;
78
79 pitem.iItem= iIndex;
80 pitem.iSubItem= 0;
81 pitem.mask= LVIF_TEXT;
82 pitem.state= LVIS_FOCUSED;
83 pitem.stateMask= NULL;
84 pitem.cchTextMax= MaxString;
85 pitem.iImage= NULL;
86 pitem.lParam= NULL;
87 pitem.iIndent= 1;
88 pitem.pszText= buf;
89
90 strcpy(buf, ItemText);
91 ListView_InsertItem(hLVCtrl, &pitem);
92
93 if( ListView_GetColumnWidth(hLVCtrl,0) <
94 (cx=(ListView_GetStringWidth(hLVCtrl,buf)+15)) )
95 ListView_SetColumnWidth(hLVCtrl,0,cx);
96 };
97
98 void TProtocolManagePrintDlg::PListView_SetItemText(HWND hLVCtrl, int iIndex, int iCol, LPSTR ItemText)
99 {
100 int cx;
101
102 ListView_SetItemText(hLVCtrl, iIndex, iCol, ItemText);
103
104 if( ListView_GetColumnWidth(hLVCtrl,iCol) <
105 (cx=(ListView_GetStringWidth(hLVCtrl,ItemText)+15)) )
106 ListView_SetColumnWidth(hLVCtrl,iCol,cx);
107 };
108
109 BOOL TProtocolManagePrintDlg::Dlg_OnInit(HWND hwnd, HWND hwndCtl, LPARAM lParam)
110 {
111 ProtocolDlg->InitializeManagePrintDlg(this);
112 hwndDlg= hwnd;
113 hSuchList= GetDlgItem( hwnd, id_SuchList );
114 if (Protocol->IsProtocolOn())
115 {
116 EnableWindow( GetDlgItem(hwndDlg, IDDELETE), DISABLE);
117 EnableWindow( GetDlgItem(hwndDlg, IDIMPORT), DISABLE);
118 EnableWindow( GetDlgItem(hwndDlg, IDPRINT), DISABLE);
119 EnableWindow( GetDlgItem(hwndDlg, id_Parameter), DISABLE);
120 }
121 return TRUE;
122 };
123
124 void TProtocolManagePrintDlg::Dlg_OnNotify(HWND hwnd, int message, UINT id, UINT wParam)
125 {
126 char buf[MaxLine], buf2[MaxString];
127 int SelCount;
128
129 if ( message!=WM_NOTIFY || id!=id_SuchList ) return;
130
131 if ( (SelCount= ListView_GetSelectedCount(hSuchList)) > 0 )
132 {
133 strcpy(buf, itoa(SelCount, buf2, 10));
134 if (SelCount != 1)
135 strcat(buf, ProtocolLanguage->GetMessage(42));
136 else
137 strcat(buf, ProtocolLanguage->GetMessage(43));
138 strcat(buf, itoa(GetPages(SelCount), buf2, 10));
139 strcat(buf, ProtocolLanguage->GetMessage(44));
140 SetDlgItemText(hwnd, id_PrnStatusLine, buf);
141 }
142 };
143
144 BOOL TProtocolManagePrintDlg::Dlg_OnCommand(HWND hwnd, int id, UINT codeNotify)
145 {
146 char buf[MaxLine], buf2[MaxString], lLfdNr[MaxString], tmpLfdNr[MaxString];
147 TSearchDate lDatum;
148 TSearchParameter lParameter;
149 int Count, SelCount, i;
150 BOOL bTest, bIsDelete;
151 TModalDlg *dlg= 0;
152
153 bTest= TRUE;
154 switch (id)
155 {
156 case IDSEARCH:
157 bSearchActiv= TRUE;
158 GetDlgItemText(hwnd, id_PrnDatum1, lDatum[0], MaxString);
159 if ((strlen(lDatum[0]) > 0) && !Protocol->TestDate(lDatum[0]))
160 {
161 SetDlgItemText(hwnd, id_PrnStatusLine,
162 ProtocolLanguage->GetMessage(58));
163 MessageBox(GetFocus(), ProtocolLanguage->GetMessage(58),
164 ProtocolLanguage->GetFailure(), MBFAILURE);
165 SetFocus(GetDlgItem(hwnd, id_PrnDatum1));
166 break;
167 }
168 GetDlgItemText(hwnd, id_PrnDatum2, lDatum[1], MaxString);
169 if ((strlen(lDatum[1]) > 0) && !Protocol->TestDate(lDatum[1]))
170 {
171 SetDlgItemText(hwnd, id_PrnStatusLine,
172 ProtocolLanguage->GetMessage(58));
173 MessageBox(GetFocus(), ProtocolLanguage->GetMessage(58),
174 ProtocolLanguage->GetFailure(), MBFAILURE);
175 SetFocus(GetDlgItem(hwnd, id_PrnDatum2));
176 break;
177 }
178 SetDlgItemText(hwnd, id_PrnStatusLine, "");
179 ListView_DeleteAllItems(hSuchList);
180 GetDlgItemText_LfdNr(hwnd, lLfdNr);
181 strcpy(tmpLfdNr, Protocol->GetLfdNr(buf));
182 if (Protocol->InitializeSearchProtocolString(lLfdNr))
183 {
184 GetDlgItemText_SearchParameter( hwnd, lParameter );
185 Count= 0;
186 while (SearchProtocolString( lLfdNr, lDatum, lParameter ))
187 {
188 if ( bDelete == Protocol->IsProtocolDelete() )
189 {
190 strcpy(buf, itoa(++Count, buf2, 10));
191 if (Count != 1)
192 strcat(buf, ProtocolLanguage->GetMessage(59));
193 else
194 strcat(buf, ProtocolLanguage->GetMessage(60));
195 SetDlgItemText(hwnd, id_PrnStatusLine, buf);
196
197 MakeListString(Count-1);
198 }
199 }
200 }
201 if ( (Count= ListView_GetItemCount(hSuchList)) == 0 )
202 {
203 SetDlgItemText(hwnd, id_PrnStatusLine,
204 ProtocolLanguage->GetMessage(61));
205 }
206 else
207 {
208 strcpy(buf, itoa(Count, buf2, 10));
209 if (Count != 1)
210 strcat(buf, ProtocolLanguage->GetMessage(59));
211 else
212 strcat(buf, ProtocolLanguage->GetMessage(60));
213 SetDlgItemText(hwnd, id_PrnStatusLine, buf);
214 }
215 Protocol->ReloadProtocolString(tmpLfdNr);
216 break;
217
218 case IDVIEW:
219 if ( (Count= ListView_GetItemCount(hSuchList)) > 0 )
220 {
221 if ( (SelCount= ListView_GetSelectedCount(hSuchList)) > 0 )
222 {
223 if (ProtocolDlg->TestChangeDlg())
224 break;
225 SetDlgItemText(hwnd, id_PrnStatusLine, "");
226 SelCount=ListView_GetNextItem(hSuchList,-1,LVIS_SELECTED);
227 ProtocolDlg->ShowLfdNr(GetSelLfdNr(lLfdNr, SelCount));
228 }
229 else
230 SetDlgItemText(hwnd, id_PrnStatusLine,
231 ProtocolLanguage->GetMessage(45));
232 }
233 break;
234
235 case IDPRINT:
236 if ( (Count= ListView_GetItemCount(hSuchList)) > 0 )
237 {
238 if ( (SelCount= ListView_GetSelectedCount(hSuchList)) > 0 )
239 {
240 PrintSelection(hwnd, SelCount, GetColumn());
241 }
242 else
243 {
244 ListBox_GetText(hSuchList, 0, buf);
245 strcpy(buf, ProtocolLanguage->GetMessage(30));
246 strcat(buf, itoa(Count, buf2, 10));
247 if (Count != 1)
248 strcat(buf, ProtocolLanguage->GetMessage(31));
249 else
250 strcat(buf, ProtocolLanguage->GetMessage(32));
251 strcat(buf, itoa(GetPages(Count), buf2, 10));
252 strcat(buf, ProtocolLanguage->GetMessage(33));
253 if (MessageBox(GetFocus(), buf,
254 ProtocolLanguage->GetQuestion(), MBASK) == IDYES)
255 {
256 for(i=0; i<Count; i++)
257 ListView_SetItemState(hSuchList,i,LVIS_SELECTED,LVIS_SELECTED);
258 PrintSelection(hwnd, Count, GetColumn());
259 }
260 }
261 SetDlgItemText(hwnd, id_PrnStatusLine, "");
262 }
263 break;
264
265 case id_Parameter:
266 if (!ProtocolDlg->GetPasswort(hwnd))
267 break;
268 dlg= (TProtocolParameterDlg *)new TProtocolParameterDlg("ProtocolParameterDlg", Protocol, ProtocolDlg, this);
269 if ( dlg ) dlg->ExecuteDialog(hwnd);
270 _FREEOBJ(dlg);
271 SetFocus(hwnd);
272 break;
273
274 case IDIMPORT:
275 if (!ProtocolDlg->GetPasswort(hwnd))
276 break;
277 SetDlgItemText(hwnd, id_PrnStatusLine, ProtocolLanguage->GetMessage(46));
278 if (Protocol->ImportProtocolFile())
279 SetDlgItemText(hwnd, id_PrnStatusLine,
280 ProtocolLanguage->GetMessage(47));
281 else
282 SetDlgItemText(hwnd, id_PrnStatusLine,
283 ProtocolLanguage->GetMessage(48));
284 break;
285
286 case id_Delete:
287 if (IsDlgButtonChecked(hwnd, id_Delete))
288 {
289 bDelete= TRUE;
290 SetDlgItemText(hwnd, IDDELETE, ProtocolLanguage->GetMessage(49));
291 }
292 else
293 {
294 bDelete= FALSE;
295 SetDlgItemText(hwnd, IDDELETE, ProtocolLanguage->GetMessage(50));
296 }
297 SearchNew();
298 break;
299
300 case IDDELETE:
301 bIsDelete= FALSE;
302 if ( (Count= ListView_GetItemCount(hSuchList)) > 0 )
303 {
304 if ( (SelCount= ListView_GetSelectedCount(hSuchList)) > 0 )
305 {
306 if (!ProtocolDlg->GetPasswort(hwnd))
307 break;
308 SetDlgItemText(hwnd, id_PrnStatusLine,
309 ProtocolLanguage->GetMessage(46));
310 strcpy(tmpLfdNr, Protocol->GetLfdNr(buf));
311 Count=-1;
312 for (i= 0; i < SelCount; i++)
313 {
314 Count=ListView_GetNextItem(hSuchList,Count,LVIS_SELECTED);
315 GetSelLfdNr(lLfdNr, Count);
316 if (strcmp(tmpLfdNr, lLfdNr) == 0)
317 bIsDelete= TRUE;
318 }
319 if (bIsDelete)
320 if (ProtocolDlg->TestChangeDlg())
321 break;
322 Count=-1;
323 for (i= 0; i < SelCount; i++)
324 {
325 Count=ListView_GetNextItem(hSuchList,Count,LVIS_SELECTED);
326 GetSelLfdNr(lLfdNr, Count);
327 if ( Protocol->LoadProtocolString(lLfdNr) == 0 )
328 if (!bDelete)
329 Protocol->SetProtocolDelete();
330 else
331 Protocol->SetProtocolReadOnly();
332 }
333 ProtocolDlg->ShowLfdNr(tmpLfdNr);
334 strcpy(buf, itoa(SelCount, buf2, 10));
335 if (!bDelete)
336 {
337 if (SelCount != 1)
338 strcat(buf, ProtocolLanguage->GetMessage(51));
339 else
340 strcat(buf, ProtocolLanguage->GetMessage(52));
341 }
342 else
343 {
344 if (SelCount != 1)
345 strcat(buf, ProtocolLanguage->GetMessage(53));
346 else
347 strcat(buf, ProtocolLanguage->GetMessage(54));
348 }
349 SetDlgItemText(hwnd, id_PrnStatusLine, buf);
350 SearchNew();
351 }
352 else
353 {
354 ListBox_GetText(hSuchList, 0, buf);
355 SetDlgItemText(hwnd, id_PrnStatusLine,
356 ProtocolLanguage->GetMessage(34));
357 MessageBox(GetFocus(), ProtocolLanguage->GetMessage(34),
358 ProtocolLanguage->GetWarning(), MBSTOP);
359 }
360 }
361 break;
362
363 default:
364 bTest= FALSE;
365 }
366 return bTest;
367 };
368
369 void TProtocolManagePrintDlg::AbortPrintSelection(HWND hwnd)
370 {
371 EnableWindow(hwnd, TRUE);
372 Protocol->ReloadProtocolString(tmpLfdNr);
373 };
374
375 BOOL TProtocolManagePrintDlg::PrintSelection(HWND hwnd, int SelCount, int IniSpalten)
376 {
377 char buf[MaxLine], PrintLfdNr[3][MaxString];
378 int i, k, Seite, Seiten, Count;
379
380 strcpy(tmpLfdNr, Protocol->GetLfdNr(buf));
381 Seite= 0;
382 if ((Spalten= IniSpalten) > 4)
383 Spalten= 4;
384 Seiten= SelCount / (Spalten - 1);
385 if (SelCount % (Spalten - 1) > 0)
386 Seiten++;
387 EnableWindow(hwnd, FALSE);
388 if (!InitializePrint(hwnd))
389 {
390 AbortPrintSelection(hwnd);
391 return FALSE;
392 }
393 for (k= 0; k < 3; k++)
394 strcpy(PrintLfdNr[k], "");
395 Count=-1;
396 for (i= 0; i < SelCount; i++)
397 {
398 Count=ListView_GetNextItem(hSuchList,Count,LVIS_SELECTED);
399 GetSelLfdNr(PrintLfdNr[i % (Spalten - 1)], Count);
400 if ( i % (Spalten - 1) == (Spalten - 2) )
401 {
402 sprintf(buf, "%s%d%s%d%s", ProtocolLanguage->GetMessage(55), ++Seite,
403 ProtocolLanguage->GetMessage(56), Seiten,
404 ProtocolLanguage->GetMessage(57));
405 SetDlgItemText(hwnd, id_PrnStatusLine, buf);
406 if (!Print(PrintLfdNr[0], PrintLfdNr[1], PrintLfdNr[2]))
407 {
408 AbortPrintSelection(hwnd);
409 return FALSE;
410 }
411 for (k= 0; k < 3; k++)
412 strcpy(PrintLfdNr[k], "");
413 }
414 }
415 if (SelCount % (Spalten - 1) > 0)
416 {
417 sprintf(buf, "%s%d%s%d%s", ProtocolLanguage->GetMessage(55), ++Seite,
418 ProtocolLanguage->GetMessage(56), Seiten,
419 ProtocolLanguage->GetMessage(57));
420 SetDlgItemText(hwnd, id_PrnStatusLine, buf);
421 }
422 if (!EndPrint(PrintLfdNr[0], PrintLfdNr[1], PrintLfdNr[2]))
423 {
424 AbortPrintSelection(hwnd);
425 return FALSE;
426 }
427 AbortPrintSelection(hwnd);
428 return TRUE;
429 };
430
431 void TProtocolManagePrintDlg::PrintError(LPCSTR Message)
432 {
433 AbortDoc(pd.hDC);
434 DeleteDC(pd.hDC);
435 MessageBox(GetFocus(), Message, ProtocolLanguage->GetFailure(), MBFAILURE);
436 };
437
438 BOOL TProtocolManagePrintDlg::InitializePrint(HWND hwnd)
439 {
440 SIZE size;
441
442 // Initialize the PRINTDLG members.
443 memset( &pd, '\0', sizeof(PRINTDLG) );
444 pd.lStructSize= sizeof(PRINTDLG);
445 pd.hDevMode= (HANDLE) NULL;
446 pd.hDevNames= (HANDLE) NULL;
447 pd.Flags= PD_RETURNDC;
448 pd.hwndOwner= hwnd;
449 pd.hDC= (HDC) NULL;
450 pd.nFromPage= 1;
451 pd.nToPage= 1;
452 pd.nMinPage= 0;
453 pd.nMaxPage= 0;
454 pd.nCopies= 1;
455 pd.hInstance= (HINSTANCE) NULL;
456 pd.lCustData= 0L;
457 pd.lpfnPrintHook= NULL;
458 pd.lpfnSetupHook= NULL;
459 pd.lpPrintTemplateName= (LPSTR) NULL;
460 pd.lpSetupTemplateName= (LPSTR) NULL;
461 pd.hPrintTemplate= (HANDLE) NULL;
462 pd.hSetupTemplate= (HANDLE) NULL;
463
464 // Display the PRINT dialog box.
465 if ( !PrintDlg(&pd) )
466 return FALSE;
467
468 if (!(GetDeviceCaps(pd.hDC, RASTERCAPS) & RC_BITBLT))
469 {
470 PrintError(ProtocolLanguage->GetMessage(35));
471 return FALSE;
472 }
473
474 // Initialize the members of a DOCINFO structure.
475 memset( &di, '\0', sizeof(DOCINFO) );
476 di.cbSize= sizeof(DOCINFO);
477 di.lpszDocName= "Protokollbuch";
478 di.lpszOutput= NULL;
479
480 Rect.top= Rect.left= 0;
481 Rect.right= PrintX;
482 Rect.bottom= PrintY;
483 xmax= GetDeviceCaps(pd.hDC, HORZRES);
484 ymax= GetDeviceCaps(pd.hDC, VERTRES);
485 if ( xmax <= 0 || ymax <= 0 )
486 {
487 PrintError(ProtocolLanguage->GetMessage(36));
488 return FALSE;
489 }
490 xmax--;
491 ymax--;
492 zoom= (xmax / 4) / Rect.right;
493 if (zoom == 0)
494 zoom= 1;
495 Rect.right= Rect.right * zoom;
496 Rect.bottom= Rect.bottom * zoom;
497
498 // Begin a print job by calling the StartDoc function.
499 if ( StartDoc(pd.hDC, &di) == SP_ERROR )
500 {
501 PrintError(ProtocolLanguage->GetMessage(37));
502 return FALSE;
503 }
504
505 GetTextExtentPoint(pd.hDC, "---- ", 5, &size);
506 xRand= size.cx;
507 xmax -= xRand;
508
509 return TRUE;
510 };
511
512 BOOL TProtocolManagePrintDlg::PrintNewPage( int &dy, int n)
513 {
514 if ( EndPage(pd.hDC) <= 0)
515 {
516 PrintError(ProtocolLanguage->GetMessage(38));
517 return FALSE;
518 }
519 if ( StartPage(pd.hDC) <= 0)
520 {
521 PrintError(ProtocolLanguage->GetMessage(39));
522 return FALSE;
523 }
524
525 TextOut(pd.hDC, 0, ymax / 2, "---- ", 5);
526
527 MoveToEx(pd.hDC, xRand, 0, NULL);
528 LineTo(pd.hDC, xRand, ymax);
529 LineTo(pd.hDC, xmax, ymax);
530 LineTo(pd.hDC, xmax, 0);
531 LineTo(pd.hDC, xRand, 0);
532
533 MoveToEx(pd.hDC, xRand - 1, 1, NULL);
534 LineTo(pd.hDC, xRand - 1, ymax);
535 LineTo(pd.hDC, xmax - 1, ymax - 1);
536 LineTo(pd.hDC, xmax - 1, 1);
537 LineTo(pd.hDC, xRand - 1, 1);
538
539 for (int k= 1; k <= n; k++)
540 {
541 MoveToEx(pd.hDC, ((xmax - xRand) / Spalten)*k + xRand - 1, 0, NULL);
542 LineTo(pd.hDC, ((xmax - xRand) / Spalten)*k + xRand - 1, ymax);
543 MoveToEx(pd.hDC, ((xmax - xRand) / Spalten)*k + xRand - 2, 0, NULL);
544 LineTo(pd.hDC, ((xmax - xRand) / Spalten)*k + xRand - 2, ymax);
545 }
546
547 dy= 0;
548
549 return TRUE;
550 };
551
552 BOOL TProtocolManagePrintDlg::EndPrint(LPCSTR lLfdNr1, LPCSTR lLfdNr2, LPCSTR lLfdNr3)
553 {
554 if (!Print(lLfdNr1, lLfdNr2, lLfdNr3))
555 return FALSE;
556
557 if ( EndDoc(pd.hDC) <= 0)
558 {
559 PrintError(ProtocolLanguage->GetMessage(40));
560 return FALSE;
561 }
562
563 // Delete the printer DC
564 DeleteDC(pd.hDC);
565
566 return TRUE;
567 };
568
569 BOOL TProtocolManagePrintDlg::Print(LPCSTR lLfdNr1, LPCSTR lLfdNr2, LPCSTR lLfdNr3)
570 {
571 char Parameter[MaxParameterString], ParameterValue[MaxParameterString];
572 char c, t[MaxString], kLfdNr[3][MaxLfdNr];
573 int i, k, l, m, x, y, dx, dy, tmpdy, dymax, n;
574 SIZE size;
575
576 n= 0;
577 if (strlen(lLfdNr1) != 0)
578 {
579 strcpy(kLfdNr[n++], lLfdNr1);
580 if (strlen(lLfdNr2) != 0)
581 {
582 strcpy(kLfdNr[n++], lLfdNr2);
583 if (strlen(lLfdNr3) != 0)
584 strcpy(kLfdNr[n++], lLfdNr3);
585 }
586 }
587 else
588 return TRUE;
589
590 if (Spalten < (n + 1))
591 Spalten= n + 1;
592
593 if ( StartPage(pd.hDC) <= 0)
594 {
595 PrintError(ProtocolLanguage->GetMessage(39));
596 return FALSE;
597 }
598
599 TextOut(pd.hDC, 0, ymax / 2, "---- ", 5);
600
601 MoveToEx(pd.hDC, xRand, 0, NULL);
602 LineTo(pd.hDC, xRand, ymax);
603 LineTo(pd.hDC, xmax, ymax);
604 LineTo(pd.hDC, xmax, 0);
605 LineTo(pd.hDC, xRand, 0);
606
607 MoveToEx(pd.hDC, xRand - 1, 1, NULL);
608 LineTo(pd.hDC, xRand - 1, ymax);
609 LineTo(pd.hDC, xmax - 1, ymax - 1);
610 LineTo(pd.hDC, xmax - 1, 1);
611 LineTo(pd.hDC, xRand - 1, 1);
612
613 for (k= 1; k <= n; k++)
614 {
615 MoveToEx(pd.hDC, ((xmax - xRand) / Spalten)*k + xRand - 1, 0, NULL);
616 LineTo(pd.hDC, ((xmax - xRand) / Spalten)*k + xRand - 1, ymax);
617 MoveToEx(pd.hDC, ((xmax - xRand) / Spalten)*k + xRand - 2, 0, NULL);
618 LineTo(pd.hDC, ((xmax - xRand) / Spalten)*k + xRand - 2, ymax);
619 }
620
621 dy= 0;
622 for (i= 0; i < Felder - 1; i++)
623 {
624
625 if (PrintSkizze(i))
626 {
627 strcpy(Parameter, "Lageskizze:");
628 TextOut(pd.hDC, xRand, dy, Parameter, strlen(Parameter));
629
630 for (k= 0; k < n; k++)
631 {
632 Protocol->LoadPicFile(kLfdNr[k]);
633 MoveToEx(pd.hDC, Rect.left + ((xmax - xRand) / Spalten)*(k + 1) + xRand, Rect.top + dy, NULL);
634 LineTo(pd.hDC, Rect.right + ((xmax - xRand) / Spalten)*(k + 1) + xRand, Rect.top + dy);
635 LineTo(pd.hDC, Rect.right + ((xmax - xRand) / Spalten)*(k + 1) + xRand, Rect.bottom + dy);
636 LineTo(pd.hDC, Rect.left + ((xmax - xRand) / Spalten)*(k + 1) + xRand, Rect.bottom + dy);
637 LineTo(pd.hDC, Rect.left + ((xmax - xRand) / Spalten)*(k + 1) + xRand, Rect.top + dy);
638 Protocol->ResetXY();
639 while (Protocol->GetXY( c, x, y, t ))
640 {
641 switch (c)
642 {
643 case 'M':
644 MoveToEx(pd.hDC, x*zoom + ((xmax - xRand) / Spalten)*(k + 1) + xRand, y*zoom + dy, NULL);
645 break;
646
647 case 'L':
648 LineTo(pd.hDC, x*zoom + ((xmax - xRand) / Spalten)*(k + 1) + xRand, y*zoom + dy);
649 break;
650
651 case 'T':
652 TextOut(pd.hDC, x*zoom + ((xmax - xRand) / Spalten)*(k + 1) + xRand, y*zoom + dy, t, strlen(t));
653 break;
654
655 default:
656 MessageBox(GetFocus(), ProtocolLanguage->GetMessage(23),
657 ProtocolLanguage->GetFailure(), MBFAILURE);
658 }
659 }
660 }
661 dy += Rect.bottom;
662 if (dy >= ymax)
663 if (!PrintNewPage(dy, n))
664 return FALSE;
665
666 dy++;
667 MoveToEx(pd.hDC, xRand, dy, NULL);
668 LineTo(pd.hDC, xmax, dy);
669 dy += 4;
670 }
671
672 if (dy >= ymax)
673 if (!PrintNewPage(dy, n))
674 return FALSE;
675 tmpdy= dy;
676 dymax= 0;
677 for (k= -1; k < n; k++)
678 {
679
680 if (k == -1)
681 GetParameterName(i, Parameter);
682 else if (!GetParameter(i, Parameter, kLfdNr[k]))
683 {
684 PrintError(ProtocolLanguage->GetMessage(41));
685 return FALSE;
686 }
687
688 dx= ((xmax - xRand) / Spalten) * (k + 1) + xRand;
689 GetTextExtentPoint(pd.hDC, Parameter, strlen(Parameter), &size);
690 while ( ((xmax - xRand) / Spalten) < size.cx )
691 {
692 strcpy(ParameterValue, Parameter);
693 strcpy(Parameter, "");
694 l= strlen(ParameterValue) - 1;
695 m= 0;
696 while ( (((xmax - xRand) / Spalten) < size.cx) && (l > 0) )
697 {
698 Parameter[m++]= ParameterValue[l];
699 Parameter[m]= ParameterValue[l--]= '\0';
700 GetTextExtentPoint(pd.hDC, ParameterValue, strlen(ParameterValue), &size);
701 if ( ( (strrchr(ParameterValue, ' ') != NULL) ||
702 (strrchr(ParameterValue, '-') != NULL) ) &&
703 (l > 0) && (Parameter[m - 1] != ' ') && (Parameter[m - 1] != '-') )
704 {
705 while ( (l > 0) && (ParameterValue[l] != ' ') &&
706 (ParameterValue[l] != '-') )
707 {
708 Parameter[m++]= ParameterValue[l];
709 Parameter[m]= ParameterValue[l--]= '\0';
710 }
711 GetTextExtentPoint(pd.hDC, ParameterValue, strlen(ParameterValue), &size);
712 }
713 }
714 strrev(Parameter);
715 TextOut(pd.hDC, dx, tmpdy, ParameterValue, strlen(ParameterValue));
716 tmpdy += size.cy;
717 GetTextExtentPoint(pd.hDC, Parameter, strlen(Parameter), &size);
718 }
719 TextOut(pd.hDC, dx, tmpdy, Parameter, strlen(Parameter));
720 tmpdy += size.cy;
721 if (dymax < tmpdy)
722 dymax= tmpdy;
723 tmpdy= dy;
724 }
725 dy= dymax;
726 if (dy >= ymax)
727 if (!PrintNewPage(dy, n))
728 return FALSE;
729
730 if ( i < (Felder - 2) )
731 {
732 MoveToEx(pd.hDC, xRand, dy, NULL);
733 LineTo(pd.hDC, xmax, dy);
734 dy += 2;
735 }
736 if ( PrintLine(i) )
737 {
738 MoveToEx(pd.hDC, xRand, dy + 1, NULL);
739 LineTo(pd.hDC, xmax, dy + 1);
740 dy++;
741 }
742 dy += 2;
743
744 if (dy >= ymax)
745 if (!PrintNewPage(dy, n))
746 return FALSE;
747 }
748 if ( EndPage(pd.hDC) <= 0)
749 {
750 PrintError(ProtocolLanguage->GetMessage(38));
751 return FALSE;
752 }
753 return TRUE;
754 };
755
756 // LastLine
757
758
759