Hi all

Hi all,

I have some hard times with Frames having event handler.
My frame is really basic :
- 1 Datasource
- 1 Query
- 1 grid
- 1 datetimepicker
- 1 combobox
- 1 button

Button has an OnClick handler.In this handler, I'm setting some query parameter and finally opening it to display data :

procedure TfrPicpic.btEvenementClick(Sender: TObject);
begin
grid.BeginUpdate;
TimeLine.BeginUpdate;
try
Query.Close;
query.ParamByName('Date').AsDate := DateTime.Date;
query.ParamByName('Id').AsInteger := Combobox.ItemIndex + 1;
query.Open;
finally
grid.endUpdate;
TimeLine.endUpdate;
try
end;

I've so far too issue :
- I'm not able to change my DateTimePicker.Date value after creating my frame
- Code inside the button handler doesn't correctly read properties from combobox and datetimepicker. Looks like values are taken from my frame designed in the IDE.

Is there an easy way to overcome this ? Should I associate my button handler at runtime too ?

Here is the code used to dynamically create my frames :

var
i : integer;
ATabSheet: TTabSheet;
fMyFrame : TfrPicpic;

begin

//freeing existing tabsheets
if fmMain.pcProduction.PageCount > 0 then
for i := fmMain.pcProduction.PageCount - 1 downto 0 do
fmMain.pcProduction.Pages[i].Free;

//opening existing devices
qrPicpics.open;
while not(qrPicpics.Eof) do
Begin
//adding tabsheet to pagecontrol
ATabSheet := TTabSheet.Create(fmMain.pcProduction);
ATabSheet.PageControl := fmMain.pcProduction;
ATabSheet.Name := 'tsPICPIC'+qrPicpics.RecNo.ToString;
ATabSheet.Caption := qrPicpics.FieldByName('Description').AsString;

//adding frame to tabsheet
fMyFrame := TfrPicpic.Create(fMyFrame);
fMyFrame.Name := 'frPICPIC'+qrPicpics.RecNo.ToString;

fMyFrame.Align := alClient;
fMyFrame.Parent := ATabSheet;
fMyFrame.Connection.Server := qrPicpics.FieldByName('host').AsString;
fMyFrame.Connection.Username := 'dodo';
fMyFrame.Connection.Password := '000';
fMyFrame.tmPicpic.Enabled:=true;
fMyFrame.btEvenement.Enabled := false;
fMyFrame.btAbaque.Enabled:= false;

fMyFrame.DateTimePicker.Date := now; // this is never set in my frame
fMyFrame.Combobox.ItemIndex := 1; // this is never set in my frame

qrPicpics.Next;
End;
qrPicpics.close;
end;



Comments