• 让IE右键失效


    1 

    主要演示了TApplicationEvents.OnMessage 的第二个参数 Handled 如果是 True, 表示消息已经处理过了, 到此为止.

    代码如下:

    unit Unit1;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, AppEvnts, OleCtrls, SHDocVw;

    type
      TForm1 = class(TForm)
        WebBrowser1: TWebBrowser;
        ApplicationEvents1: TApplicationEvents;
        procedure FormCreate(Sender: TObject);
        procedure ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
    begin
      if IsChild(WebBrowser1.Handle,Msg.hwnd) and ((Msg.message=WM_RBUTTONDOWN) or (Msg.message=WM_RBUTTONDBLCLK)) then
      begin
        Handled:=true;
      end;

    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      WindowState:= wsMaximized;
      WebBrowser1.Align:=alTop;
      WebBrowser1.Navigate('http://www.baidu.com');
    end;

    end.

    -------------------------------------------------------------

    界面代码如下:

    object Form1: TForm1
      Left = 0
      Top = 0
      Caption = 'IE'#21491#38190#22833#25928
      ClientHeight = 247
      ClientWidth = 312
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      OldCreateOrder = False
      OnCreate = FormCreate
      PixelsPerInch = 96
      TextHeight = 13
      object WebBrowser1: TWebBrowser
        Left = 4
        Top = 8
        Width = 300
        Height = 201
        TabOrder = 0
        ControlData = {
          4C000000021F0000C61400000000000000000000000000000000000000000000
          000000004C000000000000000000000001000000E0D057007335CF11AE690800
          2B2E126208000000000000004C0000000114020000000000C000000000000046
          8000000000000000000000000000000000000000000000000000000000000000
          00000000000000000100000000000000000000000000000000000000}
      end
      object ApplicationEvents1: TApplicationEvents
        OnMessage = ApplicationEvents1Message
        Left = 24
        Top = 216
      end
    end

  • 相关阅读:
    PDF文档生成缩略图
    zTree数据回显
    window.showModalDialog基础
    Java获取两个时间段内的所有日期
    CSS设置超出表格的内容用省略号显示
    Ajax提交form表单
    普通java类在Tomcat启动时获取ServletContext
    mysql中sql优化和合理使用索引
    mysql数据类型详解系列
    如何干净的清除slave同步信息
  • 原文地址:https://www.cnblogs.com/hackpig/p/1668591.html
Copyright © 2020-2023  润新知