标签: delphi-5

如何让我的Delphi 5应用程序显示密码"blobs"?

很简单,但我找不到答案.

我正在使用Delphi 5 Enterprise构建应用程序,并希望我的应用程序在密码字段中使用新的粗体黑点而不是星号.

我怎样才能做到这一点?

windows delphi delphi-5

4
推荐指数
2
解决办法
1702
查看次数

Delphi 5 - StrXoFloat在WinXP和Win2K上的结果不同

我有这个奇怪的问题,我的机器和生产服务器上的字符串转换得到不同的结果,例如:

procedure TForm1.Button1Click(Sender: TObject);
var
   s1: string;
   f1: double;
begin
   s1 := '1.234';
   f1 := StrToFloat(s1); 
end;

procedure TForm1.Button2Click(Sender: TObject);
var
   s2: string;
   f2: double;
begin
   s2 := '1,234';
   f2 := StrToFloat(s2); 
end;
Run Code Online (Sandbox Code Playgroud)

在我的WinXP机器上的'1.234'中的Button1Click结果不是有效的浮点值,而在Win2K机器上这可以正常工作.

另一端的Button2Click在我的WinXP上运行,但确实导致'1,234'不是有效的浮点值错误.

两台机器都将区域设置设置为"德语(奥地利)" - 任何关于为什么会发生这种情况的想法,或者至少为什么区域设置对话框确实显示与Delphi"DecimalSeparator"和"GetLocaleChar(GetThreadLocale,LOCALE_SDECIMAL)不同的十进制分隔符,'.')?

此致,Reinhard

delphi delphi-5

4
推荐指数
1
解决办法
2069
查看次数

Delphi:构造不调用重写的虚拟构造函数

我有一个例子的后代TBitmap:

TMyBitmap = class(TBitmap)
public
    constructor Create; override;
end;

constructor TMyBitmap.Create;
begin
   inherited;
   Beep;
end;
Run Code Online (Sandbox Code Playgroud)

在运行时,我构造其中一个TMyBitmap对象,将图像加载到其中,并将其放置TImage在窗体上:

procedure TForm1.Button1Click(Sender: TObject);
var
   g1: TGraphic;
begin
   g1 := TMyBitmap.Create;
   g1.LoadFromFile('C:\...\example.bmp');

   Image1.Picture.Graphic := g1;
end;
Run Code Online (Sandbox Code Playgroud)

在里面TPicture.SetGraphic你可以看到它通过构造一个新的,并调用.Assign新构建的克隆来制作图形的副本:

procedure TPicture.SetGraphic(Value: TGraphic);
var
   NewGraphic: TGraphic;
begin
   ...
   NewGraphic := TGraphicClass(Value.ClassType).Create;
   NewGraphic.Assign(Value);
   ...
end;
Run Code Online (Sandbox Code Playgroud)

构造新图形类的行:

NewGraphic := TGraphicClass(Value.ClassType).Create;
Run Code Online (Sandbox Code Playgroud)

正确调用我的构造函数,一切都很好.


我想做类似的事情,我想克隆一个TGraphic:

procedure TForm1.Button1Click(Sender: TObject);
var
   g1: TGraphic;
   g2: TGraphic;
begin
   g1 := TMyBitmap.Create;
   g1.LoadFromFile('C:\...\example.bmp');

   //Image1.Picture.Graphic := g1; …
Run Code Online (Sandbox Code Playgroud)

delphi virtual constructor delphi-5

4
推荐指数
1
解决办法
1039
查看次数

如何在Delphi中使用http身份验证打开URL?

如何打开需要"http身份验证"以透明方式传递登录名和密码的网址(浏览器窗口)?delphi中的遗留应用程序需要在Reporting Services的".aspx"中打开报告.

谢谢,塞尔索

delphi http http-authentication delphi-5

4
推荐指数
1
解决办法
9297
查看次数

Delphi 5与库不兼容

我正在尝试将Advantech(BDaqCL.pas)库添加到我在Delphi 5中的应用程序项目中,但.PAS文件中充斥着如下代码:

    AccessMode = (
  ModeRead = 0,
  ModeWrite,
  ModeWriteWithReset
);
Run Code Online (Sandbox Code Playgroud)

这会导致错误:

',' or ')' expected but '=' found
Run Code Online (Sandbox Code Playgroud)

这是Delphi后期版本中D5不兼容的功能吗?如果是这样,值得手动改变每个人(有很多)或者我是否会遇到更深层次的问题?

编辑:大多数枚举如上所述,但也有很多更复杂的如下.手动做的太多了:

DioPortDir = (
  Input   = $00,
  LoutHin = $0F,
  LinHout = $F0,
  Output  = $FF
);
Run Code Online (Sandbox Code Playgroud)

编辑:我开始将它们声明为常量.谁能告诉我,做以下事情是否正确

var
    DioPortDir = LongInt;
const
      Input   = $00;
      LoutHin = $0F;
      LinHout = $F0;
      Output  = $FF;
Run Code Online (Sandbox Code Playgroud)

我在哪里列出var声明并将const声明移到顶部.

我不确定当const不等于任何东西时该怎么做,例如

ValueRange = (
  V_OMIT = -1,            // Unknown when get, ignored when set
  V_Neg15To15 = 0,        // +/- 15 …
Run Code Online (Sandbox Code Playgroud)

delphi delphi-5

4
推荐指数
2
解决办法
475
查看次数

在调用ExitProcess之后,如何判断我是否在DLL_PROCESS_DETACH期间被调用?

我在Delphi中有一个单元(可以选择)提供一个全局对象:

var
   InternalThemeParkServices: TThemeParkServices;

function ThemeParkServices: TThemeParkServices;
begin
   if InternalThemeParkServices= nil then
      InternalThemeParkServices := TThemeParkServices.Create();
   Result := InternalThemeParkServices ;
end;

...

initialization
finalization
   FreeAndNil(InternalThemeServices);
end.
Run Code Online (Sandbox Code Playgroud)

我在进程关闭期间摧毁了自己.

注意:另一个代码变体是:

var
   InternalThemeParkServices: IThemeParkServices;

function ThemeParkServices: TThemeParkServices;
begin
   if InternalThemeParkServices= nil then
      InternalThemeParkServices := TThemeParkServices.Create();
   Result := InternalThemeParkServices ;
end;
Run Code Online (Sandbox Code Playgroud)

当程序关闭期间引用计数变为零时,接口变量被隐式销毁

当我的对象不再使用时(即在其中destructor),我调用各种WinAPI函数.

问题是如果有人使用我的DLL中的类(我无法控制的东西),那么在以下期间调用的任何东西:

finalization
Run Code Online (Sandbox Code Playgroud)

是德尔福的道德等同物DLL_PROCESS_DETACH.目前各种各样的东西不应该这样做时 DLL_PROCESS_DETACH ,当进程终止(如CoCreateInstance).

我知道Embarcadero使用:

initialization 
   if not IsLibrary then
   begin
      ...
Run Code Online (Sandbox Code Playgroud)

我也许可以适应,改变我的代码:

var
   InternalThemeParkServices: IThemeParkServices;
Run Code Online (Sandbox Code Playgroud)

(使用隐式清理),以:

var …
Run Code Online (Sandbox Code Playgroud)

delphi dll winapi process delphi-5

4
推荐指数
1
解决办法
1039
查看次数

TScrollBox具有自定义的扁平边框颜色和宽度?

我正在尝试创建带有扁平边框的TScrollBox而不是丑陋的“ Ctl3D”。

这是我尝试过的,但是边框不可见:

type
  TScrollBox = class(Forms.TScrollBox)
  private
    procedure WMNCPaint(var Message: TWMNCPaint); message WM_NCPAINT;
  protected
  public
    constructor Create(AOwner: TComponent); override;
  end;

...

constructor TScrollBox.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  BorderStyle := bsNone;
  BorderWidth := 1; // This will handle the client area
end;

procedure TScrollBox.WMNCPaint(var Message: TWMNCPaint);
var
  DC: HDC;
  R: TRect;
  FrameBrush: HBRUSH;
begin
  inherited;
  DC := GetWindowDC(Handle);
  GetWindowRect(Handle, R);
  // InflateRect(R, -1, -1);
  FrameBrush := CreateSolidBrush(ColorToRGB(clRed)); // clRed is here for testing
  FrameRect(DC, R, FrameBrush);
  DeleteObject(FrameBrush);
  ReleaseDC(Handle, DC);
end; …
Run Code Online (Sandbox Code Playgroud)

delphi delphi-5

4
推荐指数
1
解决办法
1545
查看次数

如何修复Delphi XE3迁移错误?

我正在将我的Delphi 5应用程序迁移到Delphi XE3.我在编译时得到了一些错误.有人可以帮我解决这些问题.提前感谢您的帮助.

  1. 我无法OemToChar在XE3中找到功能定义.当我按住Ctrl键并单击该功能时,它会显示消息Unable to locate 'WinAPI.Windows.pas'.我无法打开任何delphi组件文件.windows.pas位于系统上的位置是什么?或者如何解决?

  2. Incompatiable Types: 'PAnsiChar' and 'PWideChar'在下面的功能在线OemToChar(p1, p2).

function OemToAnsi(const Str: string): string;
var
  p1,
  p2: PChar;
begin
  p1 := PChar(Str);
  p2 := StrNew(p1);
  OemToChar(p1, p2);
  Result := StrPas(p2);
  StrDispose(p2);
end;
Run Code Online (Sandbox Code Playgroud)
  1. 'Low Bound Exceeds High Bound'在以下代码中获取错误.

function StrToRichText(const Str: string): string;
var
  i: integer;
begin
  Result := '';
  for i := 1 to Length(Str) do
  begin
    case Str[i] of
      #128 .. #255 :
        Result := Result + …
Run Code Online (Sandbox Code Playgroud)

delphi delphi-5 delphi-xe3

4
推荐指数
1
解决办法
4941
查看次数

如何在D5/D7中处理PByte指针操作(运算符不适用于此操作数类型)

我正在尝试将DDetourslib 移植到Delphi 5/7.不会编译的行具有以下模式:

procedure Decode_J(PInst: PInstruction; Size: Byte);
var
  Value: Int64;
  VA: PByte;
begin
  ...
  VA := PInst^.VirtualAddr + (PInst^.NextInst - PInst^.Addr) // <- compiler error
Run Code Online (Sandbox Code Playgroud)

编译错误:

[Error] InstDecode.pas(882):运算符不适用于此操作数类型

PInst^.VirtualAddr, PInst^.NextInst, PInst^.Addr都被声明为PByte(PByte = ^Byte)

我该怎么做才能解决这个问题?


编辑:

PInstruction 定义为:

  TInstruction = record
    Archi: Byte; { CPUX32 or CPUX64 ! }
    AddrMode: Byte; { Address Mode }
    Addr: PByte;
    VirtualAddr: PByte;
    NextInst: PByte; { Pointer to the Next Instruction }
    OpCode: Byte; { OpCode Value …
Run Code Online (Sandbox Code Playgroud)

delphi delphi-7 delphi-5

4
推荐指数
1
解决办法
621
查看次数

Delphi 5将类型转换为计算类型会导致无效的类型转换错误

调试时间

我需要转换VariantTNotifyEvent,但不能.

如图所示我GetPropValue用来获取a的OnClick属性TMenuItem.我必须将它与另一个进行比较TNotifyEvent,所以我必须将其转换为TNotifyEvent.

在运行时,这总是类型TNotifyEvent,但是当我尝试将其转换为代码时,代码无法编译TNotifyEvent.

我怎样才能使它工作?不幸的是我只有Delphi版本5,因此RTTI功能有限.

delphi delphi-5

4
推荐指数
1
解决办法
94
查看次数