标签: delphi-xe

Delphi - 打开对话框时激活键盘钩子

在一个应用程序上,我有一个键盘钩子,当按下Escape按钮时它会关闭MDI子窗体.打开TOpenDialog类后代时出现问题(使用Execute).考虑以下代码(仅作为示例)

unit Unit4;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm4 = class(TForm)
    OpenDialog1: TOpenDialog;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

function KeyboardProc(code: integer; wp: WPARAM; lp: LPARAM): LResult stdcall;
function CanDoCloseOnEscape: boolean;

var
  Form4: TForm4;
  KeybHook : HHook;


implementation

{$R *.dfm}

function CanDoCloseOnEscape: boolean;
var
  Control: TWinControl;
  Form: TForm;
begin
  Control := Screen.ActiveControl;
  Form := Screen.ActiveForm;
  Result := true;
end;

function …
Run Code Online (Sandbox Code Playgroud)

delphi delphi-xe

-1
推荐指数
1
解决办法
755
查看次数

loadfromfile 上的 TStringlist 错误:目标多字节代码页中不存在 Unicode 字符的映射

尝试使用该TStringList.LoadFromFile方法加载文件时出现以下异常:

stringlist1.loadfromfile('c:\example.txt');
Run Code Online (Sandbox Code Playgroud)

目标多字节代码页中不存在 Unicode 字符的映射

该文件是 Unicode,错误似乎与文件中存在的这个特殊字符有关。该example.txt文件只有一行,其内容如下所示:

该文件包含以下字节:

EF BB BF 5A 65 20 ED A0 BC ED B7 AB ED A0 BC ED B7 AE

任何解决方法?

delphi delphi-xe delphi-10.3-rio

-1
推荐指数
1
解决办法
430
查看次数

Delphi EXPERT ToolServices.getCurrentFile失败

什么是获取Delphi XE专家正在处理的当前文件的新方法

以前在Delphi 5-7中我们使用了ToolServices.getCurrentFile

delphi delphi-xe

-2
推荐指数
1
解决办法
462
查看次数

StrToDateDef无法正常工作

我想将系统日期时间转换为特定格式.我的系统格式是dd/mm/yy我想转换为mm/dd/yyyy,所以我使用的是StrToDateDef.我只需要使用StrToDateDef因为日期是字符串,如果有一个字符串而不是日期我将使用默认日期.我的代码如下

  str := '30/01/14';

  GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, FmtStngs);
  FmtStngs.DateSeparator := '/';
  FmtStngs.ShortDateFormat := 'mm/dd/yyyy';
  FmtStngs.TimeSeparator := ':';
  FmtStngs.LongTimeFormat := 'hh:nn';

  date := StrToDateDef(str,01/28/2013,FmtStngs);
Run Code Online (Sandbox Code Playgroud)

我期待这个日期是'01/30/2014',但它将以'30/01/14'的形式出现.我做错了什么?

delphi delphi-xe

-2
推荐指数
1
解决办法
1548
查看次数

从资源文件加载字体

我有一个包含以下资源的 Delphi XE 项目:

项目1

我已经使用function LoadResourceFont并尝试了以下代码:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function LoadResourceFontByName( const ResourceName : string; ResType: PChar ) : Boolean;
var
  ResStream  : TResourceStream;
  FontsCount : DWORD;
begin
  ResStream := TResourceStream.Create(hInstance, ResourceName, ResType);
  try
    Result  := (AddFontMemResourceEx(ResStream.Memory, ResStream.Size, nil, …
Run Code Online (Sandbox Code Playgroud)

delphi delphi-xe

-2
推荐指数
1
解决办法
4651
查看次数

如何从字段中获取值并分配给TStringList?

如何从下面的图像中获取所有用户名值,并将它们转换为TStringList,字符串或TMemo

在此输入图像描述

我尝试了以下代码,但它没有用.

with q3 do
  var txResul:stringlist
  begin
    Close;
    SQL.Clear;
    SQL.Add('SELECT*FROM user');
    Open;
    Next;
  end;
  txtResult.Add(q1.FieldByName('username').AsString);
Run Code Online (Sandbox Code Playgroud)

mysql delphi tstringlist tmemo delphi-xe

-2
推荐指数
1
解决办法
572
查看次数

Delphi XE 中编辑器的自动换行设置在哪里?

Delphi XE 中编辑器的自动换行设置在哪里?我在工具 -> 选项 -> 编辑器选项中找不到它。

delphi delphi-xe

-3
推荐指数
1
解决办法
1668
查看次数

标签 统计

delphi ×7

delphi-xe ×7

delphi-10.3-rio ×1

mysql ×1

tmemo ×1

tstringlist ×1