Solved

D1 Button Activation By Space Bar

Posted on 1999-01-18
7
152 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
ID: 1362369
Edited text of question
0
 

Author Comment

by:itoft
ID: 1362370
Edited text of question
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 150 total points
ID: 1362371
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 12

Expert Comment

by:rwilson032697
ID: 1362372
Oops, that should read:

key := 0;

Cheers,

Raymond.
0
 

Author Comment

by:itoft
ID: 1362373
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
ID: 1362374
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
ID: 1362375
Adjusted points to 150
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 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