home *** CD-ROM | disk | FTP | other *** search
- {Program Listing Express - Program Copyright (C) Doug Overmyer 9/2/91}
- {Begun 8/2/91}
- {1.1 9/15/91 change BN5, add sculpted static text fields }
- {1.2 9/23/91 revise printer method to eliminate double spacing of over-wide
- lines;force enumeration and reselection of font after running control panel;
- explicitly dispose of Faces collection; better redraw of PSText objects}
- {1.3 10/5/91 avoid integer overflow on large margins, add change printer menu
- item & button to printer dialog 10/1/91 Rework Font enumeration entirely,
- move to Fonts unit, preload font size list box & hilite, add support for
- bold & italic text, header & footer lines ; consolidate TPrinter subclasses into
- printer1 unit;10/12/91 correct the file read logic to get last record of file w/o CRLF;
- rework tab expand logic to move to tab columns rather than insert n spaces}
-
- program PLXpress;
-
- {$S-}
- {$R plx.RES}
- {$R-}
- uses WinTypes,WinProcs,Strings,WObjects,WOPlus,WFPlus,
- Printer1,StdDlgs,Fonts;
-
- const
- cm_FOpen = 101; {menuitem FileOpen }
- cm_FPrint = 102; {menuitem FilePrint }
- cm_FSetUp = 103; {menuitem FilePageSetup}
- cm_FExit = 104; {menuitem FileExit }
- cm_FChgPrt = 105; {menuitem FileChangePrinter}
- cm_TFont = 111; {menuitem TextFont }
- id_But1 = 201; {User defined button 1 iconbar}
- id_But2 = 202; { " 2 iconbar}
- id_But3 = 203; { " 3 iconbar}
- id_But4 = 204; { " 3 iconbar}
- id_But5 = 205; { " 5 iconbar}
- id_D1Lb1 = 301; {List box element in Dlg1}
- id_St1 = 401; {Static text 1 icon bar}
- id_St2 = 402; {Static text 2 icon bar}
- id_D3Setup = 501; {Setup button in Dlg3}
- id_D3Change= 502; {Change button in Dlg3}
- id_D3OKPrt = 521; {OK button in Dlg3 }
- id_D2OK = 601; {OK button in Dlg2 }
- id_D2EC1 = 603; {Edit Control 1 in Dlg2 Margin.left}
- id_D2EC2 = 605; { 2 Margin.right}
- id_D2EC3 = 607; { 3 Margin.top}
- id_D2EC4 = 609; { 4 Margin.bottom}
- id_D2EC5 = 617; { 5 tabsize}
- id_D2EC6 = 621; { 6 Header text}
- id_D2EC7 = 622; { 7 Footer Text}
- id_D2CB1 = 612; {Check box 1 in Dlg2 Format.ShowRuler}
- id_D2CB2 = 613; {Check box 2 in Dlg2 Format.ShowFName}
- id_D2CB3 = 614; {Check box 3 in Dlg2 Format.ShowDTStamp}
- id_D2CB4 = 615; {Check box 4 in Dlg2 Format.ShowPageNum}
- id_D2CB5 = 619; {Check box 5 in Dlg2 Format.ShowLineNum}
- id_D2CB6 = 620; {Check box 6 in dlg2 format.UseCCB}
- id_D4LB1 = 701; {List box1 in Dlg4 font names}
- id_D4LB2 = 702; {List box2 in Dlg4 font sizes}
- id_D4RB1 = 705; {radio button 1 in Dlg4} {font style normal}
- id_D4RB2 = 706; {radio button 2 in Dlg4} {bold}
- id_D4RB3 = 707; {radio button 3 in Dlg4} {italic}
- idm_About = 801; {menu id for PLX_About menu}
- idm_RunCP = 802; {menu id for run control panel}
- um_FilePrint = 803; {User defined message }
- {******************************************************************}
- { Types }
- {******************************************************************}
-
- type
- TPLXApplication = object(TApplication)
- procedure InitMainWindow;virtual;
- end;
-
- type
- FormatRec = record
- ShowRuler,ShowFName,ShowDTStamp,ShowPageNum,ShowLineNum,UseCCB:Integer;
- Header,Footer:Array[0..132] of Char;
- end;
-
- type
- pFontStyleRec = ^FontStyleRec;
- FontStyleRec = record
- Normal,Bold,Italic:Integer;
- end;
-
- PPLXDlg2 = ^TPLXDlg2;
- TPLXDlg2 = object(TDialog) {Page setup dialog}
- Margins:TRect;
- Format:FormatRec;
- TabSize:Integer;
- procedure WMInitDialog(var Msg:TMessage);virtual wm_First+wm_InitDialog;
- procedure IDD2OK(var Msg:TMessage); virtual id_First+id_D2OK;
- procedure IDD2EC1(var Msg:TMessage);virtual id_First+id_D2EC1;
- procedure IDD2EC2(var Msg:TMessage);virtual id_First+id_D2EC2;
- procedure IDD2EC3(var Msg:TMessage);virtual id_First+id_D2EC3;
- procedure IDD2EC4(var Msg:TMessage);virtual id_First+id_D2EC4;
- procedure IDD2EC5(var Msg:TMessage);virtual id_First+id_D2EC5;
- procedure IDD2EC6(var Msg:TMessage);virtual id_First+id_D2EC6;
- procedure IDD2EC7(var Msg:TMessage);virtual id_First+id_D2EC7;
- procedure IDD2CB1(var Msg:TMessage);virtual id_First+id_D2CB1;
- procedure IDD2CB2(var Msg:TMessage);virtual id_First+id_D2CB2;
- procedure IDD2CB3(var Msg:TMessage);virtual id_First+id_D2CB3;
- procedure IDD2CB4(var Msg:TMessage);virtual id_First+id_D2CB4;
- procedure IDD2CB5(var Msg:TMessage);virtual id_First+id_D2CB5;
- procedure IDD2CB6(var Msg:TMessage);virtual id_First+id_D2CB6;
- end;
-
-
- PPLXDlg3 = ^TPLXDlg3;
- TPLXDlg3 = object(TDialog) {Print setup dialog}
- procedure WMInitDialog(var Msg:TMessage);virtual wm_First+wm_InitDialog;
- procedure IDSetup(var Msg:TMessage);virtual id_First+id_D3Setup;
- procedure IDChange(var Msg:TMessage);virtual id_First+id_D3Change;
- procedure IDOKPrt(var Msg:TMessage);virtual id_First+id_D3OKPrt;
- end;
-
- PPLXDlg4 = ^TPLXDlg4; {Type Faces & Sizes Dialog}
- TPLXDlg4 = object(TDialog)
- FontSize: Integer;
- procedure WMInitDialog(var Msg:TMessage);virtual wm_First+wm_InitDialog;
- procedure IDD4Lb1(var Msg:TMessage);virtual id_First+id_D4Lb1;
- procedure IDD4Lb2(var Msg:TMessage);virtual id_First+id_D4Lb2;
- procedure IDD4RB1(var Msg:TMessage);virtual id_First+id_D4RB1;
- procedure IDD4RB2(var Msg:TMessage);virtual id_First+id_D4RB2;
- procedure IDD4RB3(var Msg:TMessage);virtual id_First+id_D4RB3;
- procedure LoadSizes;virtual;
- end;
-
-
- type
- pPLXPrinter = ^tPLXPrinter;
- tPlxPrinter = object(tPrinter1)
- HeadLine1:Array[0..210] of Char;
- function DoHeader:Boolean;virtual;
- function DoFooter:Boolean;virtual;
- function SetHeader1(NewHeadLine1:PChar):Boolean;virtual;
- end;
-
-
- type {MainWindow of Application}
- PPLXWindow = ^TPLXWindow;
- TPLXWindow = object(TWindow)
- DispWin:PEdit; {child window displaying sample lines from infile}
- TheIcon:HIcon;
- Bn1,Bn2,Bn3,Bn4,Bn5 :PODButton; {icon bar buttons}
- FileName:Array[0..79] of Char; {infile name}
- CharsInFile:LongInt; {chars in infile}
- St1,St2:PSText;
- FontSelection:Integer; {Index into Fonts collection}
- PFontSize:Integer; {Current font size for printed text}
- Records:PCollection; {Collection of Infile records}
- Margins:TRect; {in inches * 100}
- Format:FormatRec; {format fields}
- FontStyle:FontStyleRec; {font style fields}
- Tabsize:Integer;
- Fonts:PFonts; {font enumeration information}
- constructor Init(AParent:PWindowsObject;ATitle:PChar);
- destructor Done;virtual;
- procedure SetupWindow;virtual;
- procedure Paint(PaintDC:HDC;var PaintInfo:TPaintStruct);virtual;
- procedure SetStaticText;
- procedure LoadDispWin;
- procedure WMDrawItem(var Msg:TMessage);virtual wm_First + wm_DrawItem;
- procedure WMSize(var Msg:TMessage);virtual wm_First+wm_Size;
- procedure WMSetFocus(var Msg:TMessage);virtual wm_First+wm_SetFocus;
- procedure IDBut1(var Msg:TMessage);virtual id_First+id_But1; {Print}
- procedure IDBut2(var Msg:TMessage);virtual id_First+id_But2; {FileOpen}
- procedure IDBut3(var Msg:TMessage);virtual id_First+id_But3; {PageSetup}
- procedure IDBut4(var Msg:TMessage);virtual id_First+id_But4; {SelectFont}
- procedure IDBut5(var Msg:TMessage);virtual id_First+id_But5; {Exit}
- procedure EnumerateFonts;virtual;
- function GetFontSelection:Integer;virtual;
- procedure SetFontSelection(NewSelection:Integer);
- procedure SetFontSize(NewfontSize:Integer);virtual;
- procedure SetPFontSize(NewfontSize:Integer);virtual;
- procedure UMFilePrint(var Msg:TMessage);virtual wm_User+um_FilePrint;
- procedure WMSysCommand(var Msg:TMessage);virtual wm_First+wm_SysCommand;
- procedure CMFOpen(var Msg:TMessage);virtual cm_First+cm_FOpen;
- procedure CMFPrint(var Msg:TMessage);virtual cm_First+cm_FPrint;
- procedure CMFSetUp(var Msg:TMessage);virtual cm_First+cm_FSetUp;
- procedure CMFChgPrt(var Msg:TMessage);virtual cm_First+cm_FChgPrt;
- procedure CMFExit(var Msg:TMessage);virtual cm_First+cm_FExit;
- procedure CMTFont(var Msg:TMessage);virtual cm_First+cm_TFont;
- procedure GetFormatFlags(var AFormat:FormatRec);virtual;
- procedure SetFormatFlags(NewFormat:FormatRec);virtual;
- procedure GetMargins(var pMargins:PRect);virtual;
- procedure SetMargins(NewMargins:TRect);virtual;
- function GetTabSize:Integer;virtual;
- procedure SetTabSize(NewTabSize:Integer);virtual;
- procedure GetProfileValues;virtual;
- procedure WriteProfileValues;virtual;
- procedure SetFontStyle(NewNormal,NewBold,NewItalic:Integer);virtual;
- end;
-
- {********************************************************************}
- {G L O B A L V A R I A B L E S }
- {********************************************************************}
- var
- MainWin:PPLXWindow;
- {********************************************************************}
- {M E T H O D S }
- {********************************************************************}
-
- procedure TPLXApplication.InitMainWindow;
- begin
- MainWindow := New(PPLXWindow,Init(nil,'PLX'));
- MainWin := PPLXWindow(MainWindow);
- end;
-
- {********************************************************************}
- {Init}
- constructor TPLXWindow.Init(AParent:PWindowsObject;ATitle:PChar);
- begin
- TWindow.Init(AParent,ATitle);
- Attr.Menu := LoadMenu(HInstance,'PLX_Menu');
- Attr.X := 20; Attr.Y := 25; Attr.W := 595; Attr.H := 260;
- Bn1 := New(PODButton,Init(@Self,id_But1,'Print',200,0,50,50,False,'PLX_Bn1'));
- Bn2 := New(PODButton,Init(@Self,id_But2,'File Open',0,0,50,50,False,'PLX_Bn2'));
- Bn3 := New(PODButton,Init(@Self,id_But3,'Page Setup',50,0,100,50,False,'PLX_Bn3'));
- Bn4 := New(PODButton,Init(@Self,id_But4,'Font',150,0,50,50,False,'PLX_Bn4'));
- Bn5 := New(PODButton,Init(@Self,id_But5,'Exit',250,0,50,50,False,'PLX_Bn5'));
- St1 := New(PSText,Init(@Self,id_St1,'',315,3,240,20,sr_Recessed,dt_Center or dt_VCenter));
- St2 := New(PSText,Init(@Self,id_St2,'',315,26,240,20,sr_Recessed,dt_Center or dt_VCenter));
- FontSelection := 9999;
- PFontsize := 10;
- Fonts := New(PFonts,Init);
- EnumerateFonts;
- DispWin := New(PEdit,Init(@Self,200,nil,0,0,0,0,0,True));
- with DispWin^.Attr do
- Style := Style or es_NoHideSel ;
- Records := New(PCollection,Init(1000,500));
- CharsInFile := 0;
- Margins.left := 0;Margins.right := 0;Margins.top := 0;Margins.bottom := 0;
- Format.ShowRuler := 1;Format.ShowFName := 1;
- Format.ShowDTStamp := 1;Format.ShowPageNum := 1;
- Format.ShowLineNum := 1;Format.UseCCB := 0;
- StrCopy(Format.Header,'');StrCopy(Format.Footer,'');
- FontStyle.Normal := 1;FontStyle.Bold := 0;FontStyle.Italic := 0;
- Tabsize := 2;
- GetProfileValues;
- end;
-
- {SetupWindow}
- procedure TPLXWindow.SetupWindow;
- var
- SysMenu:hMenu;
- OEMFixFont:hFont;
- begin
- TWindow.SetupWindow;
- SetClassWord(HWindow,GCW_HIcon,LoadIcon(HInstance,'PLX_Icon'));
- Sysmenu := GetSystemMenu(hWindow,false);
- AppendMenu(SysMenu,MF_Separator,0,nil);
- AppendMenu(SysMenu,0,idm_RunCP,'Run Control Panel');
- AppendMenu(Sysmenu,0,idm_About,'About...');
- OEMFixFont := GetStockObject(OEM_Fixed_Font);
- SendMessage(DispWin^.hWindow,wm_SetFont,OEMFixFont,LongInt(1));
- end;
-
- {Paint}
- procedure TPLXWindow.Paint(PaintDC:HDC;var PaintInfo:TPaintStruct);
- var
- ThePen:HPen;
- TheBrush :HBrush;
- OldBrush :HBrush;
- OldPen:HPen;
- begin
- TheBrush := GetStockObject(LtGray_Brush);
- ThePen := CreatePen(ps_Solid,1,$00000000);
- OldPen := SelectObject(PaintDC,ThePen);
- OldBrush := SelectObject(PaintDC,TheBrush);
- Rectangle(PaintDC,0,0,1024,50);
- SelectObject(PaintDC,OldBrush);
- SelectObject(PaintDC,OldPen);
- DeleteObject(ThePen);
- end;
-
- {Route the Ownerdraw msgs to correct object}
- procedure TPLXWindow.WMDrawItem(var Msg:TMessage);
- var
- PDIS : ^TDrawItemStruct;
- begin
- PDIS := Pointer(Msg.lParam);
- case PDIS^.CtlType of
- odt_Button:
- case PDIS^.CtlID of
- id_But1 :Bn1^.DrawItem(Msg);
- id_But2 :Bn2^.DrawItem(Msg);
- id_But3 :Bn3^.DrawItem(Msg);
- id_But4 :Bn4^.DrawItem(Msg);
- id_But5 :Bn5^.DrawItem(Msg);
- end;
- end;
- end;
-
- {Done}
- destructor TPLXWindow.Done;
- begin
- if FontSelection <> 9999 then
- WriteProfileValues;
- Dispose(Fonts,Done);
- Dispose(Records,Done);
- TWindow.Done;
- end;
-
- {WMSize}
- procedure TPLXWindow.WMSize(var Msg:TMessage);
- begin
- SetWindowPos(DispWin^.HWindow,0,-1,50,
- (Msg.LParamLo )+1,(Msg.LParamHi-50),swp_NoZOrder);
- end;
-
- {WMSetFocus}
- procedure TPLXWindow.WMSetFocus(var Msg:TMessage);
- begin
-
- end;
-
- {IDBut1} {Print file dialog }
- procedure TPLXWindow.IDBut1(var Msg:TMessage);
- var
- Dlg : PDialog;
- begin
- Dlg :=New(PPLXDlg3,Init(@Self,'PLX_Dlg3'));
- Application^.ExecDialog(Dlg);
- end;
-
- {IDBut2} {run file open dialog box, load file}
- procedure TPLXWindow.IDBut2(var Msg:TMessage);
- var
- Dlg1 :PFileDialog;
- InFile :PTextStream;
- InRecord:PChar;
- ExpRecord:PChar;
- PctMeter:PMeterWindow;
- Division,Pctdone:Integer;
- indx1 : Integer;
- Indx2 : Integer;
- hTab :Integer;
- begin
- Division := 10;
- StrCopy(FileName,'*.*');
- InRecord :=MemAlloc(9999);
- ExpRecord := MemAlloc(9999);
- if Records^.Count > 0 then
- begin
- Dispose(Records,Done);
- Records := New(PCollection,Init(1000,500));
- end;
- DispWin^.Clear;
- Dlg1 := new(PfileDialog,Init(@Self,PChar(sd_FileOpen),@FileName));
- If Application^.ExecDialog(Dlg1) <> id_OK then
- begin
- StrCopy(FileName,'');
- exit;
- end;
- if StrIComp(FileName,'*.*') <> 0 then
- begin
- PctMeter := New(PMeterWindow,Init(@Self,'PLX - Reading File'));
- Application^.MakeWindow(PctMeter);
- PctMeter^.Draw(0);
- InFile := New(PTextStream,Init(FileName,stOpen,1024));
- CharsInFile := InFile^.CharsToRead;
- While NOT InFile^.IsEOF do
- begin
- StrCopy(InRecord,InFile^.GetNext);
- if InRecord = nil then {avoid storing null pointers }
- StrCopy(InRecord,' ');
- Records^.Insert(New(PTextObj,Init(InRecord)));
- if InFile^.GetPctDone > Division then
- begin
- PctMeter^.Draw(Division);
- Inc(Division,10);
- end;
- end;
- Dispose(PctMeter,Done);
- end;
- FreeMem(InRecord,9999);
- FreeMem(ExpRecord,9999);
- UpdateWindow(hWindow); {get a redraw before loading preview window}
- LoadDispWin;
- end;
-
- {IDBut3} {page setup}
- procedure TPLXWindow.IDBut3(var Msg:TMessage);
- var
- TotChars:Integer;
- begin
- Application^.ExecDialog(New(PPLXDlg2,Init(@Self,'PLX_Dlg2')));
- InvalidateRect(DispWin^.HWindow,nil,True);
- end;
-
- {IDBut4} {run font selection dialogs}
- procedure TPLXWindow.IDBut4(var Msg:TMessage);
- var
- Dlg2:PPLXDlg4;
- begin
- if Fonts^.Count = 0 then {if necessary, enumerate fonts for current printer}
- begin
- EnumerateFonts;
- end;
- Dlg2 := new(PPLXDlg4,Init(@Self,'PLX_Dlg4'));
- Application^.ExecDialog(Dlg2);
- if FontSelection = 9999 then
- begin
- MessageBox(hWindow,'Please select a font size','Alert',mb_OK or mb_IconExclamation);
- exit;
- end;
- end;
-
- {IdBut5} {exit}
- procedure TPLXWindow.IDBut5(var Msg:TMessage);
- begin
- SendMessage(HWindow,wm_Close,0,0);
- end;
-
- { Collect all of Fonts supported by current system printer }
- procedure TPLXWindow.EnumerateFonts;
- var
- ThePrinter:pWOPrinter;
- begin
- ThePrinter := New(pWOPrinter,Init(hInstance,@Self));
- Fonts^.Enumerate(ThePrinter^.GetQuickDC);
- ThePrinter^.DeleteQuickDC;
- Dispose(ThePrinter,Done);
- end;
-
- {GetFontSelection}
- function TPLXWindow.GetFontSelection:Integer;
- begin
- GetFontSelection := FontSelection;
- end;
-
- {SetFontSelection}
- procedure TPLXWindow.SetFontSelection(NewSelection:Integer);
- begin
- FontSelection := NewSelection;
- end;
-
- {SetFontSize}
- procedure TPLXWindow.SetFontSize(NewFontSize:Integer);
- begin
- PFontSize := NewFontSize;
- end;
-
- {SetPFontSize}
- procedure TPLXWindow.SetPFontSize(NewFontSize:Integer);
- begin
- PFontSize := NewFontSize;
- end;
-
- {UMFilePrint}
- procedure TPLXWindow.UMFilePrint(var Msg:TMessage);
- var
- aPtr : pPLXPrinter;
- indx : Integer;
- FI : PFontItem;
- OldFont,NewFont:hFont;
- szSize:Array[0..7] of Char;
- LogFont:TLogFont;
- TM:TTextMetric;
- Buf1,Buf2:PChar;
- szIndx:Array[0..5] of Char;
- OutRecord:pTextObj;
- ExpRec:PChar;
- CCB:Char;
- begin
- if Records^.Count = 0 then
- begin
- MessageBox(hWindow,'You need to open a file - click the disk icon',
- 'Alert',mb_OK or mb_IconExclamation);
- exit;
- end;
- if FontSelection = 9999 then
- begin
- MessageBox(hWindow,'You need to select a font - click the font button',
- 'Alert',mb_OK or mb_IconExclamation);
- exit;
- end;
- aPtr := New(pPLXPrinter,Init(hInstance,@Self));
- indx := 0;
- GetMem(Buf1,16000);
- GetMem(ExpRec,16000);
- if aPtr^.Start('PLX',hWindow) then
- begin
- aPtr^.SetMarginL(round(Margins.left * (Fonts^.LogPixX / 100))) ;{margin in device pixels}
- FI := Fonts^.At(FontSelection);
- FI^.LogFont.lfHeight := Round(PFontsize * (Fonts^.LogPixY / 72));
- FI^.LogFont.lfWidth := 0;
- if FontStyle.Bold = 1 then
- FI^.LogFont.lfWeight := fw_Bold
- else
- FI^.LogFont.lfWeight := fw_Normal;
- if FontStyle.Italic = 1 then
- FI^.LogFont.lfItalic := 1
- else
- FI^.LogFont.lfItalic := 0;
- FI^.LogFont.lfQuality := Draft_Quality;
- NewFont := CreateFontIndirect(FI^.LogFont);
- OldFont := aPtr^.SetFont(NewFont);
- aPtr^.SetHeader1(FileName);
- aPtr^.SetupPage;
- StrCopy(szIndx,'');
-
- for indx := 0 to (Records^.Count-1) do
- begin
- OutRecord := Records^.AT(indx);
- if OutRecord^.Text <> nil then {avoid null pointer}
- StrCopy(Buf1,OutRecord^.Text)
- else
- StrCopy(Buf1,'');
- Buf2 := Buf1;
- if Format.ShowLineNum = 1 then {setup line numbers}
- Str((indx+1):5,szIndx)
- else
- StrCopy(szIndx,'');
- if (Format.UseCCB = 1) then {setup CCB for linespacing}
- begin
- CCB := Buf1[0];
- Buf2:= Buf1+1;
- end
- else
- CCB := ' ';
- ExpandTabs(Buf2,ExpRec,Tabsize); {expand tabs}
- StrCat(StrCat(StrCopy(Buf1,szIndx),' '),ExpRec);
-
- case CCB of {do line spacing using CCB}
- '1': aPtr^.NewPage;
- '0': aPtr^.PrintLine(' ');
- '-': begin
- aPtr^.PrintLine(' ');
- aPtr^.PrintLine(' ');
- end;
- end;
- aPtr^.printLine(Buf1);
- end;
-
- aPtr^.PrtMode := pm_PrintFooter; {do one last footer}
- APtr^.DoFooter;
- OldFont := aPtr^.SetFont(OldFont); {restore the old font}
- DeleteObject(NewFont);
- aPtr^.Finish;
- Dispose(aPtr,Done);
- end; {end if}
- FreeMem(Buf1,16000);
- FreeMem(ExpRec,16000);
- end;
-
- {WMSysCommand}
- procedure TPLXWindow.WMSysCommand(var Msg:TMessage);
- begin
- case Msg.Wparam of
- idm_About:
- Application^.ExecDialog(New(PDialog,Init(@Self,'PLX_About')));
- idm_RunCP:
- begin
- WinExec('Control',1);
- FontSelection := 9999; {Force a reselection of current font}
- PFontSize := 10;
- Fonts^.ReInit; {reinitialze the collections }
- end;
- else
- DefWndProc(Msg);
- end;
- end;
-
- {SetStaticText}
- procedure TPLXWindow.SetStaticText;
- var
- I: Integer;
- Buf:Array[0..80] of Char;
- szLines:Array[0..5] of Char;
- LPY:Integer;
- FontMetrics:TTextMetric;
- szBytes:Array[0..7] of Char;
- nBytes:Integer;
- begin {build text display}
- StrCopy(Buf,'File: ');
- St1^.SetText(StrCat(Buf,FileName));
- Str(CharsInFile:5,szBytes);
- Str(Records^.Count:5,szLines);
- StrECopy(StrECopy(StrECopy(StrECopy(Buf,'# of Lines:'),szLines),' Bytes:'),szBytes);
- St2^.SetText(Buf);
- end;
-
- {LoadDispWin}
- procedure TPLXWindow.LoadDispWin;
- var
- InRecord:PTextObj;
- Indx:Integer;
- Buf1:pChar;
- Cursor:hCursor;
- CRLF :Array[0..2] of Char;
- RCount:Integer;
- begin
- StrCopy(CRLF,#13#10#0);
- RCount := Records^.Count;
- if RCount > 0 then
- begin
- SetCursor(LoadCursor(0,Idc_Wait));
- indx := 0;
- DispWin^.Clear;
- GetMem(Buf1,27000);
- StrCopy(Buf1,'');
- while (indx < 100) AND (indx < RCount) AND (StrLen(Buf1) < 15000) do
- begin
- InRecord := Records^.At(indx);
- If InRecord^.Text <> NIL then
- StrCat(StrCat(Buf1,InRecord^.Text),CRLF)
- else
- StrCat(Buf1,CRLF) ;
- Inc(indx,1);
- end;
- if (StrLen(Buf1) > 14999) or (Indx > 99) then
- begin
- StrCat(Buf1,CRLF);
- StrCat(StrCat(Buf1,'... Rest of text not displayed!!!'),CRLF);
- end;
- DispWin^.Insert(Buf1);
- FreeMem(Buf1,27000);
- DispWin^.Scroll(0,-9999);
- SetCursor(LoadCursor(0,Idc_Arrow));
- SetStaticText;
- end;
- end;
-
- {CMFOpen}
- procedure TPLXWindow.CMFOpen(var Msg:TMessage);
- begin
- IDBut2(Msg);
- end;
-
- {CMFPrint}
- procedure TPLXWindow.CMFPrint(var Msg:TMessage);
- begin
- IDBut1(Msg);
- end;
-
- {CMFSetup}
- procedure TPLXWindow.CMFSetUp(var Msg:TMessage);
- begin
- IDBut3(Msg);
- end;
-
- {CMFExit}
- procedure TPLXWindow.CMFExit(var Msg:TMessage);
- begin
- IDBut5(Msg);
- end;
-
- {CMFChgPrt}
- procedure TPLXWindow.CMFChgPrt(var Msg:TMessage);
- var
- ThePrinter:pWOPrinter;
- begin
- ThePrinter := New(pWOPrinter,Init(hInstance,@Self));
- ThePrinter^.ChgPrinter;
- Dispose(ThePrinter,Done);
- FontSelection := 9999;
- PFontSize := 10;
- Fonts^.ReInit;
- end;
-
- {CMTFont}
- procedure TPLXWindow.CMTFont(var Msg:TMessage);
- begin
- IDBut4(Msg);
- end;
-
-
- procedure TPLXWindow.GetFormatFlags(var AFormat:FormatRec);
- begin
- AFormat.ShowRuler := Format.ShowRuler;
- AFormat.ShowFName := Format.ShowFName;
- AFormat.ShowDTStamp := Format.ShowDTStamp;
- AFormat.ShowPageNum := Format.ShowPageNum;
- AFormat.ShowLineNum := Format.ShowLineNum;
- AFormat.UseCCB := Format.UseCCB;
- StrCopy(AFormat.Header,Format.Header);
- StrCopy(AFormat.Footer,Format.Footer);
- end;
-
- procedure TPLXWindow.SetFormatFlags(NewFormat:FormatRec);
- begin
- Format.ShowRuler := NewFormat.ShowRuler;
- Format.ShowFName := NewFormat.ShowFName;
- Format.ShowDTStamp := NewFormat.ShowDTStamp;
- Format.ShowPageNum := NewFormat.ShowPageNum;
- Format.ShowLineNum := NewFormat.ShowLineNum;
- Format.UseCCB := NewFormat.UseCCB;
- StrCopy(Format.Header,NewFormat.Header);
- StrCopy(Format.Footer,NewFormat.Footer);
- end;
-
-
- procedure TPLXWindow.GetMargins(var pMargins:PRect);
- begin
- pMargins^.Left := Margins.left;
- pMargins^.Right := Margins.right;
- pMargins^.Top := Margins.Top;
- pMargins^.Bottom := Margins.Bottom;
- end;
-
- procedure TPLXWindow.SetMargins(NewMargins:TRect);
- begin
- Margins.left := NewMargins.left;
- Margins.right := NewMargins.right;
- Margins.top := NewMargins.top;
- Margins.Bottom := NewMargins.bottom;
- end;
-
- function TPLXWindow.GetTabSize:Integer;
- begin
- GetTabSize := TabSize;
- end;
-
- procedure TPLXWindow.SetTabSize(NewTabSize:Integer);
- begin
- TabSize := NewTabSize;
- end;
-
- procedure TPLXWindow.GetProfileValues;
- var
- Buf1:Array[0..30] of Char;
- Indx:Integer;
- Item:PFontItem;
- Found:Boolean;
- begin
- Format.ShowRuler := GetPrivateProfileInt('PLX','ShowRuler',1,'PLX.INI');
- Format.ShowFName := GetPrivateProfileInt('PLX','ShowFName',1,'PLX.INI');
- Format.ShowDTStamp := GetPrivateProfileInt('PLX','ShowDTStamp',1,'PLX.INI');
- Format.ShowPageNum := GetPrivateProfileInt('PLX','ShowPageNum',1,'PLX.INI');
- Format.ShowLineNum := GetPrivateProfileInt('PLX','ShowLineNum',1,'PLX.INI');
- Format.UseCCB := GetPrivateProfileInt('PLX','UseCCB',0,'PLX.INI');
-
- Margins.Left := GetPrivateProfileInt('PLX','MarginL',0,'PLX.INI');
- Margins.Right := GetPrivateProfileInt('PLX','MarginR',0,'PLX.INI');
- Margins.Top := GetPrivateProfileInt('PLX','MarginT',0,'PLX.INI');
- Margins.Bottom := GetPrivateProfileInt('PLX','MarginB',0,'PLX.INI');
- TabSize := GetPrivateProfileInt('PLX','TabSize',2,'PLX.INI');
-
- FontStyle.Normal := GetPrivateProfileInt('PLX','Normal',1,'PLX.INI');
- FontStyle.Bold := GetPrivateProfileInt('PLX','Bold',0,'PLX.INI');
- FontStyle.Italic := GetPrivateProfileInt('PLX','Italic',0,'PLX.INI');
-
-
- GetPrivateProfileString('PLX','FaceName','9999',Buf1,SizeOf(Buf1),'PLX.INI');
- PFontSize:= GetPrivateProfileInt('PLX','FontSize',8,'PLX.INI');
- Found := False;
- for Indx := 0 to Fonts^.Count -1 do
- begin
- Item := Fonts^.At(Indx);
- If (StrIComp(Item^.LogFont.lfFaceName,Buf1) = 0) then
- begin
- FontSelection := Indx;
- Found := True;
- end
- end;
- end;
-
- procedure TPLXWindow.WriteProfileValues;
- var
- Buf:Array[0..5] of Char;
- FI:pFontItem;
- begin
- StrCopy(Buf,'');
- FI := Fonts^.At(FontSelection);
- WritePrivateProfileString('PLX','FaceName',FI^.LogFont.lfFaceName,'PLX.INI');
- Str(PFontSize,Buf);
- WritePrivateProfileString('PLX','FontSize',Buf,'PLX.INI');
- Str(FontStyle.Normal,Buf);
- WritePrivateProfileString('PLX','Normal',Buf,'PLX.INI');
- Str(FontStyle.Bold,Buf);
- WritePrivateProfileString('PLX','Bold',Buf,'PLX.INI');
- Str(FontStyle.Italic,Buf);
- WritePrivateProfileString('PLX','Italic',Buf,'PLX.INI');
-
- Str(Format.ShowRuler,Buf);
- WritePrivateProfileString('PLX','ShowRuler',Buf,'PLX.INI');
- Str(Format.ShowFName,Buf);
- WritePrivateProfileString('PLX','ShowFName',Buf,'PLX.INI');
- Str(Format.ShowDTStamp,Buf);
- WritePrivateProfileString('PLX','ShowDTStamp',Buf,'PLX.INI');
- Str(Format.ShowPageNum,Buf);
- WritePrivateProfileString('PLX','ShowPageNum',Buf,'PLX.INI');
- Str(Format.ShowLineNum,Buf);
- WritePrivateProfileString('PLX','ShowLineNum',Buf,'PLX.INI');
- Str(Format.UseCCB,Buf);
- WritePrivateProfileString('PLX','UseCCB',Buf,'PLX.INI');
-
- Str(Margins.Left,Buf);
- WritePrivateProfileString('PLX','MarginL',Buf,'PLX.INI');
- Str(Margins.Right,Buf);
- WritePrivateProfileString('PLX','MarginR',Buf,'PLX.INI');
- Str(Margins.Top,Buf);
- WritePrivateProfileString('PLX','MarginT',Buf,'PLX.INI');
- Str(Margins.Bottom,Buf);
- WritePrivateProfileString('PLX','MarginB',Buf,'PLX.INI');
- Str(TabSize,Buf);
- WritePrivateProfileString('PLX','TabSize',Buf,'PLX.INI');
- end;
-
-
- procedure TPLXWindow.SetFontStyle(NewNormal,NewBold,NewItalic:Integer);
- begin
- FontStyle.Normal := NewNormal;
- FontStyle.Bold := NewBold;
- FontStyle.Italic := NewItalic;
- end;
-
- {*********************************************************************}
- procedure TPLXDlg2.WMInitDialog(var Msg:TMessage);
- var
- Buf1:Array[0..5] of Char;
- pBuf:PChar;
- pMargins : PRect;
- begin
- pMargins := @Margins;
- MainWin^.GetMargins(pMargins);
- MainWin^.GetFormatFlags(Format);
- TabSize := PPLXWindow(Parent)^.GetTabSize;
- SendDlgItemMsg(id_D2CB1,bm_SetCheck,Format.ShowRuler,0);
- SendDlgItemMsg(id_D2CB2,bm_SetCheck,Format.ShowFName,0);
- SendDlgItemMsg(id_D2CB3,bm_SetCheck,Format.ShowDTStamp,0);
- SendDlgItemMsg(id_D2CB4,bm_SetCheck,Format.ShowPageNum,0);
- SendDlgItemMsg(id_D2CB5,bm_SetCheck,Format.ShowLineNum,0);
- SendDlgItemMsg(id_D2CB6,bm_SetCheck,Format.UseCCB,0);
-
- pBuf := Buf1;
- Str(Margins.Left/100:3:1,Buf1);
- SendDlgItemMsg(id_D2EC1,wm_SetText,0,LongInt(pBuf));
- Str(Margins.Right/100:3:1,Buf1);
- SendDlgItemMsg(id_D2EC2,wm_SetText,0,LongInt(pBuf));
- Str(Margins.Top/100:3:1,Buf1);
- SendDlgItemMsg(id_D2EC3,wm_SetText,0,LongInt(pBuf));
- Str(Margins.Bottom/100:3:1,Buf1);
- SendDlgItemMsg(id_D2EC4,wm_SetText,0,LongInt(pBuf));
- Str(TabSize,Buf1);
- SendDlgItemMsg(id_D2EC5,wm_SetText,0,LongInt(pBuf));
- StrCopy(Format.Header,'');
- Strcopy(Format.Footer,'');
- end;
-
- procedure TPLXDlg2.IDD2OK(var Msg:TMessage);
- begin
- MainWin^.SetMargins(Margins);
- MainWin^.SetFormatFlags(Format);
- MainWin^.SetTabSize(TabSize);
- EndDlg(1);
- end;
-
- procedure TPLXDlg2.IDD2CB1(var Msg:TMessage);
- begin
- case Msg.lParamHi of
- bn_Clicked:
- begin
- Format.ShowRuler := SendDlgItemMsg(id_D2CB1,bm_GetCheck,0,0);
- Exit;
- end;
- end;
- end;
-
- procedure TPLXDlg2.IDD2CB2(var Msg:TMessage);
- begin
- case Msg.lParamHi of
- bn_Clicked:
- begin
- Format.ShowFName := SendDlgItemMsg(id_D2CB2,bm_GetCheck,0,0);
- Exit;
- end;
- end;
- end;
-
- procedure TPLXDlg2.IDD2CB3(var Msg:TMessage);
- begin
- case Msg.lParamHi of
- bn_Clicked:
- begin
- Format.ShowDTStamp := SendDlgItemMsg(id_D2CB3,bm_GetCheck,0,0);
- Exit;
- end;
- end;
- end;
-
- procedure TPLXDlg2.IDD2CB4(var Msg:TMessage);
- begin
- case Msg.lParamHi of
- bn_Clicked:
- begin
- Format.ShowPageNum := SendDlgItemMsg(id_D2CB4,bm_GetCheck,0,0);
- Exit;
- end;
- end;
- end;
-
- procedure TPLXDlg2.IDD2CB5(var Msg:TMessage);
- begin
- case Msg.lParamHi of
- bn_Clicked:
- begin
- Format.ShowLineNum := SendDlgItemMsg(id_D2CB5,bm_GetCheck,0,0);
- Exit;
- end;
- end;
- end;
-
- procedure TPLXDlg2.IDD2CB6(var Msg:TMessage);
- begin
- case Msg.lParamHi of
- bn_Clicked:
- begin
- Format.UseCCB := SendDlgItemMsg(id_D2CB6,bm_GetCheck,0,0);
- Exit;
- end;
- end;
- end;
-
- procedure TPLXDlg2.IDD2EC1(var Msg:TMessage);
- var
- Idx : Integer;
- Buf:Array[0..5] of Char;
- Ptr : PChar;
- ErrCode:Integer;
- Margin:Real;
- return:Integer;
- begin
- case Msg.lParamHi of
- en_KillFocus:
- begin
- Ptr := Buf;
- Idx := 5;
- Return := SendDlgItemMsg(id_D2EC1,wm_GetText,word(Idx),LongInt(Ptr));
- val(Ptr,Margin,ErrCode);
- Margins.Left := round(Margin * 100);
- Exit;
- end;
- end;
- end;
-
- procedure TPLXDlg2.IDD2EC2(var Msg:TMessage);
- var
- Idx : Integer;
- Buf:Array[0..5] of Char;
- Ptr : PChar;
- ErrCode:Integer;
- Margin:Real;
- return:Integer;
- begin
- case Msg.lParamHi of
- en_KillFocus:
- begin
- Ptr := Buf;
- Idx := 5;
- Return := SendDlgItemMsg(id_D2EC2,wm_GetText,word(Idx),LongInt(Ptr));
- val(Ptr,Margin,ErrCode);
- Margins.Right := round(Margin * 100);
- Exit;
- end;
- end;
- end ;
-
- procedure TPLXDlg2.IDD2EC3(var Msg:TMessage);
- var
- Idx : Integer;
- Buf:Array[0..5] of Char;
- Ptr : PChar;
- ErrCode:Integer;
- Margin:Real;
- return:Integer;
- begin
- case Msg.lParamHi of
- en_KillFocus:
- begin
- Ptr := Buf;
- Idx := 5;
- Return := SendDlgItemMsg(id_D2EC3,wm_GetText,word(Idx),LongInt(Ptr));
- val(Ptr,Margin,ErrCode);
- Margins.Top := round(Margin * 100);
- Exit;
- end;
- end;
- end;
-
- procedure TPLXDlg2.IDD2EC4(var Msg:TMessage);
- var
- Idx : Integer;
- Buf:Array[0..5] of Char;
- Ptr : PChar;
- ErrCode:Integer;
- Margin:Real;
- return:Integer;
- begin
- case Msg.lParamHi of
- en_KillFocus:
- begin
- Ptr := Buf;
- Idx := 5;
- Return := SendDlgItemMsg(id_D2EC4,wm_GetText,word(Idx),LongInt(Ptr));
- val(Ptr,Margin,ErrCode);
- Margins.Bottom := round(Margin * 100);
- Exit;
- end;
- end;
- end;
-
- procedure TPLXDlg2.IDD2EC5(var Msg:TMessage);
- var
- Idx : Integer;
- Buf:Array[0..5] of Char;
- Ptr : PChar;
- ErrCode:Integer;
- TSize:Integer;
- return:Integer;
- begin
- case Msg.lParamHi of
- en_KillFocus:
- begin
- Ptr := Buf;
- Idx := 5;
- Return := SendDlgItemMsg(id_D2EC5,wm_GetText,word(Idx),LongInt(Ptr));
- val(Ptr,TSize,ErrCode);
- TabSize := TSize;
- Exit;
- end;
- end;
- end;
-
- procedure TPLXDlg2.IDD2EC6(var Msg:TMessage);
- var
- Idx : Integer;
- Buf:Array[0..132] of Char;
- Ptr : PChar;
- ErrCode:Integer;
- TSize:Integer;
- return:Integer;
- begin
- case Msg.lParamHi of
- en_KillFocus:
- begin
- Ptr := Buf;
- Idx := 132;
- Return := SendDlgItemMsg(id_D2EC6,wm_GetText,word(Idx),LongInt(Ptr));
- StrCopy(Format.Header,Ptr);
- Exit;
- end;
- end;
- end;
-
- procedure TPLXDlg2.IDD2EC7(var Msg:TMessage);
- var
- Idx : Integer;
- Buf:Array[0..132] of Char;
- Ptr : PChar;
- ErrCode:Integer;
- TSize:Integer;
- return:Integer;
- begin
- case Msg.lParamHi of
- en_KillFocus:
- begin
- Ptr := Buf;
- Idx := 132;
- Return := SendDlgItemMsg(id_D2EC7,wm_GetText,word(Idx),LongInt(Ptr));
- StrCopy(Format.Footer,Ptr);
- Exit;
- end;
- end;
- end;
-
- {*********************************************************************}
- procedure TPLXDlg3.WMInitDialog(var Msg:TMessage);
- var
- ThePrinter:pWOPrinter;
- DeviceName:Array[0..40] of Char;
- begin
- TDialog.WMInitDialog(Msg);
- ThePrinter := New(pWOPrinter,Init(hInstance,@Self));
- ThePrinter^.GetQuickDC;
- StrCopy(DeviceName,ThePrinter^.deviceName);
- ThePrinter^.DeleteQuickDC;
- Dispose(ThePrinter,Done);
- SetDlgItemText(HWindow,503,DeviceName);
- end;
-
- procedure TPLXDlg3.IDSetup(var Msg:TMessage);
- var
- ThePrinter:pWOPrinter;
- begin
- ThePrinter := New(pWOPrinter,Init(hInstance,@Self));
- ThePrinter^.prnDeviceMode(hWindow);
- dispose(ThePrinter,Done);
- MainWin^.FontSelection := 9999;
- MainWin^.PFontSize := 10;
- MainWin^.Fonts^.ReInit;
- end;
-
- procedure TPLXDlg3.IDChange(var Msg:TMessage);
- begin
- EndDlg(1);
- SendMessage(MainWin^.HWindow,wm_Command,cm_FChgPrt,0);
- end;
-
- procedure TPLXDlg3.IDOKPrt(var Msg:TMessage);
- begin
- EndDlg(1);
- SendMessage(MainWin^.HWindow,wm_User+um_FilePrint,Msg.wParam,Msg.LParam);
- end;
-
- {***********************************************************************}
-
- procedure TPLXDlg4.WMInitDialog(var Msg:TMessage);
- var
- Indx : Integer;
- Font : PFontItem;
- pTextItem:PChar;
- szString:Array[0..5] of Char;
- begin
- TDialog.WMInitDialog(Msg);
- for indx := 0 to (PPLXWindow(Parent)^.Fonts^.Count -1) do
- begin
- Font := MainWin^.Fonts^.At(indx);
- pTextItem := Font^.LogFont.lfFaceName;
- SendDlgItemMsg(id_D4LB1,lb_AddString,word(0),LongInt(pTextItem));
- end;
- IF MainWin^.FontSelection <> 9999 then
- begin
- SendDlgItemMsg(id_D4Lb1,lb_SetCurSel,MainWin^.FontSelection,0);
- LoadSizes;
- pTextItem := szString;
- Str(MainWin^.PFontSize:3,szString);
- SendDlgItemMsg(id_D4lb2,lb_SelectString,word(-1),LongInt(pTextItem));
- end;
- if MainWin^.FontStyle.Normal = 1 then
- SendDlgItemMsg(id_D4RB1,bm_SetCheck,1,0)
- else if MainWin^.FontStyle.Bold = 1 then
- SendDlgItemMsg(id_D4RB2,bm_SetCheck,1,0)
- else SendDlgItemMsg(id_D4RB3,bm_SetCheck,1,0);
- end;
-
- procedure TPLXDlg4.IDD4Lb1(var Msg:TMessage);
- var
- Idx : Integer;
- Buf:Array[0..5] of Char;
- Ptr : PChar;
- ErrCode:Integer;
- begin
- case Msg.lParamHi of
- lbn_SelChange,lbn_DblClk:
- begin
- Ptr := Buf;
- Idx := SendDlgItemMsg(id_D4Lb1,lb_GetCurSel,0,0);
- MainWin^.SetFontSelection(Idx);
- loadsizes;
- end;
- end;
- end;
-
- procedure TPLXDlg4.IDD4Lb2(var Msg:TMessage);
- var
- Idx : Integer;
- Buf:Array[0..5] of Char;
- Ptr : PChar;
- ErrCode:Integer;
- begin
- case Msg.lParamHi of
- lbn_SelChange,lbn_DblClk:
- begin
- Ptr := @Buf;
- Idx := SendDlgItemMsg(id_D4Lb2,lb_GetCurSel,0,0);
- SendDlgItemMsg(id_D4Lb2,lb_GetText,Idx,LongInt(Ptr));
- val(Ptr,FontSize,ErrCode);
- MainWin^.SetFontSize(FontSize);
- end;
- end;
- end;
-
- procedure TPLXDlg4.LoadSizes;
- var
- pTextItem:PChar;
- Buf:Array[0..5] of Char;
- Indx,Indx2:Integer;
- FontItem:PFontItem;
- Item:PIntObj;
- Res,Res2:Integer;
- Height:Integer;
- LPY:Integer;
- begin
- LPY := MainWin^.Fonts^.LogPixY;
- FontItem := MainWin^.Fonts^.At(MainWin^.GetFontSelection);
- Indx2 := 0;
- Indx := 6;
- pTextItem := Buf;
- Res := FontItem^.FontType and Raster_FontType; {0 = vector font}
- Res2 := FontItem^.FontType and Device_FontType; {0 = GDI font}
- SendDlgItemMsg(id_D4Lb2,lb_ResetContent,word(0),LongInt(pTextItem));
- if Res = 0 then
- begin
- Str(Indx:3,Buf);
- while Indx < 20 do
- begin
- SendDlgItemMsg(id_D4Lb2,lb_AddString,word(0),LongInt(pTextItem));
- Indx := Indx + 2;
- Str(Indx:3,Buf);
- end;
- end
- else
- for Indx2 := 0 to FontItem^.Sizes^.Count-1 do
- begin
- Item := FontItem^.Sizes^.At(Indx2);
- Height := Item^.Int;
- Str(Round(Height * 72 / LPY):3,Buf);
- SendDlgItemMsg(id_D4Lb2,lb_AddString,word(0),LongInt(pTextItem));
- end;
- end;
-
-
- procedure TPLXDlg4.IDD4RB1(var Msg:TMessage); {Normal}
- var
- Idx : Integer;
- begin
- case Msg.lParamHi of
- bn_Clicked:
- begin
- Idx := SendDlgItemMsg(id_D4RB1,bm_GetCheck,0,0);
- if Idx = 0 then
- begin
- SendDlgItemMsg(id_D4RB1,bm_SetCheck,1,0);
- SendDlgItemMsg(id_D4RB2,bm_SetCheck,0,0);
- SendDlgItemMsg(id_D4RB3,bm_SetCheck,0,0);
- MainWin^.SetFontStyle(1,0,0);
- end;
- end;
- end;
- end;
-
- procedure TPLXDlg4.IDD4RB2(var Msg:TMessage); {Bold}
- var
- Idx : Integer;
- begin
- case Msg.lParamHi of
- bn_Clicked:
- begin
- Idx := SendDlgItemMsg(id_D4RB2,bm_GetCheck,0,0);
- if Idx = 0 then
- begin
- SendDlgItemMsg(id_D4RB2,bm_SetCheck,1,0);
- SendDlgItemMsg(id_D4RB1,bm_SetCheck,0,0);
- SendDlgItemMsg(id_D4RB3,bm_SetCheck,0,0);
- MainWin^.SetFontStyle(0,1,0);
- end;
- end;
- end;
- end;
-
- procedure TPLXDlg4.IDD4RB3(var Msg:TMessage); {Italic}
- var
- Idx : Integer;
- begin
- case Msg.lParamHi of
- bn_Clicked:
- begin
- Idx := SendDlgItemMsg(id_D4RB3,bm_GetCheck,0,0);
- if Idx = 0 then
- begin
- SendDlgItemMsg(id_D4RB3,bm_SetCheck,1,0);
- SendDlgItemMsg(id_D4RB1,bm_SetCheck,0,0);
- SendDlgItemMsg(id_D4RB2,bm_SetCheck,0,0);
- MainWin^.SetFontStyle(0,0,1);
- end;
- end;
- end;
- end;
- {***********************************************************************}
- function TPLXPrinter.DoHeader:Boolean;
- var
- Indx : Integer;
- FI : PFontItem;
- szSize:Array[0..7] of Char;
- Buf1:Array[0..100] of Char;
- szDateTime:Array[0..79] of Char;
- szPageNumber:Array[0..5] of Char;
- Ruler : Array[0..260] of Char;
- Format:FormatRec;
- begin
- MainWin^.GetFormatFlags(Format);
- if Format.ShowLineNum = 1 then
- StrCopy(Ruler,' ')
- else
- StrCopy(Ruler,'');
- StrCat(Ruler,' |...+....1....+....2....+....3....+....4....+....5');
- StrCat(Ruler,'....+....6....+....7....+....8....+....9....+....0');
- StrCat(Ruler,'....+....1....+....2....+....3....+....4....+....5');
- StrCat(Ruler,'....+....6....+....7....+....8....+....9....+....0');
- StrCat(Ruler,'....+....1....+....2....+....3....+....4....+....5');
- ResetPos;
- if StrLen(Format.Header) <> 0 then
- printLine(Format.Header);
- StrCopy(Buf1,'');
- GetDateTime(szDateTime);
- if Format.ShowFName <> 0 then
- StrCopy(Buf1,HeadLine1);
- if Format.ShowDTStamp <> 0 then
- StrCat(StrCat(Buf1,' '),szDateTime);
- Str(PageNumber:3,szPageNumber);
- if Format.ShowPageNum <> 0 then
- StrCat(StrCat(Buf1,' page:'),szPageNumber);
- if StrLen(Buf1) <> 0 then
- print(Buf1);
- SetMarginL(Margin.left); {Set margin = 0 inch}
- NewLine;
- if Format.ShowRuler <> 0 then
- PrintLine(Ruler);
- end;
-
- function tPLXPrinter.SetHeader1(NewHeadLine1:PChar):Boolean;
- begin
- StrCopy(HeadLine1,NewHeadLine1);
- SetHeader1 := True;
- end;
-
- function tPLXPrinter.DoFooter:Boolean;
- var
- Format:FormatRec;
- begin
- if PrtMode > pm_NoPrint then {position footer at bottom of page}
- posY := MaxY - (Margin.Bottom + FooterY + height);
- MainWin^.GetFormatFlags(Format); {get Footer text, if any}
- if StrLen(Format.Footer) > 0 then
- PrintLine(Format.Footer);
- end;
- {*********************************************************************}
- {*** M A I N L I N E }
- {*********************************************************************}
- var
- PLXApp : TPLXApplication;
- begin
- PLXApp.Init('PLX');
- PLXApp.Run;
- PLXApp.Done;
- end.
-