Как поменять цвет или стиль бордюра в TWebBrowser

Советы » Браузер » Как поменять цвет или стиль бордюра в TWebBrowser

uses

MSHTML; procedure

WB_SetBorderColor(Sender: TObject; BorderColor: String

); { BorderColor: Can be specified in HTML pages in two ways. 1) by using a color name (red, green, gold, firebrick, ...) 2) or by using numbers to denote an RGB color value. (#9400D3, #00CED1,...) See: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/ reference/properties/borderstyle.asp } var

Document : IHTMLDocument2; Element : IHTMLElement; begin

Document := TWebBrowser(Sender).Document as

IHTMLDocument2; if

Assigned(Document) then

begin

Element := Document.Body; if

Element <> nil

then

begin

Element.Style.BorderColor := BorderColor; end

; end

; end

; procedure

WB_SetBorderStyle(Sender: TObject; BorderStyle: String

); { BorderStyle values: 'none' No border is drawn 'dotted' Border is a dotted line. (as of IE 5.5) 'dashed' Border is a dashed line. (as of IE 5.5) 'solid' Border is a solid line. 'double' Border is a double line 'groove' 3-D groove is drawn 'ridge' 3-D ridge is drawn 'inset' 3-D inset is drawn 'window-inset' Border is the same as inset, but is surrounded by an additional single line 'outset' 3-D outset is drawn See: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/ reference/properties/borderstyle.asp } var

Document : IHTMLDocument2; Element : IHTMLElement; begin

Document := TWebBrowser(Sender).Document as

IHTMLDocument2; if

Assigned(Document) then

begin

Element := Document.Body; if

Element <> nil

then

begin

Element.Style.BorderStyle := BorderStyle; end

; end

; end

; procedure

WB_Set3DBorderStyle(Sender: TObject; bValue: Boolean); { bValue: True: Show a 3D border style False: Show no border } var

Document : IHTMLDocument2; Element : IHTMLElement; StrBorderStyle: string

; begin

Document := TWebBrowser(Sender).Document as

IHTMLDocument2; if

Assigned(Document) then

begin

Element := Document.Body; if

Element <> nil

then

begin

case

BValue of

False

: StrBorderStyle := 'none'; True

: StrBorderStyle := ''; end

; Element.Style.BorderStyle := StrBorderStyle; end

; end

; end

; procedure

TForm1.WebBrowser1NavigateComplete2(Sender: TObject; const

pDisp: IDispatch; var

URL: OleVariant); // Put this code in the OnDocumentComplete event as well begin

// Examples: // Show no border WB_Set3DBorderStyle(Sender, False

); // Draw a double line border WB_SetBorderStyle(Sender, 'double'); // Set a border color WB_SetBorderColor(Sender, '#6495ED'); end

; procedure

TForm1.Button1Click(Sender: TObject); begin

Webbrowser1.Navigate('www.SwissDelphiCenter.ch'); end

;

Другое по теме:

Категории

Статьи

Советы

Copyright © 2022 - All Rights Reserved - www.delphirus.com