[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

key preview for all keys

Posted on 1999-12-22
4
Medium Priority
?
161 Views
Last Modified: 2010-04-06

Hi to all,
under D3/WIN98 i have the following problem:
in the main form is "key preview"=TRUE and i have
"on key down"-event = procedure "inputt" , but not
every keystroke is received in "inputt",
especially when the arrow keys are used.
It seems that mostly (!) only every second keystroke
is received.
In the help of "key preview" is written, that the
arrowkeys are not supported. But i need them.

Any idea what to do for receiving the arrow-keys too ?

thanks,
titz
0
Comment
Question by:titz
  • 2
4 Comments
 
LVL 3

Expert Comment

by:markshiffer
ID: 2300462
I have run into this problem before, if you use the following function on the KeyPress event it should wake up. Alter as needed for vk_down, etc....

function ArrowKeyPressed: boolean;
begin
  Result := (hibyte( GetKeyState (vk_Up)) <> 0);
end; //ControlPressed
0
 
LVL 17

Expert Comment

by:inthe
ID: 2301307
Arrow keys do not generate WM_KEYDOWN
Problem:
The KEYDOWN event does not get fired for the left/right arrow keys.
When placed on a form with more than one other control,
the left and right arrow keys move the focus, instead
 of firing an event.

Solution:
You need to handle WM_GETDLGCODE to tell Windows what
 keyboard messages you want to process.




   
 // based on a contribution from David Rifkind <drifkind@acm.org>
type
  TMyControl = class(TWinControl)
  private
    //..
    procedure WMGetDlgCode(var message: TMessage);
      message WM_GETDLGCODE;
    //..
  end;

// request the arrow keys + characters and tabs
procedure TMyControl.WMGetDlgCode(var message: TMessage);
begin
  message.Result := DLGC_WANTARROWS or DLGC_WANTCHARS or DLGC_WANTTAB;
end;
0
 
LVL 1

Author Comment

by:titz
ID: 2301373
hi markshiffer,

i adapted your idea to my problem and it works fine !
You will have the points ! throw in an answer!


Sorry inthe,
but markshiffer was quicker. i read your suggestion after testing the idea of markshiffer.

Thanks to you both and merry x-mas !
titz
0
 
LVL 3

Accepted Solution

by:
markshiffer earned 150 total points
ID: 2301388
here you go... glad it worked for you...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…

640 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