Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 03-02-2002, 07:54 AM
Basheer Basheer is offline
Junior Member
 
Join Date: Feb 2001
Posts: 12
Default Calling a function/proc in another form by its handle

Hi all,

Please hlep to find a way for calling a function or procedure in another form using the handle of that form.

thanks in advance.
Reply With Quote
  #2  
Old 03-02-2002, 07:59 AM
GoodFun GoodFun is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,645
Default RE: Calling a function/proc in another form by its handle

Hi there,

just add the name of the form to the front of the function call.

var Form1: TForm1;
var Form2: TForm2;

once they are both created, you can call a function in Form1 from Form2 by using the following syntax:

Variable := Form1.FunctionName(Parameters);

of course those are just made up names. You also have to put the unit name of Form1 into the uses clause of Form2 (in the implementation part of the unit where Form2 is defined).

The better way to do this is to have another unit that holds the function, include that unit in both Form1 and Form2 uses clause and then call it directly.

Hope this helps,

Marcel

Please click on Accept if this helped...
Reply With Quote
  #3  
Old 03-02-2002, 09:03 AM
andyho andyho is offline
Senior Member
 
Join Date: Jul 2001
Posts: 1,446
Default RE: Calling a function/proc in another form by its handle

Why do you only have the handle? If that form is inside the same application there should never be the need to use the window handle for accessing that form, even if you don't have a direct variable like the "form1", e.g. for dynamically created forms, you can access them by using application.components which contains all forms of the application. And then you can use something like

for i:=application.componentindex-1 downto 0 do
if application.components[i] is TForm1 then
TForm1(application.components[i]).YourMethod;

However if the window is in a different application you need to do something totally different, for example registering a global windows message and use that one to send a message to that handle, and that form then calls your method in the wndproc...

Bye,
Andy
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 06:43 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.