home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / chap15 / strpcx / main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-21  |  1.2 KB  |  57 lines

  1. unit Main;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: StrPCX }
  5.  
  6. { This program shows how to use a TStringGrid
  7.   component.
  8.  
  9.   I used this program when creating a screen shot
  10.   for the book. I've kept it in this subdirectory
  11.   so it will end up on the CD, which is someplace
  12.   where I can find it in case I want to use it again. }
  13.  
  14. interface
  15.  
  16. uses
  17.   SysUtils, WinTypes, WinProcs,
  18.   Messages, Classes, Graphics,
  19.   Controls, Forms, Dialogs,
  20.   StdCtrls, Buttons, Grids;
  21.  
  22. type
  23.   TForm1 = class(TForm)
  24.     StringGrid1: TStringGrid;
  25.     procedure FormCreate(Sender: TObject);
  26.   private
  27.     { Private declarations }
  28.   public
  29.     { Public declarations }
  30.   end;
  31.  
  32. var
  33.   Form1: TForm1;
  34.  
  35. implementation
  36.  
  37. {$R *.DFM}
  38.  
  39. procedure TForm1.FormCreate(Sender: TObject);
  40. const
  41.   S: string = 'This is a string on the heap';
  42.   AddressStr: string = '0F02';
  43. var
  44.   i: Integer;
  45. begin
  46.   for i := 0 to 40 do
  47.     StringGrid1.Cells[i, 0] := IntToStr(i);
  48.   for i := 0 to 26 do
  49.     StringGrid1.Cells[0, i] := Chr(i + 65);
  50.   for i := 1 to Length(S) do
  51.     StringGrid1.Cells[i + 2, 5] := S[i];
  52.   for i := 1 to Length(AddressStr) do
  53.     StringGrid1.Cells[i + 12, 15] := AddressStr[i];
  54. end;
  55.  
  56. end.
  57.