请问有谁知道如何屏蔽memo控件中所有的鼠标事件吗?(memo控件不会对鼠标的单击双击等事件作出反应。)

解决方案 »

  1.   

    阻塞键盘鼠标输入
    // Import BlockInput function form user32.dll: // BlockInput Funktion von user32.dll importieren: function BlockInput (fBlockInput : boolean) : DWord; stdcall; external 'user32.DLL'; {block input/ blockieren} procedure TForm1.Button1Click(Sender: TObject); 
    begin 
     BlockInput(true); 
    end; {unblock input / Blockierung aufheben} procedure TForm1.Button2Click(Sender: TObject); 
    begin 
     BlockInput(false); 
    end; Note: Requires Windows 98/2000 or later.   You can unblock input by pressing   CTRL+ALT+DEL 
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        Memo1: TMemo;
        Button2: TButton;
        Button1: TButton;
        Edit1: TEdit;
        procedure Memo1Enter(Sender: TObject);
        procedure Memo1Exit(Sender: TObject);  private
        { Private declarations }
      public
        { Public declarations }  end;var
      Form1: TForm1;
      function BlockInput (fBlockInput : boolean) : DWord; stdcall; external 'user32.DLL';
    implementation{$R *.DFM}procedure TForm1.Memo1Enter(Sender: TObject);
    begin
    BlockInput(true)
    end;procedure TForm1.Memo1Exit(Sender: TObject);
    begin
    BlockInput(false)
    end;end.
      

  3.   

    重载wndproc消息函数,屏蔽掉你不要的鼠标消息,比如edit的下边的代码:procedure tmyedit.wndproc(var message:tmessage);
    begin
      if message.msg=wm_mousemove then
        begin
          cursor:=crarrow;
          exit;
        end;
      if message.msg=wm_setfocus then
        exit;
      if message.Msg=wm_lbuttondown then
        showmessage('不能输入文字的了');
      inherited wndproc(message);
    end;
      

  4.   

    谢谢大家的回复, rouqing(*柔情似水&冷酷到底*) 网友,你可以把你的方法说得详细一点吗?
    我是初学者,谢谢!我想把memo控件的所有鼠标事件屏蔽掉,但在其中还是可以输入文字的.
    我不知道怎么样才能在Delphi中重载你说的这个函数.
      

  5.   

    procedure tmyedit.wndproc(var message:tmessage);override;
      

  6.   

    我在private中声明了该重载函数,但是只能够捕获窗口的鼠标消息,不能捕获memo控件的消息
    (我的窗体命名为form1,所以我把上面的程序中的tmyedit改为Tform1了)。
    后来我把tmyedit改为Tmemo或Tmemo1调试时就出错,可以和我说说怎么样才能捕获有关memo控件的
    鼠标消息吗?
      

  7.   

    哪个不要,把哪个事件设为 nil不就OK 了。
      

  8.   

    在你的程序中替换掉TMemo,自己处理鼠标消息。unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TMemo = class(StdCtrls.TMemo)
      protected
        procedure WndProc(var Message: TMessage); override;
      end;type
      TForm1 = class(TForm)
        Memo1: TMemo;
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TMemo.WndProc(var Message: TMessage);
    begin
      if (Message.Msg >= WM_MOUSEFIRST) and (Message.Msg <= WM_MOUSELAST) then Exit;
      inherited WndProc(Message);
    end;end.
      

  9.   

    谢谢sysu(死树) 网友的回复,他的方法是对的。