home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / windows / pascal / turbpa / uhr.pa_ / uhr.pa
Encoding:
Text File  |  1993-03-07  |  6.5 KB  |  209 lines

  1. {*************************************************************************}
  2. {*                                                                       *}
  3. {* Project :                                                             *}
  4. {* Unit    : Uhr.Pas                                                     *}
  5. {*                                                                       *}
  6. {* Author  : Uwe Janiak                                                  *}
  7. {* Firm    :                                                             *}
  8. {* Adress  : 1055 Berlin, Grellstra▀e 63                                 *}
  9. {*                                                                       *}
  10. {* Created : Montag, den 10. August 1992 um 22:06:06 Uhr                 *}
  11. {* Update  :                                                             *}
  12. {*                                                                       *}
  13. {* Version : Basic source created by Dialog Engine 1.5                   *}
  14. {*                                                                       *}
  15. {*************************************************************************}
  16.  
  17. {$N+,F+}
  18. Unit Uhr;
  19.  
  20. interface uses WinTypes, WinProcs, WObjects, WinTools, Strings;
  21.  
  22. CONST     {Im Dialog verwendete ID-Codes der Elemente}
  23.  
  24.           id_Uhr_TEST=100;
  25.           id_Uhr_Help=998;
  26.  
  27. TYPE     {Fuer den Dialog verwendeter Datensatz}
  28.  
  29.           TRecUhr= record
  30.                 ExitID:word;
  31.                 vTEST:string;
  32.           end;
  33.  
  34. VAR       VRecUhr:TRecUhr;
  35.  
  36. TYPE      {Definition des verwendeten Dialogfensters}
  37.           PUhr = ^TUhr;
  38.           TUhr = Object(TDlgWindow)
  39.  
  40.             DialogBackground:HBrush;
  41.             DialogTextColor:Longint;
  42.             DialogBkColor:Longint;
  43.             ResName:string;
  44.             FirstTimer:Integer;
  45.             TimerInstalled:Boolean;
  46.             ts_TEST:PSTATIC;
  47.  
  48.             {Konstruktionsmethoden}
  49.             constructor Init(AParent:PWindowsObject;Name:PChar);
  50.             procedure SetupWindow;virtual;
  51.             procedure wmColor(var Msg:TMessage);virtual wm_CtlColor;
  52.             procedure wmTimer(var Msg:TMessage);virtual wm_first + wm_timer;
  53.             procedure OK(var Msg:TMessage);virtual id_first + id_Ok;
  54.             procedure Cancel(var Msg:TMessage);virtual id_first + id_Cancel;
  55.             procedure Help(var Msg:TMessage);virtual id_first + id_Uhr_Help;
  56.  
  57.             {Reaktionsmethoden}
  58.             procedure wmTEST(var Msg:TMessage); virtual id_first+id_Uhr_TEST;
  59.  
  60.             {Lokale Methoden}
  61.             function SaveDataToRecord:boolean;
  62.             procedure CreateColorElements;
  63.             procedure DeleteColorElements;
  64.  
  65.           end;
  66.  
  67. implementation
  68.  
  69. {$R C:\TPW\SOURCER\UHR.RES}
  70.  
  71. {*************************************************************************}
  72. {*              Routinen zur Verwaltung des Dialogs                      *}
  73. {*************************************************************************}
  74.  
  75. constructor TUhr.Init(AParent:PWindowsObject;Name:PChar);
  76.   begin
  77.     TDlgWindow.Init(AParent,Name);
  78.     StrCopy(@ResName[1],Name);Str_Pas(ResName);
  79.     CreateColorElements;
  80.     ts_TEST:=New(PSTATIC,InitResource(@self,id_Uhr_TEST,255));
  81.   end;
  82.  
  83. procedure TUhr.SetupWindow;
  84.   var s:string;j:word;
  85.   begin
  86.     TDlgWindow.SetupWindow;
  87.     With VRecUhr do
  88.       begin
  89.         s:=vTEST+#0;
  90.         ts_TEST^.SetText(@s[1]);
  91.       end;
  92.     DlgPos(hWindow,ResName,WP_Load);
  93.     FirstTimer:=0;
  94.     TimerInstalled:=SetTimer(hWindow,$ff,100,nil)<>0;
  95.     If not TimerInstalled then message('Die Systemresource fⁿr'+
  96.       'den Starttimer ist nicht verfⁿgbar!',1);
  97.   end;
  98.  
  99.  
  100. procedure TUhr.wmColor;
  101.  
  102.   function id(code_von,code_bis:word):boolean;
  103.   var i:word;ok:boolean;
  104.   begin
  105.     i:=code_von;
  106.     repeat
  107.       ok:=getdlgitem(hwindow,i)=msg.lparamlo;
  108.       inc(i);
  109.     until ok or (i>code_bis);
  110.     id:=ok;
  111.   end;
  112.  
  113.   var s:string;c,i,no:word;pw:twindow;
  114.   begin
  115.     no:=GetDlgCtrLID(msg.wparam);
  116.     SetBkColor(Msg.wParam,DialogBkColor);
  117.     SetTextColor(Msg.wParam,DialogTextColor);
  118.     Msg.Result:=DialogBackground;
  119.   end;
  120.  
  121. procedure TUhr.OK;
  122.   var i:integer;
  123.   begin
  124.     If SaveDataToRecord then exit;
  125.     DeleteColorElements;
  126.     DlgPos(hWindow,ResName,WP_Save);
  127.     If TimerInstalled then KillTimer(hWindow,$FF);
  128.     EndDlg(i);
  129.   end;
  130.  
  131. procedure TUhr.Cancel;
  132.   var i:integer;
  133.   begin
  134.     DeleteColorElements;
  135.     DlgPos(hWindow,ResName,WP_Save);
  136.     If TimerInstalled then KillTimer(hWindow,$FF);
  137.     EndDlg(i);
  138.   end;
  139.  
  140. procedure TUhr.Help;
  141.   begin
  142.     message('Sie haben Hilfe zum Dialog TUhr angefordert. '+
  143.             'Bitte fⁿgen Sie einen WinHelp-Aufruf in die Methode Help'+
  144.             ' ein, oder rufen Sie Ihre eigene Hilferoutine auf.',17);
  145.   end;
  146. procedure TUhr.wmTimer;
  147.   var i:integer;s:string;
  148.   begin
  149.     Inc(FirstTimer);
  150.     If FirstTimer=1 then
  151.       begin
  152.         If TimerInstalled then KillTimer(hWindow,$FF);
  153.         TimerInstalled:=SetTimer(hWindow,$FF,1000,nil)<>0;
  154.         If not TimerInstalled then message('Die Systemresource fⁿr'+
  155.           'den Standardtimer ist nicht verfⁿgbar!',1);
  156.         exit;
  157.       end;
  158.  
  159.     {------ Hier die Standardbehandlung fⁿr das Timerevent ergΣnzen! ----}
  160.     s:=timestring+#0;
  161.     setwindowtext(hwindow,@s[1]);
  162.     
  163.   end;
  164. procedure TUhr.CreateColorElements;
  165.   begin
  166.     DialogBackground:=CreateSolidBrush($FFFFFF);
  167.     DialogTextColor:=$000000;
  168.     DialogBkColor:=$FFFFFF;
  169.   end;
  170.  
  171. procedure TUhr.DeleteColorElements;
  172.   begin
  173.     DeleteObject(DialogBackground);
  174.   end;
  175.  
  176. {*************************************************************************}
  177. {*              Reaktionsmethoden der einzelnen Dialogelemente           *}
  178. {*************************************************************************}
  179.  
  180. procedure TUhr.wmTEST(var Msg:TMessage);
  181.   begin
  182.     DefWndProc(Msg);
  183.   end;
  184.  
  185. {*************************************************************************}
  186. {*              Lokale Routinen zur Verwaltung des Dialogs               *}
  187. {*************************************************************************}
  188.  
  189. function TUhr.SaveDataToRecord:boolean;
  190.   begin
  191.     SaveDataToRecord:=false;
  192.     With VRecUhr do
  193.       begin
  194.         ts_TEST^.GetText(@vTEST[1],255);str_pas(vTEST);
  195.       end;
  196.   end;
  197.  
  198. begin
  199.  
  200. {*************************************************************************}
  201. {*        Belegung der Dialogelemente nach dem Programmstart             *}
  202. {*************************************************************************}
  203.  
  204.     With VRecUhr do
  205.       begin
  206.         vTEST:='';
  207.       end;
  208. end.
  209.