Solved

Help with custom component with keypress

Posted on 2002-04-05
4
336 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 200 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 96
Delphi: how to send PJL commands to printer 3 108
add combobox item based on numbers 9 154
FMX enumerated colours 2 115
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 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