Hi devilduck,
try
var
Mgs: TMsg;
begin
{...}
PeekMessage(Mgs, 0, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE);
{...}
end;
instead "Key := 0;"
Regards,
Markus
Main Topics
Browse All TopicsI have a form with just a treeview on it. I am trying to add ctrl+a to select all nodes. Each time I press ctrl+a, I get an alert beep.
I have looked through EE and found multiple references to setting Key := Ord(#0); but that doesn't help.
Below is the KeyDown code that I am using.
Thanks,
DD
procedure TForm1.TreeView1KeyDown(Se
Shift: TShiftState);
begin
if (ssCTRL IN SHIFT) and ((Key = Ord('a')) or (Key = Ord('A')))then
begin
// Do my selection stuff here.
Key := Ord(#0); // EE line to remove beep - doesn't work
Shift := Shift - [ssCTRL]; // I tried this to see if it would work too. Nope.
end;
end;
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Wow, Russell you are fast. I am doing all of my keydown checks in the treeview keydown event. I just created a keypress event and added Key:=#0;
procedure TmainForm.TreeView1KeyPres
begin
Key:=#0;
end;
1. Will this cause me interaction problems with keydown?
2. Is the call to GetAsyncKeyState necessary considering I am doing everything on keydown?
3. I didn't have a keypress event defined for my treeview (or anywhere else) I am going to assume that it is a windows event that occurs whether I define it in delphi or not.
Thanks,
DD
Business Accounts
Answer for Membership
by: rllibbyPosted on 2004-04-19 at 14:50:30ID: 10863970
Its actually the KeyPress event that is causing the beep, so all you need to do is zero the (#0) char value for key in that event. You can also check for the control state, and conditionally clear it if you wanted to as well (code below)
nder: TObject; var Key: Word; Shift: TShiftState);
ender: TObject; var Key: Char);
K_CONTROL) ) <> 0) then Key:=#0;
Regards,
Russell
procedure TForm1.TreeView1KeyDown(Se
begin
if (ssCtrl in Shift) and (Key in [65, 97]) then
ShowMessage('Control+A');
end;
procedure TForm1.TreeView1KeyPress(S
var intKey: SHORT;
begin
if (HiByte(GetAsyncKeyState(V
end;