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

📄 dxjsregister.pas

📁 Well known and usefull component for delphi 7
💻 PAS
📖 第 1 页 / 共 2 页
字号:

function TPropertyEditor.GetVarValue: Variant;
begin
  Result := GetVarValueAt(0);
end;

function TPropertyEditor.GetVarValueAt(Index: Integer): Variant;
begin
  with FPropList^[Index] do Result := GetVariantProp(Instance, PropInfo);
end;

function TPropertyEditor.GetValue: string;
begin
  Result := 'Unknown';
end;

function TPropertyEditor.GetVisualValue: string;
begin
  if AllEqual then
    Result := GetValue
  else
    Result := '';
end;

procedure TPropertyEditor.GetValues(Proc: TGetStrProc);
begin
end;

procedure TPropertyEditor.Initialize;
begin
end;

procedure TPropertyEditor.Modified;
begin
  if Designer <> nil then
    Designer.Modified;
end;

procedure TPropertyEditor.SetFloatValue(Value: Extended);
var
  I: Integer;
begin
  for I := 0 to FPropCount - 1 do
    with FPropList^[I] do SetFloatProp(Instance, PropInfo, Value);
  Modified;
end;

procedure TPropertyEditor.SetMethodValue(const Value: TMethod);
var
  I: Integer;
begin
  for I := 0 to FPropCount - 1 do
    with FPropList^[I] do SetMethodProp(Instance, PropInfo, Value);
  Modified;
end;

procedure TPropertyEditor.SetOrdValue(Value: Longint);
var
  I: Integer;
begin
  for I := 0 to FPropCount - 1 do
    with FPropList^[I] do SetOrdProp(Instance, PropInfo, Value);
  Modified;
end;

procedure TPropertyEditor.SetPropEntry(Index: Integer;
  AInstance: TPersistent; APropInfo: PPropInfo);
begin
  with FPropList^[Index] do
  begin
    Instance := AInstance;
    PropInfo := APropInfo;
  end;
end;

procedure TPropertyEditor.SetStrValue(const Value: string);
var
  I: Integer;
begin
  for I := 0 to FPropCount - 1 do
    with FPropList^[I] do SetStrProp(Instance, PropInfo, Value);
  Modified;
end;

procedure TPropertyEditor.SetVarValue(const Value: Variant);
var
  I: Integer;
begin
  for I := 0 to FPropCount - 1 do
    with FPropList^[I] do SetVariantProp(Instance, PropInfo, Value);
  Modified;
end;

procedure TPropertyEditor.Revert;
var
  I: Integer;
begin
  if Designer <> nil then
    for I := 0 to FPropCount - 1 do
      with FPropList^[I] do Designer.Revert(Instance, PropInfo);
end;

procedure TPropertyEditor.SetValue(const Value: string);
begin
end;

function TPropertyEditor.ValueAvailable: Boolean;
var
  I: Integer;
  S: string;
begin
  Result := True;
  for I := 0 to FPropCount - 1 do
  begin
    if (FPropList^[I].Instance is TComponent) and
      (csCheckPropAvail in TComponent(FPropList^[I].Instance).ComponentStyle) then
    begin
      try
        S := GetValue;
        AllEqual;
      except
        Result := False;
      end;
      Exit;
    end;
  end;
end;

function TPropertyEditor.GetInt64Value: Int64;
begin
  Result := GetInt64ValueAt(0);
end;

function TPropertyEditor.GetInt64ValueAt(Index: Integer): Int64;
begin
  with FPropList^[Index] do Result := GetInt64Prop(Instance, PropInfo);
end;

procedure TPropertyEditor.SetInt64Value(Value: Int64);
var
  I: Integer;
begin
  for I := 0 to FPropCount - 1 do
    with FPropList^[I] do SetInt64Prop(Instance, PropInfo, Value);
  Modified;
end;

function TPropertyEditor.GetIntfValue: IInterface;
begin
  Result := GetIntfValueAt(0);
end;

function TPropertyEditor.GetIntfValueAt(Index: Integer): IInterface;
begin
  with FPropList^[Index] do Result := GetInterfaceProp(Instance, PropInfo);
end;

procedure TPropertyEditor.SetIntfValue(const Value: IInterface);
var
  I: Integer;
begin
  for I := 0 to FPropCount - 1 do
    with FPropList^[I] do SetInterfaceProp(Instance, PropInfo, Value);
  Modified;
end;

function TPropertyEditor.GetEditValue(out Value: string): Boolean;
begin
  Result := False;
  try
    Value := GetValue;
    Result := True;
  except
    on E: EPropWriteOnly do Value := 'NotAvailable';
    on E: Exception do Value := E.Message; // 1-27-2003
//    on E: Exception do Value := Format('(%s)', [E.Message]);
  end;
end;

function TPropertyEditor.HasInstance(Instance: TPersistent): Boolean;
var
  I: Integer;
begin
  Result := True;
  for I := 0 to FPropCount - 1 do
    if FPropList^[I].Instance = Instance then Exit;
  Result := False;
end;

{$ENDIF}

procedure TMemoEdit.Edit;
var
  Form: TForm;
  Memo: TMemo;
  DXJavaScript: TDXJavaScript;
begin
  DXJavaScript := GetComponent(0) as TDXJavaScript;

  Form := TForm.Create(nil);
  Form.Left  := 100;
  Form.Top   := 200;
  Form.Width := 500;

  Memo := TMemo.Create(Form);
  Memo.Parent := Form;
  Form.Caption := 'JavaScript Script editor';
  Memo.Align := alClient;
  Memo.Lines.Text := DXJavaScript.SourceCode; //GetStrValue;
  Memo.Font.Size := 12;

  try
    Form.ShowModal;
    if Memo.Modified then
    begin
      DXJavaScript.SourceCode := Memo.Lines.Text;
      SetStrValue(Memo.Lines.Text);
    end;

  finally
    Form.Free;
  end;
end;

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

function TMemoEdit.GetValue: string;
begin
  result := '[JAVASCRIPT SOURCE]';
end;

procedure TMemoEdit.SetValue(const val: string);
begin
  SetStrValue(val);
end;

(*procedure TMemoEdit2.Edit;
var
  Form: TForm;
  Memo: TMemo;
  DXScript: TDXPascalScript;
begin
  DXScript := GetComponent(0) as TDXPascalScript;

  Form := TForm.Create(nil);
  Form.Left  := 100;
  Form.Top   := 200;
  Form.Width := 500;

  Memo := TMemo.Create(Form);
  Memo.Parent := Form;
  Form.Caption := 'Pascal Script editor';
  Memo.Align := alClient;
  Memo.Lines.Text := DXScript.SourceCode; //GetStrValue;
  Memo.Font.Size := 12;

  try
    Form.ShowModal;
    if Memo.Modified then
    begin
      DXScript.SourceCode := Memo.Lines.Text;
      SetStrValue(Memo.Lines.Text);
    end;

  finally
    Form.Free;
  end;
end;

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

function TMemoEdit2.GetValue: string;
begin
  result := '[PASCAL SOURCE]';
end;

procedure TMemoEdit2.SetValue(const val: string);
begin
  SetStrValue(val);
end;
*)

procedure Register;
Begin
  RegisterComponents('BPDX JavaScript', [
     TDXJavaScript,
//     TDXPascalScript,
     TDXJSAddTForm,
     TDXJSAddTApplication,
     TDXJSGraphicsConstants,
     TDXJSExtraDOM
{$IFDEF DBVALIDATION}
     ,TDXJS_DBValidation
{$ENDIF}
{$ifdef REPORT_WORKS}
     ,TDXJS_REPORTWORKS
{$endif}
  ]);

  RegisterPropertyEditor(TypeInfo(String), TDXJavaScript, '', TMemoEdit);
//  RegisterPropertyEditor(TypeInfo(String), TDXPascalScript, '', TMemoEdit2);
End;


end.

⌨️ 快捷键说明

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