Been reading/messing around with various bitmap/canvas/form tutorials on here. For the life of me I cannot get anything to draw on a Form's canvas. I can draw to a bitmap and slam that over, but not directly to the Form.
What's wrong with this?
Simba Code:
program New;
var
Form: TForm;
procedure InitForm;
begin
Form := TForm.Create(nil);
with Form do
begin
Position := poScreenCenter;
Width := 500;
Height := 500;
Caption := 'Form Test';
BorderStyle := bsDialog;
Color := clWhite;
Canvas.Pen.Color := clBlack;
Canvas.Pen.Width := 1;
Canvas.Brush.Color := clBlack;
Canvas.Brush.Style := bsSolid;
Canvas.Rectangle(100, 100, 200, 200);
end;
end;
procedure ShowFormModal;
begin
Form.ShowModal;
end;
procedure SafeProcCall(Proc: String);
var
V: TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall(Proc, V);
end;
begin
SafeProcCall('InitForm');
SafeProcCall('ShowFormModal');
end.
Edit: Solved my own problem: As someone answered in another thread the form gets cleared/erased on a repaint. Which means when I show the form (and the form gets repainted) my rectangle gets erased. 
Simba Code:
procedure OnFormPaint(Sender: TObject);
begin
with Form.Canvas do
begin
Pen.Color := clBlack;
Pen.Width := 1;
Brush.Color := clBlack;
Brush.Style := bsSolid;
Rectangle(100, 100, 200, 200);
end;
end;
// Down in InitForm
Form.OnPaint := @OnFormPaint;