delphi 禁止用键盘左右箭头,去切换PageControl页签


本文整理自网络,侵删。

 
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls;

type
  TForm1 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure EditWndProc(var Message: TMessage);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  EditHandle: THandle;
  EditPointer:Pointer;
  

implementation

{$R *.dfm}

procedure TForm1.EditWndProc(var Message: TMessage);
begin
  case Message.Msg of
      WM_KEYDOWN  :                          //如果是按键消息
      begin
        if Message.WParam in [37,39] then   //如果是左右箭头
          Exit;
      end;
   end;
   Message.Result:=CallWindowProc(EditPointer, EditHandle, Message.Msg, Message.WParam, Message.LParam);
end;

procedure TForm1.FormCreate(Sender: TObject);
Var P:Pointer;
begin
  EditHandle:=PageControl1.Handle;
  if EditHandle<>0 then
  begin
    EditPointer := Pointer(GetWindowLong(EditHandle, GWL_WNDPROC));
    P := Classes.MakeObjectInstance(EditWndProc);
    SetWindowLong(EditHandle, GWL_WNDPROC, Longint(P));
  end;
end;


end.

相关阅读 >>

Delphi 窗口全屏

Delphi stringtobase64、base64tostring两个函数

Delphi gettempdirectory 获取临时文件夹路径

Delphi创建密钥文件

webbrowser里网页根据文字判断来点击链接

Delphi把流中的字符串转换为utf格式

Delphi拖动窗体超简单实现

Delphi unidac 连接mdb access 数据库

Delphi中使用tpathanimation

Delphi android实例-trectangle加载图片(xe8+小米2)

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...