Jump to content

HowTo : check if form is 'active/showed'


mierlp

Recommended Posts

Hi,

 

On my form there a several datasources. The every datasource has a onStateChange with the 
​following code to enable/disable buttons. This works like i want.

procedure TFormTableProduction.dsProductionBasicDayStateChange(
  Sender: TObject);
begin
    if dmProduction.ProductionBasicDay.State in [dsBrowse] then begin
       FormTableProductionDay.UniBitBtn_Add.Enabled    := True;
       FormTableProductionDay.UniBitBtn_Delete.Enabled := True;
       FormTableProductionDay.UniBitBtn_Save.Enabled   := False;
       FormTableProductionDay.UniBitBtn_Cancel.Enabled := False;
    end;
    if dmProduction.ProductionBasicDay.State in [dsInsert,dsEdit] then begin
       FormTableProductionDay.UniBitBtn_Add.Enabled    := False;
       FormTableProductionDay.UniBitBtn_Delete.Enabled := False;
       FormTableProductionDay.UniBitBtn_Save.Enabled   := True;
       FormTableProductionDay.UniBitBtn_Cancel.Enabled := True;
    end;
end;

Attached sample form. When the user hits the button with the (dutch) text 'Beheren productie dagen'

then a second form will be opened for adding prodution days. Because the datasource for this table

is also on the first form the buttons for addind/editing in this form  are not responding to the state.

 

In the windows variant of the application i use :

  if ( Assigned( FormTableProductionDay ) ) then begin

   ...my code
  end;

But in uniGui thats not working...how can i solve this?

 

 

 

 

 

 

post-510-0-61769400-1503080787_thumb.png

Link to comment
Share on other sites

if i understand you correctly...

 

 

i use a array - in this array i write every created form (and delete the ntry if i close the form)

 

So - i know every open form - and can handle the 2 differnet situaltions (if its already open or if i must create it)

 

HTH

Erich

// write form in array

procedure ....UniFormCreate(Sender: TObject);
begin

mainform.fensteranzahl:=mainform.fensteranzahl+1;
mainform.fensterliste[mainform.fensteranzahl]:=self.Name;
// delete form in array

procedure ...UniFormClose(Sender: TObject;  var Action: TCloseAction);
var 
    x:Integer;
    y:Integer;
begin
// Aktuelles fenster aus der Fensterliste löschen
    y:=1;
    for x:=1 to mainform.fensteranzahl do
    begin
      if mainform.fensterliste[x]=self.Name then y:=y+1;
      mainform.fensterliste[x] := mainform.fensterliste[y];
      y:=y+1;
    end;
    mainform.fensteranzahl:=mainform.fensteranzahl-1;
end;
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...