Для Delphi:
Код:
unit Unit1;
interface
uses
*Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
*Dialogs, StdCtrls;
type
*TForm1 = class(TForm)
* *Edit1: TEdit;
* *Edit2: TEdit;
* *Button1: TButton;
* *Button2: TButton;
* *Label1: TLabel;
* *procedure Button1Click(Sender: TObject);
*private
* *{ Private declarations }
*protected
*procedure Enter_Tab(var Msg:TMessage);message CM_DIALOGKEY;
*public
* *{ Public declarations }
*end;
var
*Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.Enter_Tab(var Msg: TMessage);
begin
if msg.WParam=13 then
begin
Perform(CM_DIALOGKEY,9,0);
msg.Result:=1;//отключаем обработку нажатия Enter
end
else
inherited;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage('Enter=Tab');
end;
end.
************************************************
Для C++ (CBuilder6):
Заголовочный файл
//---------------------------------------------------------------------------
Код:
#ifndef UnMainH
#define UnMainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:// IDE-managed Components
* * * *TButton *Button1;
* * * *TEdit *Edit1;
* * * *TEdit *Edit2;
* * * *TButton *Button2;
* * * *TButton *Button3;
private:// User declarations
protected:
void __fastcall KeyCatch(TMessage &Msg);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_DIALOGKEY,TMessage,KeyCatch)
END_MESSAGE_MAP(TForm)
public:
// User declarations
* * * *__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Файл реализации
//---------------------------------------------------------------------------
Код:
#include <vcl.h>
#pragma hdrstop
#include "UnMain.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
* * * *: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::KeyCatch(TMessage &Msg)
{ *
* if( Msg.WParam==13){
* Perform(CM_DIALOGKEY,9,0);
* *Msg.Result=1;//отключаем обработку нажатия Enter *
* } else * TForm::Dispatch(&Msg);
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ShowMessage("Enter=Tab");
}
//---------------------------------------------------------------------------
[s]Исправлено:
Vla2003, 20:31 7-06-2003[/s]
[s]Исправлено:
Vla2003, 12:27 9-06-2003[/s]