마음의 안정을 찾기 위하여 - TWebBrowser에서 테두리 없애는 방법!
1592408
387
367
관리자새글쓰기
태그위치로그방명록
별일없다의 생각
dawnsea's me2day/2010
색상(RGB)코드 추출기(Color...
Connection Generator/2010
최승호PD, '4대강 거짓말 검...
Green Monkey**/2010
Syng의 생각
syng's me2DAY/2010
천재 작곡가 윤일상이 기획,...
엘븐킹's Digital Factory/2010
TWebBrowser에서 테두리 없애는 방법!
Delphi/웹브라우져 | 2010/11/08 15:01
TWebBrowser 컴퍼넌트를 사용할때, 브라우저의 테두리가 보이지 않도록 하는 방법으로
WebBrowser.OleObject.Document.Body.Style.Border := 'none'; 를 사용하게 되면 해당 구문 호출 이전에 보여지는 것까지도 방지할 수 있다.

unit DocHostUIHandler;
 
interface
 
uses
  Windows, Classes, SysUtils, ActiveX, SHDocVw;
 
const
  DOCHOSTUITYPE_BROWSE = 0;
  DOCHOSTUITYPE_AUTHOR = 1;
 
  DOCHOSTUIDBLCLK_DEFAULT = 0;
  DOCHOSTUIDBLCLK_SHOWPROPERTIES = 1;
  DOCHOSTUIDBLCLK_SHOWCODE = 2;
 
  DOCHOSTUIFLAG_DIALOG = 1;
  DOCHOSTUIFLAG_DISABLE_HELP_MENU = 2;
  DOCHOSTUIFLAG_NO3DBORDER = 4;
  DOCHOSTUIFLAG_SCROLL_NO = 8;
  DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE = 16;
  DOCHOSTUIFLAG_OPENNEWWIN = 32;
  DOCHOSTUIFLAG_DISABLE_OFFSCREEN = 64;
  DOCHOSTUIFLAG_FLAT_SCROLLBAR = 128;
  DOCHOSTUIFLAG_DIV_BLOCKDEFAULT = 256;
  DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY = 512;
 
type
  PDOCHOSTUIINFO = ^TDOCHOSTUIINFO;
 
  TDOCHOSTUIINFO = record
    cbSize: ULONG;
    dwFlags: DWORD;
    dwDoubleClick: DWORD;
  end;
 
  IDocHostShowUI = interface(IUnknown)
    ['{c4d244b0-d43e-11cf-893b-00aa00bdce1a}']
    function ShowMessage(hwnd: THandle; lpstrText: POLESTR;
      lpstrCaption: POLESTR; dwType: longint; lpstrHelpFile: POLESTR;
      dwHelpContext: longint; var plResult: LRESULT): HRESULT; stdcall;
    function ShowHelp(hwnd: THandle; pszHelpFile: POLESTR; uCommand: integer;
      dwData: longint; ptMouse: TPoint; var pDispachObjectHit: IDispatch)
      : HRESULT; stdcall;
  end; // IDocHostShowUI
 
  IDocHostUIHandler = interface(IUnknown)
    ['{bd3f23c0-d43e-11cf-893b-00aa00bdce1a}']
    function ShowContextMenu(const dwID: DWORD; const ppt: PPOINT;
      const pcmdtReserved: IUnknown; const pdispReserved: IDispatch)
      : HRESULT; stdcall;
    function GetHostInfo(var pInfo: TDOCHOSTUIINFO): HRESULT; stdcall;
    function ShowUI(const dwID: DWORD;
      const pActiveObject: IOleInPlaceActiveObject;
      const pCommandTarget: IOleCommandTarget; const pFrame: IOleInPlaceFrame;
      const pDoc: IOleInPlaceUIWindow): HRESULT; stdcall;
    function HideUI: HRESULT; stdcall;
    function UpdateUI: HRESULT; stdcall;
    function EnableModeless(const fEnable: BOOL): HRESULT; stdcall;
    function OnDocWindowActivate(const fActivate: BOOL): HRESULT; stdcall;
    function OnFrameWindowActivate(const fActivate: BOOL): HRESULT; stdcall;
    function ResizeBorder(const prcBorder: PRECT;
      const pUIWindow: IOleInPlaceUIWindow; const fRameWindow: BOOL): HRESULT;
      stdcall;
    function TranslateAccelerator(const lpMsg: PMSG;
      const pguidCmdGroup: PGUID; const nCmdID: DWORD): HRESULT; stdcall;
    function GetOptionKeyPath(var pchKey: POLESTR; const dw: DWORD): HRESULT;
      stdcall;
    function GetDropTarget(const pDropTarget: IDropTarget;
      out ppDropTarget: IDropTarget): HRESULT; stdcall;
    function GetExternal(out ppDispatch: IDispatch): HRESULT; stdcall;
    function TranslateUrl(const dwTranslate: DWORD; const pchURLIn: POLESTR;
      var ppchURLOut: POLESTR): HRESULT; stdcall;
    function FilterDataObject(const pDO: IDataObject;
      out ppDORet: IDataObject): HRESULT; stdcall;
  end; // IDocHostUIHandler
 
  TEnhancedWebBrowserUI = class(TPersistent)
  private
    FScrollBar: Boolean;
    FBorder3D: Boolean;
    FFlatScrollBars: Boolean;
    FContextMenu: Boolean;
  public
    constructor Create;
  published
    property ScrollBars: Boolean read FScrollBar write FScrollBar;
    property FlatScrollBars: Boolean read FFlatScrollBars write FFlatScrollBars;
    property ContextMenu: Boolean read FContextMenu write FContextMenu;
    property Border3D: Boolean read FBorder3D write FBorder3D;
  end;
 
  TWebBrowser = class(SHDocVw.TWebBrowser, IUnknown, IDocHostUIHandler, IDocHostShowUI)
  private
    FRefCount: integer;
    FEnhancedWebBrowserUI: TEnhancedWebBrowserUI;
  protected
    // IUnknown
    function QueryInterface(const IID: TGUID; out Obj): integer; stdcall;
    function _AddRef: longint; virtual; stdcall;
    function _Release: longint; virtual; stdcall;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    // IDOcHostUIHandler
    function ShowContextMenu(const dwID: DWORD; const ppt: PPOINT;
      const pcmdtReserved: IUnknown; const pdispReserved: IDispatch)
      : HRESULT; stdcall;
    function GetHostInfo(var pInfo: TDOCHOSTUIINFO): HRESULT; stdcall;
    function ShowUI(const dwID: DWORD;
      const pActiveObject: IOleInPlaceActiveObject;
      const pCommandTarget: IOleCommandTarget; const pFrame: IOleInPlaceFrame;
      const pDoc: IOleInPlaceUIWindow): HRESULT; stdcall;
    function HideUI: HRESULT; stdcall;
    function UpdateUI: HRESULT; stdcall;
    function EnableModeless(const fEnable: BOOL): HRESULT; stdcall;
    function OnDocWindowActivate(const fActivate: BOOL): HRESULT; stdcall;
    function OnFrameWindowActivate(const fActivate: BOOL): HRESULT; stdcall;
    function ResizeBorder(const prcBorder: PRECT;
      const pUIWindow: IOleInPlaceUIWindow; const fRameWindow: BOOL): HRESULT;
      stdcall;
    function TranslateAccelerator(const lpMsg: PMSG;
      const pguidCmdGroup: PGUID; const nCmdID: DWORD): HRESULT; stdcall;
    function GetOptionKeyPath(var pchKey: POLESTR; const dw: DWORD): HRESULT;
      stdcall;
    function GetDropTarget(const pDropTarget: IDropTarget;
      out ppDropTarget: IDropTarget): HRESULT; stdcall;
    function GetExternal(out ppDispatch: IDispatch): HRESULT; stdcall;
    function TranslateUrl(const dwTranslate: DWORD; const pchURLIn: POLESTR;
      var ppchURLOut: POLESTR): HRESULT; stdcall;
    function FilterDataObject(const pDO: IDataObject;
      out ppDORet: IDataObject): HRESULT; stdcall;
    // IDocHostShowUI
    function ShowMessage(hwnd: THandle; lpstrText: POLESTR;
      lpstrCaption: POLESTR; dwType: longint; lpstrHelpFile: POLESTR;
      dwHelpContext: longint; var plResult: LRESULT): HRESULT; stdcall;
    function ShowHelp(hwnd: THandle; pszHelpFile: POLESTR; uCommand: integer;
      dwData: longint; ptMouse: TPoint; var pDispachObjectHit: IDispatch)
      : HRESULT; stdcall;
    { Public declarations }
  published
    { Published declarations }
    property UI: TEnhancedWebBrowserUI read FEnhancedWebBrowserUI;
  end;
 
implementation
 
function TWebBrowser.ShowMessage(hwnd: THandle; lpstrText: POLESTR;
  lpstrCaption: POLESTR; dwType: longint; lpstrHelpFile: POLESTR;
  dwHelpContext: longint; var plResult: LRESULT): HRESULT;
begin
  RESULT := E_NotImpl;
end;
 
function TWebBrowser.ShowHelp(hwnd: THandle; pszHelpFile: POLESTR;
  uCommand: integer; dwData: longint; ptMouse: TPoint;
  var pDispachObjectHit: IDispatch): HRESULT;
begin
  RESULT := S_OK;
end;
 
function TWebBrowser.QueryInterface(const IID: TGUID; out Obj): integer;
begin
  if GetInterface(IID, Obj) then
    RESULT := S_OK
  else
    RESULT := E_NOINTERFACE;
end;
 
function TWebBrowser._AddRef: longint;
begin
  Inc(FRefCount);
  RESULT := FRefCount;
end;
 
function TWebBrowser._Release: longint;
begin
  Dec(FRefCount);
  RESULT := FRefCount;
end;
 
function TWebBrowser.ShowContextMenu(const dwID: DWORD; const ppt: PPOINT;
  const pcmdtReserved: IUnknown; const pdispReserved: IDispatch): HRESULT;
begin
  if FEnhancedWebBrowserUI.ContextMenu then
    Result := S_OK
  else
    Result := S_FALSE;
end;
 
function TWebBrowser.GetHostInfo(var pInfo: TDOCHOSTUIINFO): HRESULT;
begin
  pInfo.cbSize := SizeOf(pInfo);
  pInfo.dwFlags := 0;
  if not FEnhancedWebBrowserUI.ScrollBars then
    pInfo.dwFlags := pInfo.dwFlags or DOCHOSTUIFLAG_SCROLL_NO;
  if not FEnhancedWebBrowserUI.FlatScrollBars then
    pInfo.dwFlags := pInfo.dwFlags or DOCHOSTUIFLAG_FLAT_SCROLLBAR;
  if not FEnhancedWebBrowserUI.Border3D then
    pInfo.dwFlags := pInfo.dwFlags or DOCHOSTUIFLAG_NO3DBORDER;
 
//  pInfo.dwDoubleClick := 0;
  RESULT := S_OK;
end;
 
function TWebBrowser.ShowUI(const dwID: DWORD;
  const pActiveObject: IOleInPlaceActiveObject;
  const pCommandTarget: IOleCommandTarget; const pFrame: IOleInPlaceFrame;
  const pDoc: IOleInPlaceUIWindow): HRESULT;
begin
  RESULT := S_OK;
end;
 
function TWebBrowser.HideUI: HRESULT;
begin
  RESULT := S_OK;
end;
 
function TWebBrowser.UpdateUI: HRESULT;
begin
  RESULT := E_NotImpl;
end;
 
constructor TWebBrowser.Create(AOwner: TComponent);
begin
  inherited;
 
  FEnhancedWebBrowserUI := TEnhancedWebBrowserUI.Create;
end;
 
destructor TWebBrowser.Destroy;
begin
  FEnhancedWebBrowserUI.Free;
 
  inherited;
end;
 
function TWebBrowser.EnableModeless(const fEnable: BOOL): HRESULT;
begin
  RESULT := E_NotImpl;
end;
 
function TWebBrowser.OnDocWindowActivate(const fActivate: BOOL): HRESULT;
begin
  RESULT := E_NotImpl;
end;
 
function TWebBrowser.OnFrameWindowActivate(const fActivate: BOOL): HRESULT;
begin
  RESULT := E_NotImpl;
end;
 
function TWebBrowser.ResizeBorder(const prcBorder: PRECT;
  const pUIWindow: IOleInPlaceUIWindow; const fRameWindow: BOOL): HRESULT;
begin
  RESULT := E_NotImpl;
end;
 
function TWebBrowser.TranslateAccelerator(const lpMsg: PMSG;
  const pguidCmdGroup: PGUID; const nCmdID: DWORD): HRESULT;
begin
  RESULT := E_NotImpl;
end;
 
function TWebBrowser.GetOptionKeyPath(var pchKey: POLESTR;
  const dw: DWORD): HRESULT;
begin
  RESULT := E_NotImpl;
end;
 
function TWebBrowser.GetDropTarget(const pDropTarget: IDropTarget;
  out ppDropTarget: IDropTarget): HRESULT;
begin
  RESULT := E_NotImpl;
end;
 
function TWebBrowser.GetExternal(out ppDispatch: IDispatch): HRESULT;
begin
  RESULT := E_NotImpl;
end;
 
function TWebBrowser.TranslateUrl(const dwTranslate: DWORD;
  const pchURLIn: POLESTR; var ppchURLOut: POLESTR): HRESULT;
begin
  RESULT := E_NotImpl;
end;
 
function TWebBrowser.FilterDataObject(const pDO: IDataObject;
  out ppDORet: IDataObject): HRESULT;
begin
  RESULT := E_NotImpl;
end;
 
{ TEnhancedWebBrowserUI }
 
constructor TEnhancedWebBrowserUI.Create;
begin
  FScrollBar := True;
  FFlatScrollBars := False;
  FBorder3D := True;
  FContextMenu := True;
end;



출처
http://www.99inf.net/SoftwareDev/Delphi/52943.htm
http://tech.groups.yahoo.com/group/delphi-webbrowser/message/16


2010/11/08 15:01 2010/11/08 15:01
Article tag list Go to top
View Comment 1
Trackback URL :: 이 글에는 트랙백을 보낼 수 없습니다
From. 구차니 2010/11/14 14:20
답글달기삭제
C말고 다른 언어도 배워봐야 하는데 인터프리터 계열은 여전히 눈에 익지를 않네요 ㅎ
PREV : [1] : NEXT
 
 
 
 
PREV : [1] : NEXT
«   2019/10   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
전체 (796)
출판 준비 (0)
My-Pro... (41)
사는 ... (445)
블로그... (22)
My Lib... (32)
게임 ... (23)
개발관... (3)
Smart ... (1)
Delphi (76)
C Builder (0)
Object... (0)
VC, MF... (9)
Window... (1)
Open API (3)
Visual... (0)
Java, JSP (2)
ASP.NET (0)
PHP (4)
Database (12)
리눅스 (28)
Windows (20)
Device... (1)
Embedded (1)
게임 ... (0)
Web Se... (2)
Web, S... (19)
잡다한... (3)
프로젝트 (0)
Personal (0)
대통령... (9)
Link (2)