the problem was when I create a new form in runtime, and set active page before I use showmodal, the command seem to be ignored, however if I show it as normal "show" it works.
I made a workaround for this for people interrested by using a postmessage so the command can be triggered after the modal form is shown.
...
private
Procedure WM_UserPage(var Msg: TMessage); message WM_USER+1;
...
procedure TForm2.UserPage(var Msg: TMessage);
begin
with pagecontrol do
case Msg.LParam of
0: activepage := tabsheet1;
1: activepage := tabsheet2;
2: activepage := tabsheet3;
end;
end;
from my first form I call :
procedure TForm1.ShowPage(PageNumber: integer);
var
MyForm : TForm2;
begin
MyForm := TForm2.create(self);
with MyForm do
try
PostMessage(MyForm.Handle, WM_USER+1, 0, PageNumber);
showmodal;
finally
FreeAndNil(MyForm);
end;
end;