title: Select component on current focused/active form
body: <p>I need to select the component on currently focused/active form, but can't figure the way of doing this completely.
  So, I have a delphi unit with all common procedures on it, so I call them from other forms.
  Now, the thing is, that with one of the procedures I call the component show action, but, since the component is placed on each form (couldn't find a way of placing one component, which can be used by all forms, but I think this somehow can't be done. Am I wrong? ), I need to call a show event for the component on currently active form, otherwise the specified form, from which I call the component, gets active and focused.</p>
  
  <p>So far I've tried by getting current form name, via Screen.ActiveForm and Screen.ActiveForm.Name, but none of this works, since the compiler doesn't compile because component parent is not defined (getting error " 'TForm' does not contain a member named 'KeyBoard1' "...)</p>
  
  <p>Here's the procedure code:</p>
  
  <pre><code>  procedure KeyDownEvents(var Key: Word; Shift: TShiftState);
      begin
      CurrentForm:=Screen.ActiveForm.Name;
      if Key = VK_F9 then CurrentForm.KeyBoard1.Show;
      end;
  </code></pre>
  
  <p>Using global variable</p>
  
  <pre><code>    var CurrentForm: TForm;
  </code></pre>
  
  <p>Where and what am I missing, since I've tried like 10 different combinations...?</p>
  
  <p>Thanks, </p>
  
  <p>Marc.</p>
  
  <p>Ps: as asked above, is there a way of placing or calling component, to be active on any form, or should it be placed in each form, so no focus is changed...? I know in MDI I could use a component in main form (as far as I know...), but I'm working in SDI, because of multiple monitors needed...</p>
  
  <hr>
  
  <p>Complete code for David:</p>
  
  <pre><code>unit CommonProcedures;
  
  interface
  
  uses Classes, Dialogs, StdCtrls, Math, Winapi.Windows, Winapi.Messages,
  Vcl.Controls, Vcl.Forms, AdvTouchKeyboard;
  
  procedure KeyDownEvents(var Key: Word; Shift: TShiftState);
  
  var
  CurrentForm: TComponentName;
  KeyBoard1Visible: Boolean;
  
  implementation
  
  
  uses Startup, Main, Controller, Settings, Patch, Output, StageVisual, FixturesEditor,
  FixturesEditorGlobal;
  
  procedure KeyDownEvents(var Key: Word; Shift: TShiftState);
   begin
    CurrentForm:=Screen.ActiveForm.Name;
     if ((ssAlt in Shift) and (Key = VK_F4)) then Key:=0;
     if Key = VK_F1 then Main1.Show;
     if Key = VK_F2 then Controller1.Show;
     if Key = VK_F3 then Settings1.Show;
     if Key = VK_F4 then Patch1.Show;
     if Key = VK_F5 then Output1.Show;
     if Key = VK_F6 then StageVisual1.Show;
     if Key = VK_F7 then FixturesEditor1.Show;
     if Key = VK_F8 then FixturesEditor2.Show;
     if Key = VK_F9 then
       begin
         if KeyBoard1Visible=False
         then
          begin
            KeyBoard1Visible:=True;
            CurrentForm.KeyBoard1.Show;
          end
         else
          begin
           KeyBoard1Visible:=False;
           CurrentForm.KeyBoard1.Hide;
         end;
       end;
    end;
  </code></pre>
  
  <p>end.</p>
  
  <p>There you can see, that I only left out all other key events, since they're completely unimportant, but I did as well left out process of checking whether the keyboard is shown or hidden, so the VK_F9 behaves as toggle key.</p>
  
  <p>That is so far the only procedure in this unit, as I only started to create the program a few days ago, so it's still in first base, so said...
  And yes, as you can see and guess, it's sort of light-show controller program, the project for my senior year.</p>
  
  <p>Ps: don't see the reason to downvote the question when I edited it to be even clearer...</p>