Re: Don't want a default button
From: Dragon Lord (invalid_at_joke.com)
Date: 02/02/04
- Next message: Dragon Lord: "Re: Don't want a default button"
- Previous message: Richard S Beckett: "Re: Problem with ShellExecute."
- In reply to: J French: "Re: Don't want a default button"
- Next in thread: J French: "Re: Don't want a default button"
- Reply: J French: "Re: Don't want a default button"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 2 Feb 2004 13:38:31 -0500
Here is some sample code
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, ExtCtrls;
type
TBitBtnHack = class(TBitBtn)
public
procedure WndProc(var Message: TMessage); override;
end;
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
public
procedure OnClicky(Sender: TObject);
procedure WndProc(var Message: TMessage); override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TBitBtnHack.WndProc(var Message: TMessage);
begin
writeln('BUTTON MESSAGE: ', IntToHex(Message.Msg,8));
inherited WndProc(Message);
end;
procedure TForm1.WndProc(var Message: TMessage);
begin
writeln('FORM MESSAGE: ', IntToHex(Message.Msg,8));
inherited WndProc(Message);
end;
procedure TForm1.OnClicky(Sender: TObject);
begin
writeln('on click fired');
end;
procedure TForm1.FormCreate(Sender: TObject);
var
MyButton: TBitBtnHack;
begin
MyButton := TBitBtnHack.Create(Form1);
Form1.InsertControl(MyButton);
MyButton.OnClick := OnClicky;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
writeln('-----------------------------------------------');
end;
end.
Produces this in the console window when a key is pressed
BUTTON MESSAGE: 0000BD00 CN_KEYDOWN
BUTTON MESSAGE: 0000B02E CM_CHILDKEY
FORM MESSAGE: 0000B02E CM_CHILDKEY
BUTTON MESSAGE: 0000B01E CM_WANTSPECIALKEY
BUTTON MESSAGE: 00000087 WM_GETDLGCODE
FORM MESSAGE: 0000B005 CM_DIALOGKEY
BUTTON MESSAGE: 0000B005 CM_DIALOGKEY
on click fired
BUTTON MESSAGE: 00000084 WM_NCHITTEST
changing the code slightly
procedure TForm1.WndProc(var Message: TMessage);
begin
writeln('FORM MESSAGE: ', IntToHex(Message.Msg,8));
if Message.Msg = CM_CHILDKEY then
Message.Result := 1;
inherited WndProc(Message);
end;
BUTTON MESSAGE: 0000BD00
BUTTON MESSAGE: 0000B02E
FORM MESSAGE: 0000B02E
BUTTON MESSAGE: 00000084
to just trap the CM_CHILDKEY you can put a handler for JUST that event, this
is just for testing purposes. But, as you can see, if you handle that even
(Message.Result:=1) then the Button ingores it. You COULD also trap the
CM_DIALOGKEY.
Jeremy
"J French" <erewhon@nowhere.com> wrote in message
news:401e8a6e.9588444@news.btclick.com...
> On Mon, 2 Feb 2004 12:21:15 -0500, "Dragon Lord" <invalid@joke.com>
> wrote:
>
> >Actually, Windows doesn't steal it, but actually, the VCL steals it in
the
> >form of a custom message. CM_CHILDKEY.
>
> Are you really sure about that ?
>
>
- Next message: Dragon Lord: "Re: Don't want a default button"
- Previous message: Richard S Beckett: "Re: Problem with ShellExecute."
- In reply to: J French: "Re: Don't want a default button"
- Next in thread: J French: "Re: Don't want a default button"
- Reply: J French: "Re: Don't want a default button"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]