Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent focused BitBtn to activate on Enter

Status
Not open for further replies.

Delphard

Programmer
Jul 22, 2004
144
RS
I want to enable activating focused BitBtn just with SPACE, but not with ENTER. Is it possible?
 

AFAIK, no. But if you want to do a little work, you could simulate the effect you want.

Drop a TPanel on your form and size it to look like a button.
Drop a TImage on the panel.
Fill the TImage with a bit map of your bit button image.
Set the tab stop property of the TPanel to True.
Set the Key Preview of the Form to True.
Process the OnKeyDown event of the form with something like this:
Code:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Self.ActiveControl = Panel1 then
    if Key = 32 then
      ShowMessage( 'Panel (space bar pressed)' );
  inherited;
end;
If you want to add visual feed-back of the key press, you can probably do that by fiddling the image as part of the event processing.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top