⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iwhtmllistde.pas

📁 TMS IntraWEb增强控件TMSIntraWeb_v2.3.2.1_D2007.rar
💻 PAS
字号:
{***************************************************************************}
{ TMS IntraWeb Component Pack Pro                                           }
{ for Delphi & C++Builder                                                   }
{ version 2.2                                                               }
{                                                                           }
{ written by TMS Software                                                   }
{            copyright ?2002 - 2004                                        }
{            Email : info@tmssoftware.com                                   }
{            Web : http://www.tmssoftware.com                               }
{                                                                           }
{ The source code is given as is. The author is not responsible             }
{ for any possible damage done due to the use of this code.                 }
{ The component can be freely used in any application. The complete         }
{ source code remains property of the author and may not be distributed,    }
{ published, given or sold in any form as such. No parts of the source      }
{ code can be included in any other component or application without        }
{ written authorization of the author.                                      }
{***************************************************************************}

unit IWHTMLListDE;
{$I TMSDEFS.INC}
interface

uses
  IWHTMLListProp, Classes, Forms, Dialogs, Controls, Windows, TypInfo, Graphics,
  Sysutils,DesignIntf, DesignEditors;
//{$IFDEF DELPHI6_LVL}
//  DesignIntf, DesignEditors
//{$ELSE}
//  DsgnIntf
//{$ENDIF}
//  ;

type
  TIWHTMLListDefaultEditor = class(TDefaultEditor)
  protected
//  {$IFNDEF DELPHI6_LVL}
//    procedure EditProperty(PropertyEditor: TPropertyEditor;
//                           var Continue, FreeEditor: Boolean); override;
//  {$ELSE}
//    procedure EditProperty(const Prop:IProperty; var Continue:Boolean); override;
//  {$ENDIF}
  public
    function GetVerb(index:integer):string; override;
    function GetVerbCount:integer; override;
    procedure ExecuteVerb(Index:integer); override;
  end;

  TIWHTMLStringListProperty = class(TClassProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure Edit; override;
    procedure SetValue(const Value: String); override;
    function GetValue: String; override;
  end;

implementation

function TIWHTMLStringListProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog];
end;

procedure TIWHTMLStringListProperty.Edit;
var
  HTMLEditor: THTMLListEditor;
  PropInfo: PPropInfo;
  sl,tmplst: TStringList;
  s,su: string;
  i: Integer;
begin
  HTMLEditor := THTMLListEditor.Create(Application);

  sl := TStringList.Create;

  try
    PropInfo:= typInfo.GetPropInfo(GetComponent(0).ClassInfo,'BaseDir');
    if Assigned(PropInfo) then
      HTMLEditor.HTMLStaticText1.BaseDir := GetStrProp(GetComponent(0),PropInfo);

    HTMLEditor.ToolButton3.Enabled := GetComponent(0).ClassName = 'TTIWStaticMenu';

    tmplst := TStringList(GetOrdValue);

    sl.Assign(tmplst);

    for i := 1 to sl.Count do
    begin
      s := sl.Strings[i - 1];
      if pos('"#',s) = 1 then
      begin
        delete(s,1,2);
        su := copy(s,1,pos('"',s) - 1);
        delete(s,1,pos('"',s));

        sl.Strings[i - 1] := s;
        sl.Objects[i - 1] := TObject(StrToInt(su));
      end;
    end;

    HTMLEditor.Memo1.Lines.Clear;
    if Assigned(sl) then
    begin
      if sl.Count > 0 then
      begin
        HTMLEditor.Memo1.Lines.Text := sl.Strings[0];
        if Assigned(sl.Objects[0]) then
          HTMLEditor.Panel2.Color := TColor(sl.Objects[0]);
      end;
      HTMLEditor.ListBox1.Items.Assign(sl);
      HTMLEditor.ListBox1.ItemIndex := 0;       
    end;

    if HTMLEditor.Showmodal = mrOK then
    begin
      sl.Assign(HTMLEditor.Listbox1.Items);

      for i := 1 to sl.Count do
      begin
        if Assigned(sl.Objects[i - 1]) then
        begin
          s := '"#'+IntToStr(Integer(sl.Objects[i - 1]))+'"'+sl.Strings[i - 1];
          sl.Strings[i - 1] := s;
        end;
      end;
      tmplst.Assign(sl);

      Designer.Modified;
    end;

  finally
    sl.Free;
    HTMLEditor.Free;
  end;
end;

procedure TIWHTMLStringListProperty.SetValue(const Value: String);
begin
end;

function TIWHTMLStringListProperty.GetValue: String;
begin
  Result := '(HTMLStringList)';
end;

{ TIWHTMLDefaultEditor }
//{$IFDEF DELPHI6_LVL}
//procedure TIWHTMLListDefaultEditor.EditProperty(const Prop:IProperty; var Continue:Boolean);
//{$ELSE}
//procedure TIWHTMLListDefaultEditor.EditProperty(PropertyEditor: TPropertyEditor;
//  var Continue, FreeEditor: Boolean);
//{$ENDIF}
//var
//  PropName: string;
//begin
// {$IFDEF DELPHI6_LVL}
//  PropName := Prop.GetName;
// {$ELSE}
//  PropName := PropertyEditor.GetName;
// {$ENDIF}
//  if (CompareText(PropName, 'ITEMS') = 0) then
//  begin
//  {$IFDEF DELPHI6_LVL}
//    Prop.Edit;
//  {$ELSE}
//    PropertyEditor.Edit;
//  {$ENDIF}
//    Continue := False;
//  end;
//end;



procedure TIWHTMLListDefaultEditor.ExecuteVerb(Index: integer);
var
  compiler:string;
begin
  case Index of
  0: Edit;
  1: begin
       {$IFDEF VER130}
         {$IFDEF BCB}
         compiler:='C++Builder 5';
         {$ELSE}
         compiler:='Delphi 5';
         {$ENDIF}
       {$ENDIF}
       {$IFDEF VER140}
         {$IFDEF BCB}
         compiler:='C++Builder 6';
         {$ELSE}
         compiler:='Delphi 6';
         {$ENDIF}
       {$ENDIF}
       {$IFDEF VER140}
         compiler:='Delphi 7';
       {$ENDIF}

       MessageDlg(Component.ClassName + ' for ' + Compiler + #13#10#13#10'?2002 - 2003 by TMS software'#13#10'http://www.tmssoftware.com',
                  mtInformation,[mbok],0);
     end;
  end;
end;



function TIWHTMLListDefaultEditor.GetVerb(index: integer): string;
begin
  Result := '';
  case Index of
  0:Result := 'HTML List Editor';
  1:Result := 'About';
  end;
end;

function TIWHTMLListDefaultEditor.GetVerbCount: integer;
begin
  Result := 2;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -