home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / zkuste / delphi / nastroje / d23456 / PRODEL.ZIP / PROFONLI.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  2002-04-03  |  4.6 KB  |  208 lines

  1. //PROFILE-NO
  2. unit Profonli;
  3. interface
  4.  
  5. uses
  6.   Windows,
  7.   Forms, Controls, StdCtrls,
  8.   Classes,
  9.   SysUtils, ComCtrls, ExtCtrls;
  10. {$H-}
  11. {$V-}
  12. {$O-}
  13. {$D-}
  14. {$B-}
  15. {$Q-}
  16. {$I-}               
  17. {$R-}       
  18. {$A+}
  19. {$W+}
  20. {$J+}
  21. {$T+}
  22. {$X+}
  23.  
  24. PROCEDURE ProfOnlineOperation;
  25.  
  26. TYPE
  27.   TOnlineProform = class(TForm)
  28.     Button1: TButton;
  29.     Button2: TButton;
  30.     Button3: TButton;
  31.     Edit1: TEdit;
  32.     GroupBox1: TGroupBox;
  33.     Button4: TButton;
  34.     Panel1: TPanel;
  35.     CycBut: TCheckBox;
  36.     MinLab: TLabel;
  37.     FrequAnz: TTrackBar;
  38.     Label6: TLabel;
  39.     CycTimer: TTimer;
  40.     procedure StarteMessung(Sender: TObject);
  41.     procedure StoppeMessung(Sender: TObject);
  42.     procedure Anhaengen(Sender: TObject);
  43.     procedure Erzeugen(Sender: TObject);
  44.     procedure ResultatLoeschen(Sender: TObject);
  45.     procedure Zerstoeren(Sender: TObject);
  46.     procedure TickChange(Sender: TObject);
  47.     procedure ActDeact(Sender: TObject);
  48.     procedure CycAppend(Sender: TObject);
  49.   private
  50.     { Private-Deklarationen }
  51.     procedure ButtonOnOff;
  52.   public
  53.     { Public-Deklarationen }
  54.     IstAktiv : Boolean;
  55.   end;
  56.  
  57. var
  58.   OnlineProform: TOnlineProform;
  59.  
  60. {$R *.dfm}
  61.  
  62. IMPLEMENTATION
  63. USES
  64.   Profint;
  65.  
  66. FUNCTION  GetMHZ95     : Integer; external 'PROFMEAS.DLL';
  67. FUNCTION  ProfIstAktiv : Boolean; external 'PROFMEAS.DLL';
  68. PROCEDURE ProfResultatLoeschen;   external 'PROFMEAS.DLL';
  69. FUNCTION  GetPDVersion : PChar;   external 'PROFMEAS.DLL';
  70.  
  71.  
  72. VAR
  73.   winxpos : Integer;
  74.   winypos : Integer;
  75.   toppos  : Integer;
  76.  
  77. PROCEDURE ProfOnlineOperation;
  78. VAR
  79.   hs : String;
  80. BEGIN
  81.   Application.CreateForm(TOnlineProForm, OnlineProForm);
  82.   OnLineProForm.Caption := 'ProDelphi - online operation';
  83.   Str(GetMHz95,hs);
  84.   OnlineProForm.Edit1.text := 'CPU performs with ' + hs + ' MHz';
  85. END;
  86.  
  87. FUNCTION GetIniFile : String;
  88. BEGIN
  89.   Result := ExtractFilePath(ParamStr(0)) + 'profile.ini';
  90. END;
  91.  
  92. procedure TOnlineProform.StarteMessung(Sender: TObject);
  93. begin
  94.   ProfActivate;
  95.   ButtonOnOff;
  96. end;
  97.  
  98. procedure TOnlineProform.StoppeMessung(Sender: TObject);
  99. begin
  100.   ProfDeactivate;
  101.   ButtonOnOff;
  102. END;
  103.  
  104. procedure TOnlineProform.Anhaengen(Sender: TObject);
  105. VAR
  106.   txt : Array[0..255] OF Char;
  107. BEGIN
  108.   StrPLCopy(txt, OnlineProForm.Edit1.Text, 255);
  109.   ProfSetComment(txt);
  110.   ProfAppendResults(FALSE);
  111. END;
  112.  
  113. procedure TOnlineProform.Erzeugen(Sender: TObject);
  114. BEGIN
  115.   IF winxpos <> -1 THEN BEGIN
  116.     Left := winxpos;
  117.     Top  := Winypos;
  118.   END;
  119.   IF TopPos <> 0 THEN
  120.     SetWindowPos(handle, HWND_TOPMOST, 0, 0, 0, 0,
  121.                  SWP_NOSIZE OR SWP_NOMOVE OR SWP_SHOWWINDOW);
  122.   ButtonOnOff;
  123. END;
  124.  
  125. procedure TOnlineProform.ButtonOnOff;
  126. BEGIN
  127.   IF ProfIstAktiv = TRUE THEN BEGIN
  128.     Button1.Enabled := FALSE;
  129.     Button2.Enabled := TRUE;
  130.     END
  131.   ELSE BEGIN
  132.     Button2.Enabled := FALSE;
  133.     Button1.Enabled := TRUE;
  134.   END;
  135. END;
  136.  
  137. procedure TOnlineProform.ResultatLoeschen(Sender: TObject);
  138. BEGIN
  139.   ProfResultatLoeschen;
  140. END;
  141.  
  142. procedure TOnlineProform.Zerstoeren(Sender: TObject);
  143. VAR
  144.   rect   : TRect;
  145.   xp, yp : Array[0..24] OF Char;
  146.   namec  : Array[0..255] OF Char;
  147. BEGIN
  148.   StrPCopy(namec, GetIniFile);
  149.   GetWindowRect(handle, rect);
  150.   Str(rect.top, yp);
  151.   Str(rect.left, xp);
  152.   WritePrivateProfileString('PROFILER','SCREEN-X',xp,namec);
  153.   WritePrivateProfileString('PROFILER','SCREEN-Y',yp,namec);
  154. END;
  155.  
  156. PROCEDURE InitUnit;
  157. VAR
  158.   namec   : Array[0..255] OF Char;
  159.   tmpbuff : Array[0..255] OF Char;
  160.   anzeige : Integer;
  161. BEGIN
  162.   StrPCopy(namec, GetIniFile);
  163.   GetPrivateProfileString('PROFILER','SCREEN-X','-1',tmpbuff,SizeOf(tmpbuff)-1,namec);
  164.   VAL(tmpbuff, winxpos, anzeige);
  165.   IF anzeige <> 0 THEN
  166.     Winxpos := -1;
  167.   GetPrivateProfileString('PROFILER','SCREEN-Y','-1',tmpbuff,SizeOf(tmpbuff)-1,namec);
  168.   VAL(tmpbuff, winypos, anzeige);
  169.   IF anzeige <> 0 THEN
  170.     Winypos := -1;
  171.   GetPrivateProfileString('PROFILER','ONTOP','0',tmpbuff,SizeOf(tmpbuff)-1,namec);
  172.   VAL(tmpbuff, toppos, anzeige);
  173. END;
  174.  
  175. procedure TOnlineProform.TickChange(Sender: TObject);
  176. VAR
  177.   hs : String;
  178. begin
  179.   CycTimer.Enabled := FALSE;
  180.   Str(FrequAnz.Position, hs);
  181.   MinLab.Caption := hs;
  182.   CycTimer.Interval := FrequAnz.Position * 60000;
  183.   IF CycBut.Checked = TRUE THEN
  184.     CycTimer.Enabled := TRUE;
  185. end;
  186.  
  187. procedure TOnlineProform.ActDeact(Sender: TObject);
  188. begin
  189.   IF CycBut.Checked = TRUE THEN BEGIN
  190.     CycTimer.Enabled := TRUE;
  191.     FrequAnz.Visible := FALSE;
  192.     END
  193.   ELSE BEGIN
  194.     CycTimer.Enabled := FALSE;
  195.     FrequAnz.Visible := TRUE;
  196.   END;
  197. end;
  198.  
  199. procedure TOnlineProform.CycAppend(Sender: TObject);
  200. BEGIN
  201.   Edit1.Text := DateTimeToStr(Now);
  202.   Anhaengen(Sender);
  203. end;
  204.  
  205. INITIALIZATION
  206.   InitUnit;
  207. END.
  208.