Solved

Help with custom component with keypress

Posted on 2002-04-05
4
325 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now