Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8975567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:54:53+00:00 2026-06-15T18:54:53+00:00

i have create mainform (auto create form) and Form1 (available form). the method that

  • 0

i have create mainform (auto create form) and Form1 (available form).
the method that i use to call form1 is like this

procedure Tmainform.Button2Click(Sender: TObject);
var
f : Tform1;
begin
f:=Tform1.create(self);
f.parent:=Tabsheet1;
f.visible:=true;
f.align:=alClient;
end;

the question is why KeyPreview in Form1 does not work, even though I have activated his KeyPreview be true?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:54:54+00:00Added an answer on June 15, 2026 at 6:54 pm

    in function TWinControl.DoKeyDown(var Message: TWMKey): Boolean; the call is delegated to the parent if existing.

    The Procedure

    procedure TWinControl.KeyDown(var Key: Word; Shift: TShiftState);
    begin
      if Assigned(FOnKeyDown) then FOnKeyDown(Self, Key, Shift);
    end;
    

    will not be called if Form is parented

    function TWinControl.DoKeyDown(var Message: TWMKey): Boolean;
    var
      ShiftState: TShiftState;
      Form, FormParent: TCustomForm;
      LCharCode: Word;
    begin
      Result := True;
      { First give the immediate parent form a try at the Message }
      Form := GetParentForm(Self, False);
      if (Form <> nil) and (Form <> Self) then 
      begin
        //  >> -- the DoKeyDown of the parent (not of your form) will be called 
        if Form.KeyPreview and TWinControl(Form).DoKeyDown(Message) then
          Exit;
        { If that didn't work, see if that Form has a parent (ie: it is docked) }
        if Form.Parent <> nil then 
        begin
          FormParent := GetParentForm(Form);
          if (FormParent <> nil) and (FormParent <> Form) and FormParent.KeyPreview and
              TWinControl(FormParent).DoKeyDown(Message) then
            Exit;
        end;
      end;
    ......
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have create a vcf file that contains contacts by using this code ContentResolver
I have create name range on sheet A so I need to use this
I have a main form called mainForm - this runs my entire app. In
I have a popup with a form containing file upload cfgfile <form id=mainForm method=post
I try to create aplication with Ninject. I have one MainForm and dialog form
I have created a list form that gets attached to a main form in
I have create my own NSOpenGLView class, right now the data that i want
i have create a form (so it's PHP and HTML hybrid-code). it has ability
I have create a listfragment and a button which looks like as follows (
I'm working with a C# project using System.Windows.Form to create the GUI, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.