home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / COLORDLL / MAIN.PAS < prev    next >
Pascal/Delphi Source File  |  1998-05-12  |  1KB  |  47 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6. //  ShareMem,  { Not required by this example }
  7.   Windows, SysUtils, Classes, Graphics, Controls,
  8.   Forms, Dialogs, StdCtrls;
  9.  
  10. type
  11.   TMainForm = class(TForm)
  12.     Button1: TButton;
  13.     Memo1: TMemo;
  14.     procedure Button1Click(Sender: TObject);
  15.   private
  16.     { Private declarations }
  17.   public
  18.     { Public declarations }
  19.   end;
  20.  
  21. var
  22.   MainForm: TMainForm;
  23.  
  24. implementation
  25.  
  26. {$R *.DFM}
  27.  
  28. {- Declare external function in the Colorlib.Dll }
  29. function FBGetColors(var FColor, BColor: TColor): WordBool; far;
  30.   external 'Colorlib.dll';
  31.  
  32. {- Activate color dialog in the Colorlib.Dll }
  33. procedure TMainForm.Button1Click(Sender: TObject);
  34. var
  35.   FColor, BColor: TColor;
  36. begin
  37.   FColor := Font.Color;    { Form's text color }
  38.   BColor := Color;         { Window background color }
  39.   if FBGetColors(FColor, BColor) then  { Call DLL ! }
  40.   begin
  41.     Memo1.Color := BColor;       { Assign window color }
  42.     Memo1.Font.Color := FColor;  { Assign text color }
  43.   end;
  44. end;
  45.  
  46. end.
  47.