Solved

Trapping Windows button

Posted on 1998-01-26
8
211 Views
Last Modified: 2010-04-04
I am not sure if this is an easy task but:

how can i  trap the Windows button??

Regards
Keith
0
Comment
Question by:keithcsl
  • 5
  • 2
8 Comments
 
LVL 4

Expert Comment

by:d003303
ID: 1357565
Hum, Windows button ? Do you mean the minimize/maximize buttons on the title bar ?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357566
You mean the new windows button on the keyboard (win95 ,NT)?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357567
I believe, you have to check for the VK_LWin or VK_RWin key.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 8

Accepted Solution

by:
ZifNab earned 20 total points
ID: 1357568
This should it be, if I correctly understood the question :

Use Plain form, copy this source to the unit, run it and push left or right window button on keyboard.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, DtEdit97;

type
  TForm1 = class(TForm)
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
  var i : integer;
begin
 If Key = VK_LWIn then showmessage('left');
 if key = vk_RWin then showmessage('right');
end;

end.

Regards,
ZifNab;
0
 
LVL 1

Author Comment

by:keithcsl
ID: 1357569
I am so soree but I meant the Windows key on the keyboard. Should have made my question more clearly..

Keith
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357570
Keithcsl, the source code I gave you is meant for the windows key on the keyboard!!! The left and the right one!
0
 
LVL 1

Author Comment

by:keithcsl
ID: 1357571
ZifNab

Oh my, I am sorry for not reading your answer properly. The code works fine. Thanx!

If it is not too much to ask, is there a way to cancel the Keydown event?, ie i don't want the user to be able to press the Windows Key.

Thanx
Keith
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357572
Hi Keith,
I don't know really, it seems that the key is directely sended to windows. You can't just assign another value to Key as normally. I'll try to find a solution, but I can't promise anything.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

789 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