Solved

D1 Button Activation By Space Bar

Posted on 1999-01-18
7
149 Views
Last Modified: 2010-04-06
Using Delphi 1. If the user presses the space bar, any highlighted button is activated. How do I stop this happening, so that the button is only activated when the user hits CR or clicks on the button with the mouse?
0
Comment
Question by:itoft
  • 4
  • 3
7 Comments
 

Author Comment

by:itoft
Comment Utility
Edited text of question
0
 

Author Comment

by:itoft
Comment Utility
Edited text of question
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 150 total points
Comment Utility
This is the default windows behaviour (ie: space = mouse click on active control).

You could stop it by setting form1.keypreview to true and setting an on KeyDown event for the form. Check if it is a space and that the active control is a button and nix the char if so:

       procedure TForm3.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (key = vk_space) and (activecontrol is TButton) then // swallow it...
    key := #0;
end;

Cheers,

Raymond.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 12

Expert Comment

by:rwilson032697
Comment Utility
Oops, that should read:

key := 0;

Cheers,

Raymond.
0
 

Author Comment

by:itoft
Comment Utility
Unfortunately my question was not detailed enough as my question has been answered, but it doesn't solve my problem.
I wish to disable the space=mouse click on active control when a MessageDlg object is displayed, while still being able to detect which button on the MessageDlg foorm has been pressed.
0
 
LVL 12

Expert Comment

by:rwilson032697
Comment Utility
This is a bit trickier. What you will need to do is implement your own messagedlg form which looks and feels the same but catches the space key as you require.

Cheer,

Raymond.
0
 

Author Comment

by:itoft
Comment Utility
Adjusted points to 150
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

12 Experts available now in Live!

Get 1:1 Help Now