delphi 01 글꼴 속성 설정
60637 단어 Delphi
취소선
uses
MSHTML;
//설정
//------------------------------------------------------------------------------
procedure WB_SetFontName();
begin
(Form1.webbrowser1.Document as IHTMLDocument2).execCommand('FontName', False, Form1.cbb_FontNameList.Text);
end;
//------------------------------------------------------------------------------
procedure WB_SetFontSize();
begin
(Form1.webbrowser1.Document as IHTMLDocument2).execCommand('FontSize', false, StrToInt(Form1.cbb_FontSize.Text));
end;
//------------------------------------------------------------------------------
procedure WB_SetBold();
begin
(Form1.webbrowser1.Document as IHTMLDocument2).execCommand('Bold', False, 1);
end;
//------------------------------------------------------------------------------
procedure WB_Setstrike();
begin
(Form1.webbrowser1.Document as IHTMLDocument2).execCommand('StrikeThrough', False, 1);
end;
//------------------------------------------------------------------------------
procedure WB_SetItalic();
begin
(Form1.webbrowser1.Document as IHTMLDocument2).execCommand('Italic', False, 1);
end;
//------------------------------------------------------------------------------
procedure WB_SetUnderline();
begin
(Form1.webbrowser1.Document as IHTMLDocument2).execCommand('Underline', False, 1);
end;
//------------------------------------------------------------------------------
// HTML
procedure WB_SetForeColor();
begin
(Form1.WebBrowser1.Document as IHTMLDocument2).execCommand('ForeColor', False, '#CD0000');
end;
//------------------------------------------------------------------------------
procedure WB_SetBackColor();
begin
(Form1.WebBrowser1.Document as IHTMLDocument2).execCommand('BackColor',false, '#8EE5EE');
end;
//획득
//------------------------------------------------------------------------------
//First chance exception at $759E9617. Exception class EOleException with message ' 。'. Process Webbrowser.exe (6472)
function GetFontName():string;
begin
Result:=(Form1.webbrowser1.Document as IHTMLDocument2).queryCommandValue('FontName');
end;
//------------------------------------------------------------------------------
function GetFontSize():string;
begin
Result:=(Form1.webbrowser1.Document as IHTMLDocument2).queryCommandValue('FontSize');
end;
//------------------------------------------------------------------------------
function GetFontColor():TColor;
begin
Result:=(Form1.webbrowser1.Document as IHTMLDocument2).queryCommandValue('ForeColor');
end;
//------------------------------------------------------------------------------
function GetFontBgColor():TColor;
begin
Result:=(Form1.webbrowser1.Document as IHTMLDocument2).queryCommandValue('BackColor');
end;
//------------------------------------------------------------------------------
function IsBold():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as IHTMLDocument2).queryCommandState('Bold');
if bRtn then
Result:=True
else
Result:=False;
end;
//------------------------------------------------------------------------------
function IsItalic():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as IHTMLDocument2).queryCommandState('Italic');
if bRtn then
Result:=True
else
Result:=False;
end;
//------------------------------------------------------------------------------
function IsUnderline():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as IHTMLDocument2).queryCommandState('Underline');
if bRtn then
Result:=True
else
Result:=False;
end;
//------------------------------------------------------------------------------
function IsStrikeThrough():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as IHTMLDocument2).queryCommandState('StrikeThrough');
if bRtn then
Result:=True
else
Result:=False;
end;
//------------------------------------------------------------------------------
function IsSubScript():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as IHTMLDocument2).queryCommandState('SubScript');
if bRtn then
Result:=True
else
Result:=False;
end;
//------------------------------------------------------------------------------
function IsSuperScript():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as IHTMLDocument2).queryCommandState('SuperScript');
if bRtn then
Result:=True
else
Result:=False;
end;
//------------------------------------------------------------------------------
function IsJustifyLeft():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as IHTMLDocument2).queryCommandState('JustifyLeft');
if bRtn then
Result:=True
else
Result:=False;
end;
//------------------------------------------------------------------------------
function IsJustifyCenter():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as IHTMLDocument2).queryCommandState('JustifyCenter');
if bRtn then
Result:=True
else
Result:=False;
end;
//------------------------------------------------------------------------------
function IsJustifyRight():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as IHTMLDocument2).queryCommandState('JustifyRight');
if bRtn then
Result:=True
else
Result:=False;
end;
//------------------------------------------------------------------------------
function IsJustifyFull():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as IHTMLDocument2).queryCommandState('JustifyFull');
if bRtn then
Result:=True
else
Result:=False;
end;
//------------------------------------------------------------------------------
function IsInsertOrderedList():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as IHTMLDocument2).queryCommandState('InsertOrderedList');
if bRtn then
Result:=True
else
Result:=False;
end;
//------------------------------------------------------------------------------
function IsInsertUnorderedList():Boolean;
Var bRtn:Boolean;
begin
bRtn:= (Form1.webbrowser1.Document as IHTMLDocument2).queryCommandState('InsertUnorderedList');
if bRtn then
Result:=True
else
Result:=False;
end;
//------------------------------------------------------------------------------
//
procedure TForm1.WebBrowser1CommandStateChange(ASender: TObject;
Command: Integer; Enable: WordBool);
begin
//------------------------------------------------------------------------------
if WebBrowser1.ReadyState =READYSTATE_COMPLETE then
if GetSelText<>'' then
begin
mni_Copy.Enabled:=True;
btn_Copy.Enabled:=True;
btn_Cut.Enabled:=True;
mni_Cut.Enabled:=True;
end
else
begin
mni_Copy.Enabled:=false;
btn_Copy.Enabled:=False;
btn_Cut.Enabled:=False;
mni_Cut.Enabled:=false;
end;
//
if IsClipboardFormatAvailable(CF_TEXT) then
begin
btn_Paste.Enabled:=True;
mni_Paste.Enabled:=True;
end
else
begin
btn_Paste.Enabled:=False;
mni_Paste.Enabled:=False;
end;
//------------------------------------------------------------------------------
try
//cbb_FontNameList.Text:=GetFontName();
cbb_FontNameList.ItemIndex :=cbb_FontNameList.Items.IndexOf( GetFontName());
//cbb_FontSize.Text:=GetFontSize();
cbb_FontSize.ItemIndex :=cbb_FontSize.Items.IndexOf( GetFontSize());
btn_Bold.Down:=IsBold();
btn_Italic.Down:=IsItalic();
btn_Underline.Down:=IsUnderline();
btn_strikethrough.Down:=IsStrikeThrough();
btn_SubScript.Down:=IsSubScript();
btn_SuperScript.Down:=IsSuperScript();
ToolButton_AlignTwo.Down:=IsJustifyFull();
ToolButton_AlignLeft.Down:=IsJustifyLeft();
ToolButton_AlignCenter.Down:=IsJustifyCenter();
ToolButton_AlignRight.Down:=IsJustifyRight();
ToolButton_UnoredredList.Down:=IsInsertUnorderedList();
ToolButton_OrderedList.Down:=IsInsertOrderedList();
//
except
Exit;
end;
case Command of
CSC_NAVIGATEBACK: ToolButton_Back.Enabled := Enable; //“ ”
CSC_NAVIGATEFORWARD: ToolButton_Forward.Enabled := Enable; //“ ”
CSC_UPDATECOMMANDS: ToolButton_Stop.Enabled := TWebBrowser(ASender).Busy; //“ ”
end;
end;
Wiz
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[Delphi] TStringBuilder그리고 꼭 사용해야만 할까? 그림처럼 Heap 영역에 "Hello" 공간을 생성하고 포인팅을 한다. "Hello World" 공간을 새로 생성한 후 포인팅을 하게 된다. 결국 "Hello" 라는 String 객체가 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.