zoukankan      html  css  js  c++  java
  • WebBrowser这个控件实现去除滚动条,边框,右键

    有时侯为了界面的简洁好看还有程序的安全性,我们都希望WebBrowser这个控件可以实现去除滚动条,边框,右键,下面这两个方法可以充分满足我们的需求:

    //去除边框,滚动条

    1 procedure WB_Set3DBorderStyle(Sender: TObject; bValue: Boolean);
    2  var
    3 Document : IHTMLDocument2;
    4 Element : IHTMLElement;
    5 StrBorderStyle: string;
    6  begin
    7
    8  try
    9 Document := TWebBrowser(Sender).Document as IHTMLDocument2;
    10 TWebBrowser(Sender).OleObject.Document.Body.Scroll := 'no';//去除滚动条
    11 if Assigned(Document) then
    12 begin
    13 Element := Document.Body;
    14 if Element <> nil then
    15 begin
    16 case BValue of
    17 False: StrBorderStyle := 'none';
    18 True: StrBorderStyle := '';
    19 end;
    20 Element.Style.BorderStyle := StrBorderStyle;
    21 end;
    22 end;
    23 except
    24 end;
    25 end;
    26
    27 在窗体的DocumentComplete事件中使用
    28
    29 去除右键:
    30
    31 //禁止右键
    32 function MouseProc(nCode: Integer; wParam, lParam: Longint): Longint; stdcall;
    33 var
    34 szClassName: array[0..255] of Char;
    35 const
    36 ie_name = 'Internet Explorer_Server';
    37 begin
    38 case nCode < 0 of
    39 True:
    40 Result := CallNextHookEx(HookID, nCode, wParam, lParam)
    41 else
    42 case wParam of
    43 WM_RBUTTONDOWN,
    44 WM_RBUTTONUP:
    45 begin
    46 GetClassName(PMOUSEHOOKSTRUCT(lParam)^.HWND, szClassName, SizeOf(szClassName));
    47 if lstrcmp(@szClassName[0], @ie_name[1]) = 0 then
    48 Result := HC_SKIP
    49 else
    50 Result := CallNextHookEx(HookID, nCode, wParam, lParam);
    51 end
    52 else
    53 Result := CallNextHookEx(HookID, nCode, wParam, lParam);
    54 end;
    55 end;
    56 end;
    57

    在窗体的Create事件中加入
    HookID := SetWindowsHookEx(WH_MOUSE, MouseProc, 0, GetCurrentThreadId());

    做完上面这几步,打开一个网页看看,再右键看看,是不是这种效果很满意呢?

    ';

  • 相关阅读:
    You can’t access this shared folder because your organization’s security policies block unauthenticated guest access
    iOS 程序退出之后
    给网站得标签头加上小图标
    ios外界蓝牙适配
    JavaScript&jquery判断下载地址是否可用,同时判断浏览器是否禁用弹窗
    GCD初级使用
    find与xargs
    sed命令详解
    shell变量详解
    date命令详解
  • 原文地址:https://www.cnblogs.com/prtmon/p/1933246.html
Copyright © 2011-2022 走看看