delphi 01 글꼴 속성 설정

60637 단어 Delphi
글꼴 속성 설정/가져오기
  • 이름
  • 크기
  • 굵게
  • 사체
  • 밑줄

  • 취소선
  • 색상 1
  • 색상 2
  •  
    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

    좋은 웹페이지 즐겨찾기