Recent

Author Topic: I'm showing a form but...  (Read 6468 times)

Anonymous

  • Guest
I'm showing a form but...
« on: February 25, 2004, 03:30:53 am »
in my program when i click a button it shows a form (form2.show;), but thats it.. the form doesnt activate itself (it should add items to a combobox).. how do i make the form do what its supposed to?

i tried the same thing in delphi, and it worked.... whats the deal?

neli

  • Jr. Member
  • **
  • Posts: 86
I'm showing a form but...
« Reply #1 on: February 25, 2004, 09:23:44 am »
What event are you using to 'activate'? The OnFormShow event should work.

Micha.

Anonymous

  • Guest
I'm showing a form but...
« Reply #2 on: February 25, 2004, 05:52:36 pm »
That doesnt work either... in less my combobox code is wrong..
isnt this how you add stuff to the combobox?
combobox1.items.add('stuff');

neli

  • Jr. Member
  • **
  • Posts: 86
I'm showing a form but...
« Reply #3 on: February 27, 2004, 12:01:02 am »
Hmm. What I'd do is putting a ShowMessage or WriteLn in that FormShow function, so you're sure if it's called or not. If it's not while it should, add a bug report ;).

Micha.

Anonymous

  • Guest
I'm showing a form but...
« Reply #4 on: March 09, 2004, 06:54:57 pm »
i downloaded the lastest version and it still doesnt work... can someone please try to have 2 forms and a button on the first one and a combobox on the second? the first one should open the 2nd form which adds items to the combobox. and then post the example here?

Drewski

  • Jr. Member
  • **
  • Posts: 55
I'm showing a form but...
« Reply #5 on: March 09, 2004, 10:44:57 pm »
Sorry for the long post. Here's what I tried hope this helps:

Added a button to Form1.
Added another Form to the project. (Form2)
Added a ComboBox to Form2.  Here's the complete code

 //// begin unit1
unit unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation
uses unit2;

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var
Count: Integer;
begin
  //Form2.Show;       // Did work if Form2 wasn't visible. Triggered the
                      // OnShow Event the first time only.
  //Form2.Activate;   // Didn't seem to do anything. Did trigger the
                      // OnActivate Event each time but focus was not changed.

  // This is crude but it worked, and triggered the OnShow Event each time.
  Form2.Visible := False;
  Form2.Visible := True;
end;

initialization
  {$I unit1.lrs}

end.
//// end unit1

//// begin unit2
unit unit2;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls;

type
  TForm2 = class(TForm)
    ComboBox1: TComboBox;
    procedure Form2Show(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form2: TForm2;

implementation

{ TForm2 }

procedure TForm2.Form2Show(Sender: TObject);
var
Count: Integer;
begin
  Count := ComboBox1.Items.Count + 1;
  ComboBox1.Items.Add('Item' + IntToStr(Count));
end;

initialization
  {$I unit2.lrs}

end.
//// end unit2

 

TinyPortal © 2005-2018