?
Solved

TFrame Function Problem

Posted on 2009-05-13
4
Medium Priority
?
219 Views
Last Modified: 2012-05-06
Hi I'd like to be able to activate a action within a function within a tframe. though for some reason I can't do it?
object Frame2: TFrame2
  Left = 0
  Top = 0
  Width = 320
  Height = 240
  TabOrder = 0
  TabStop = True
  object Edit1: TEdit
    Left = 72
    Top = 48
    Width = 121
    Height = 21
    TabOrder = 0
    Text = 'Edit1'
  end
  object Button1: TButton
    Left = 72
    Top = 75
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 1
    OnClick = Button1Click
  end
end
 
 
 
 
==========================================================
 
 
 
unit Unit2;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
 
type
  TFrame2 = class(TFrame)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
implementation
 
{$R *.dfm}
 
function Start:string;
begin
frame2.edit1.text:='tt';
end;
 
function finish:string;
begin
start;
 
 
end;
 
 
procedure TFrame2.Button1Click(Sender: TObject);
begin
finish;
end;
 
end.

Open in new window

0
Comment
Question by:eNarc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 24377849
why do you mix methods and proc/funcs like this ?
what are you trying to achieve ?

next to that your function results are not defined ...

this may be just a sample but it brings just more questions than simplify

when calling a function from a frame from within the form and this is not a method of the frame, it is better to pass the form and/or frame as a parameter
0
 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 2000 total points
ID: 24377892
something like this ?
object Frame2: TFrame2
  Left = 0
  Top = 0
  Width = 320
  Height = 240
  TabOrder = 0
  TabStop = True
  object Edit1: TEdit
    Left = 72
    Top = 48
    Width = 121
    Height = 21
    TabOrder = 0
    Text = 'Edit1'
  end
  object Button1: TButton
    Left = 72
    Top = 75
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 1
    OnClick = Button1Click
  end
end
 
 
 
 
==========================================================
 
 
 
unit Unit2;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
 
type
  TFrame2 = class(TFrame)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
implementation
 
{$R *.dfm}
 
function Start(aFrame: TFrame):string;
begin
  //it's a function, so return a result 
  // or change it to a procedure
  Result := '';
  if aFrame is TFrame2 then 
    Result := TFrame2(aFrame).Edit1.Text;
  //frame2.edit1.text:='tt';
end;
 
function finish(aFrame: TFrame):string;
begin
  Result := start(aFrame);
end;
 
 
procedure TFrame2.Button1Click(Sender: TObject);
begin
  finish(Self);
end;
 
end.

Open in new window

0
 
LVL 5

Author Comment

by:eNarc
ID: 24378823
thankyou, your a life saver, you truly are, I thought it was something self, though when I did self, it declared it as being unknown, and now I see how you've done it :D and yea, it has to be declared, should have known hehe thankyou :D
0
 
LVL 5

Author Closing Comment

by:eNarc
ID: 31581111
thankyou :)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month13 days, 3 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question