[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Help with custom component with keypress

Posted on 2002-04-05
4
Medium Priority
?
348 Views
Last Modified: 2010-04-04
I have written a graphical component which derives from the TPanel base class. All is great, but I need foir this to accept keys from ther user when it has focus.
This base class does not accept focus or keypress. I have tryed compiling it as a twincontrol (no luck) and as a tcustomcomponent(no luck) and as a tcustomcontrol(no luck).

I would greatly appreciate any assistance with this.
0
Comment
Question by:bobspencerr
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 800 total points
ID: 6922348
here's some sample code:

type
  TFocusPanel = class(TPanel)
  private
    procedure CMFocusChanged(var Message: TCMFocusChanged); message CM_FOCUSCHANGED;
  protected
    procedure WndProc(var Message: TMessage); override;
  end;


procedure TFocusPanel.CMFocusChanged(var Message: TCMFocusChanged);
begin
     with Message do
       if Sender is TPanel then
          if Sender = Self then
             Caption:='got focus'
          else
             Caption:='lost focus'
       else Caption:='lost focus';
     inherited;
end;

procedure TFocusPanel.WndProc(var Message: TMessage);
begin
     case Message.Msg of
       WM_LBUTTONDOWN,
       WM_LBUTTONDBLCLK: Windows.SetFocus(Handle);
     end;
     inherited WndProc(Message);
end;
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6922403
listening
0
 

Author Comment

by:bobspencerr
ID: 6922534
Sir,
I thank you for your assistance. I spent 24 hours straight on this section alone.

You deserve the points and greatfully given.

Bob Spencer.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6922542
tnx for the A :)
I've spent 10 minutes on it :) (have a bit of component making experience)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

830 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