SRL Archive - OSR Help

Simba Form Help


gerauchert

2012-07-05 14:31:05

EDIT3: New problem:

Can't get a TPopupMenu to work at all… is there some difference in the coding between scar and simba?


program new;
{$i SRL/SRL.simba}
var
Form1_1: TForm;
SessionTagPopup: TPopUpMenu;
ExerciseTags: array of TMenuItem;
SampleTags: TStringArray;
MenuButton: TButton;

Procedure MenuPopup(Sender: TObject);
var
x,y: Integer;
begin
GetMousePos(x,y);
SessionTagPopup.POPUP(x,y);
end;
Procedure InitForm;
var
i: Integer;
begin
SampleTags := ['Upper','Lower','Biceps','Triceps','Quads'];
with Form1_1 do
begin
Form1_1 := CreateForm;
Left := 325;
Top := 187;
Caption := 'Form1';
ClientHeight := 700;
ClientWidth := 700;
Color := clBtnFace;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Tahoma';
Font.Style := [];
PixelsPerInch := 96;
Position := poScreenCenter;
end;

SetLength(ExerciseTags,Length(SampleTags));
SessionTagPopup := TPopupMenu.CREATE(Form1_1);
for i := 0 to High(SampleTags) do
begin
ExerciseTags[i] := TMenuItem.CREATE(Form1_1);
ExerciseTags[i].Caption := SampleTags[i];
SessionTagPopup.ITEMS.ADD(ExerciseTags[i]);
end;

MenuButton := TButton.Create(Form1_1);
with MenuButton do
begin
Parent := Form1_1;
Left := 220;
Top := 460;
Width := 90;
Height := 50;
Caption := 'MenuButton!';
OnClick := @MenuPopup;
end;



end;
procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
Form1_1.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

Procedure ShowPlayerForm;
begin
SafeInitForm;
SafeShowFormModal;
end;

Begin
ShowPlayerForm;
End.

Daniel

2012-07-06 09:04:26

Yeah, from testing just then, it appears that destroying a tab sheet does not yet work with the in-built method :( You could however achieve the same result by doing the following:

procedure ExitSession(Sender: TObject);
begin
PageControl1.ActiveTab.Parent := nil;
PageControl1.ActiveTab := nil;
PageControl1.SelectNextPage(False, True);
end;

Hope I helped,
Daniel.

gerauchert

2012-07-11 17:16:14

Thanks daniel, got it all fixed up :)

Unfortunately, the TPopupMenu is not working for me now… any thoughts?

Daniel

2012-07-13 02:21:49

From: gerauchert
Thanks daniel, got it all fixed up :)

Unfortunately, the TPopupMenu is not working for me now… any thoughts?


Define not working? Did you assign it to anything (i.e. Form.PopupMenu := x; )?