Einzelnen Beitrag anzeigen

ThYpHoOn

Registriert seit: 8. Jan 2008
52 Beiträge
 
Delphi 5 Enterprise
 
#3

Re: Altes Delphi/Pascal im neuen BDS....

  Alt 14. Jan 2008, 22:20
Delphi-Quellcode:
uses
  SysUtils, WinTypes, WinProcs, Buttons, Classes, Controls, Clipbrd, Dialogs, ExtCtrls,
  Forms, Menus, StdCtrls, Printers, IniFiles, Graphics,
  NSDchild, NSDgraph, NSDtypes, NSDutil, NSDpage, NSDabout;
{.....}
procedure TNSDEditor.PrintChild(Sender: TObject);
var
  x, y: Integer;
  r, s: Real;
begin
{.....}
    Screen.Cursor := crHourGlass;
    with TNSDiagram(ActiveMDIChild) do begin
      Printer.BeginDoc;
      { set mapping mode, necessary to change Window/Viewport extent !! }
      SetMapMode(Printer.Canvas.Handle, MM_ISOTROPIC); { set mapping mode }
      x := round(Printer.PageWidth / NSDlist.zoomFactor * 100);
      y := round(Printer.PageHeight / NSDlist.zoomFactor * 100);
      { set window(log.) : viewport(phys.) extent to Page size/Zoom : Page size}
      SetWindowExt(Printer.Canvas.Handle, x, y);
      SetViewportExt(Printer.Canvas.Handle, Printer.PageWidth, Printer.PageHeight);
      r := GetDeviceCaps(Printer.Handle, LOGPIXELSX) / 245 * NSDlist.leftMargin;
      s := GetDeviceCaps(Printer.Handle, LOGPIXELSY) / 245 * NSDlist.topMargin;
      { set viewport origin to (leftMargin, topMargin) in pixel }
      SetViewPortOrg(Printer.Canvas.Handle, round(r), round(s));
      Printer.Canvas.Font := NSDImage.Canvas.Font;
      NSDlist.Print(Printer);
      SetMapMode(Printer.Canvas.Handle, MM_TEXT); { reset mapping mode to Default }
      Printer.EndDoc;
Das wäre jetzt der Code-Ausschnitt für die SetWindowExt, etc.

Und hier der Code-Ausschnitt wo er System-Infos haben möchte:
Delphi-Quellcode:
uses
  SysUtils, WinTypes, WinProcs, Buttons, Classes, Controls, ExtCtrls, Forms, StdCtrls,
  Graphics;
{.....}
constructor TAboutBox.Execute(full: Boolean);
var
  AboutBox: TAboutBox;
  WVersion, DVersion: Word;
  WinFlags, start_time: LongInt;
begin
  AboutBox := TAboutBox.Create(Application);
  try
    with AboutBox do begin
      { Load application icon }
      {ProgramIcon.Picture.Graphic := Application.Icon;}
      {ProgramIcon.Picture.LoadFromFile('G:\delphi\1-nsd\NSD.BMP');}

      { Set dialog strings }
      Caption := 'About ' + Application.Title;
      ProductName.Caption := 'NSD Editor - ReMake';
      Version.Caption := 'Version 1.01 - ReMake by ThYpHoOn';
      Copyright.Caption := 'Copyright 1996 - Marcel Kalt' + #13#10 +
                           'UNI Fribourg, Switzerland';
      Comments.Caption := 'Project in computer science (third year),' + #13#10 +
                          'under the direction of Prof. J. Pasquier,'+ #13#10 +
                          'written by Marcel Kalt';

      if full then begin
        { Get Win/Dos version numbers }
        WVersion := LoWord(GetVersion);
        DVersion := HiWord(GetVersion);
        WinVersion.Caption := IntToStr(LO(WVersion)) + '.' + IntToStr(HI(WVersion));
        DosVersion.Caption := IntToStr(HI(DVersion)) + '.' + IntToStr(LO(DVersion));

        WinFlags := GetSystemInfo;

        { Get math coprocessor status }
        if WinFlags and WF_80x87 > 0 then
          Coprocessor.Caption := 'Present'
        else
          Coprocessor.Caption := 'Not Present';

        { Get CPU type }
        if WinFlags and WF_CPU486 > 0 then
          CPU.Caption := '486';
        if WinFlags and WF_CPU386 > 0 then
          CPU.Caption := '386';
        if WinFlags and WF_CPU286 > 0 then
          CPU.Caption := '286';

        { Get free memory, resources, disk space }
        FreeMemory.Caption := IntToStr(GetFreeSpace(0) div 1000) + ' KB';
        FreeResources.Caption := IntToStr(GetFreeSystemResources(GFSR_SYSTEMRESOURCES))
                       + ' / ' + IntToStr(GetFreeSystemResources(GFSR_GDIRESOURCES))
                       + ' / ' + IntToStr(GetFreeSystemResources(GFSR_USERRESOURCES)) + ' %';
        FreeDisk.Caption := IntToStr(DiskFree(3) div 1000000) + ' MB';

        ShowModal;
      end
{....}
Beide sind in einer jeweiligen Unit.

Den kompletten Source-Code kann man sich übrigens auf http://diuf.unifr.ch/softeng/student...t/ftp-nsd.html besorgen, falls man die komplette Übersicht haben möchte.

Ich werde jetzt erstmal die betroffenen Passagen ausbauen und einfach erstmal weg lassen, soweit ich das richtig einschätze sind es sowieso nur die Print-Steuerung und die SystemInfos die da fehlen würden. Was mich nicht sonderlich stört.


Greetz ThY
  Mit Zitat antworten Zitat