?
Solved

Help with custom component with keypress

Posted on 2002-04-05
4
Medium Priority
?
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

770 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