Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not sure I understand your question correctly. Sounds like you have a frame with a button (and either an TAction or click event handler on the button) and this frame is sitting on a form. Now you want to programmatically simulate a click on that button.</p> <p>Obviously you need to add the frame unit to your form's uses clause. You also need an instance of the frame on the form which should lead to a form field of the frame type, e.g.</p> <pre><code>TForm1... ... Frame1: TFrame1; end; </code></pre> <p>Then you can execute that code via <code>Frame1.SQLbtn.Click</code> from within any of the form's methods. A better way would probably be to provide a public method on the frame which you can use from the form. Then you don't need to access the button directly (the button is an implementation detail of the frame, frame private so to speak).</p> <p><b>Edit after clarification</b> </p> <p>I understand you have the following scenario:</p> <pre><code>TFrameForm1... ... Frame1: TFrame1; end; TForm1... ... procedure something; end; procedure TForm1.something; begin // how to call a method on Frame1 which is on FrameForm1 end; </code></pre> <p>Your best choice is to move the code from frame button OnClick event handler into a separate unit. This can be a datamodule, or a just another unit with a standalone procedure. Then you can call that code from both Form1 and the Frame1 button event handler. This is what Vegar has commented.</p> <p>If that is not possible, e.g. because the processing requires access to other controls on Frame1, move the code into a new procedure on Frame1 (my original suggestion):</p> <pre><code>TFrame1... ... public procedure framestuff; end; procedure TFrame1.framestuff; begin ... end; procedure TFrame1.SQLbtnClick(Sender...); begin framestuff; end; </code></pre> <p>Now you need to call that method from Form1. You'll need a reference to FrameForm1 for that. Which you need to initialize manually (!) when you create TFrameForm1. In this example, the reference is a field FFrameForm:</p> <pre><code>TForm1... ... FFrameForm: TFrameForm1; procedure something; end; procedure TForm1.something; begin FrameForm.framestuff; end; </code></pre> <p>Or, by default Delphi adds global variables for all forms to the form units (auto form creation, check project options / forms). Then you do this:</p> <pre><code>procedure TForm1.something; begin FrameForm1.framestuff; // if FrameForm1 is the name Delphi used for the global variable end; </code></pre> <p>Of course there are many other variations...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload