unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Grids;
type
{ TForm1 }
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
procedure PopulateDrugData;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.PopulateDrugData;
const
DrugData: array[0..11, 0..4] of string = (
('Cannabis', 'Weed, Pot, Ganja, Bud, 420', 'Dried flowers, edibles', 'Relaxation, hunger, euphoria', 'Can impair memory/reaction; low overdose risk'),
('Cocaine', 'Coke, Blow, Snow, Yayo', 'White powder', 'Energy, confidence, alertness', 'Heart stress, addiction, often laced'),
('Crack Cocaine', 'Crack, Rocks', 'Hard crystals', 'Intense short high', 'Highly addictive, increased overdose risk'),
('MDMA', 'Molly, Ecstasy, E, X', 'Pills, powder, crystals', 'Empathy, energy, sensory enhancement', 'Dehydration, serotonin syndrome'),
('Methamphetamine', 'Meth, Crystal, Tina, Ice, Crank', 'Crystals, powder', 'Intense focus, energy', 'Extreme addiction, psychosis'),
('Heroin', 'Smack, H, Dope, Skag', 'Brown/white powder, tar', 'Euphoria, sedation', 'Overdose, high dependency'),
('Fentanyl', 'Fent, China Girl, Apache, Dance Fever', 'Powder, fake pills', 'Powerful sedation, pain relief', 'Microscopic dose = fatal; often contaminates others'),
('GHB', 'Gina, G, Liquid X, Fantasy', 'Clear liquid, powder', 'Sedation, lowered inhibitions', 'Date rape drug; memory loss; coma risk'),
('Ketamine', 'K, Special K, Kit Kat', 'Liquid, powder', 'Disconnection, hallucinations', 'Bladder damage, confusion'),
('LSD', 'Acid, Tabs, Blotters', 'Blotter paper, drops', 'Visual/auditory hallucinations', 'Bad trips, anxiety'),
('Psilocybin', 'Shrooms, Magic Mushrooms, Boomers', 'Dried mushrooms', 'Hallucinations, introspection', 'Nausea, confusion'),
('Benzodiazepines', 'Xanax, Bars, Benzos', 'Pills', 'Sedation, anxiety reduction', 'Dependency, dangerous with alcohol')
);
const
Headers: array[0..4] of string = (
'Drug Name', 'Street Names', 'Form', 'Common Effects', 'Risks / Notes'
);
var
i, j: Integer;
begin
StringGrid1.ColCount := 5;
StringGrid1.RowCount := Length(DrugData) + 1;
// Set headers
for j := 0 to 4 do
StringGrid1.Cells[j, 0] := Headers[j];
// Fill data
for i := 0 to High(DrugData) do
for j := 0 to 4 do
StringGrid1.Cells[j, i + 1] := DrugData[i, j];
// Autosize columns
for j := 0 to 4 do
StringGrid1.ColWidths[j] := 120;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
PopulateDrugData;
StringGrid1.Options := StringGrid1.Options + [goColSizing, goRowSelect];
StringGrid1.AutoSizeColumns;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
// Resize the form to fit the grid exactly
Width := StringGrid1.Left + StringGrid1.Width + 16; // +16 for padding or scrollbar
Height := StringGrid1.Top + StringGrid1.Height + 39; // +39 accounts for titlebar, borders
// writeln('Width:'+inttostr(Width),' Height:'+inttostr(Height));
// writeln(StringGrid1.Width);
end;
end.