特定
type
TMyClass = class
private
FPrivateInt : Integer;
protected
FProtectedInt : Integer;
public
FPublicInt : Integer;
end;
Run Code Online (Sandbox Code Playgroud)
在一个单位和
type
TMyHelper = class helper for TMyClass
function Sum : Integer;
end;
[...]
function TMyHelper.Sum: Integer;
begin
Result := 0;
Result := Result + FPublicInt;
Result := Result + FProtectedInt;
Result := Result + FPrivateInt; // <- compiler error here
end;
Run Code Online (Sandbox Code Playgroud)
在另一个,XE8编译器报告错误"E2003未声明的标识符'FPrivateInt'.这是我直观地预期的,因为在声明类的单元外部的私有成员的可见性受限,如果我没有看到示例Marco Cantu的Delphi 2007手册p89/90,访问"帮助"类的私人领域,并在接受的答案的开头段落中明确声明
这似乎支持它:"众所周知,帮助者确实破解了私人可见性.因此,私人成员可以从班级助手那里看到......"
那么,为什么我会收到E2003 Undeclared Identifier错误?在我的理解或代码中,我显然在某处遗漏了某些东西.我使用XE4和XE6,btw和XE4在我引用的SO答案之前得到了相同的错误,这是从去年开始的.
无论我做什么,我似乎无法使用Firedac连接到Firebird 2.5嵌入式数据库.有趣的是,昨天它似乎工作,现在突然间它不会.
相反,为了让我的脑袋突然停止工作,我开始重建一个干净的项目,这样我就可以一步一步地弄清楚发生了什么.我将下载的软件包的全部内容从Firebird添加(复制)到我的应用程序目录和数据库本身.
为了避免文件夹问题,我设置了Delphi环境选项,将所有文件(和exe放在同一目录中.然后我使用了Firebird*.doc文件夹中的建议,并将fbembed.dll重命名为fbclient.dll.一些Firedac Q&A关于我读过的问题,Firedac需要fbembed.dll文件.好吧,我已经尝试了两种方式,它无论如何都不会工作....).但是让我坚持第一个问题fbclient.dll.
为了建立连接,我在数据模块上放了一个FDPhysFBDriverLink1和一个FDConnection1.
现在FDPhysFBDriverLink1:它的BaseDriverID是FB.对于DriverID,我尝试了两个建议:首先使用'FB',然后提供fbclient.dll的完整路径.没有人似乎有所作为.
当我转到Firedac Connection编辑器并输入我的数据库文件的路径时,我得到"无法加载供应商库(fbclient.dll或fbembed.dll)....错误.但这两个文件都在应用程序exe文件夹中(就像在embarcadero网站上建议的那样.那么Firedac在哪里寻找文件?我对Firebird和Firedac有点厌倦,因为他们不能简单地解释为什么连接成功必须做的事情.他们给的只是一些模糊的选项,它们都不起作用.添加这个 - 添加......最后......失败.
因此,如果有人有直接回答如何做到这一点的经验(没有链接,请...我已经看过并尝试过所有这些)我会非常感激.尝试建立一个简单的连接几天是非常愚蠢的.我也尝试过与Unidac类似的结果.所以在我第99次精神崩溃之前,我该怎么办才能完成连接?
我正在尝试(在D7中)设置一个带有消息泵的线程,最终我想将其移植到DLL中.
这是我的代码的相关/非平凡部分:
const
WM_Action1 = WM_User + 1;
scThreadClassName = 'MyThreadClass';
type
TThreadCreatorForm = class;
TWndThread = class(TThread)
private
FTitle: String;
FWnd: HWND;
FWndClass: WNDCLASS;
FCreator : TForm;
procedure HandleAction1;
protected
procedure Execute; override;
public
constructor Create(ACreator: TForm; const Title: String);
end;
TThreadCreatorForm = class(TForm)
btnCreate: TButton;
btnAction1: TButton;
Label1: TLabel;
btnQuit: TButton;
btnSend: TButton;
edSend: TEdit;
procedure FormShow(Sender: TObject);
procedure btnCreateClick(Sender: TObject);
procedure btnAction1Click(Sender: TObject);
procedure btnQuitClick(Sender: TObject);
procedure btnSendClick(Sender: TObject);
procedure WMAction1(var Msg : TMsg); message WM_Action1;
procedure …Run Code Online (Sandbox Code Playgroud) 我有一个 Excel 电子表格,但现在我的问题是我希望能够只读取特定的列,电子表格中的列超过 20,我只需要读取 3 列。
procedure TForm1.sh1(SheetIndex: integer);
Var
Xlapp1,Xlrange, Sheet:Variant ;
MaxRow, MaxCol,X, Y:integer ;
str:string;
arrData:Variant;
begin
try
Str:=trim(form1.OpenDialog1.FileName);
XLApp1 := createoleobject('excel.application');
XLApp1.Workbooks.open(Str) ;
Sheet := XLApp1.WorkSheets[SheetIndex] ;
MaxRow := Sheet.Usedrange.EntireRow.count ;
MaxCol := sheet.Usedrange.EntireColumn.count;
arrData:= Sheet.UsedRange.Value;
stringgrid1.RowCount:=maxRow+1;
StringGrid1.ColCount:=maxCol+1;
for x := 1 to maxCol do
for y := 1 to maxRow do
stringgrid1.Cells[x,y]:=arrData[y, x];
XLApp1.Workbooks.close;
Except
on E : Exception do begin
XLApp1.Workbooks.close;
ShowMessage(E.Message);
end;
end;
end;
Run Code Online (Sandbox Code Playgroud) 当使用旧的Delphi代码将一些文本输出到Excel时,我在一台机器上遇到错误"Interface not supported".我怎样才能解决这个问题?
您好我正在创建一个非常繁重的应用程序,它在另一个应用程序线程上继续并且还抓取句柄.因此,如果该应用程序会冻结,那么我的应用程序会在目标软件负载很重的情况下不时出现滞后现象
问题是,如果某种程度上更重的应用程序"滞后"我会遇到字符串的意外问题,它们会给我不可靠的输出.
任何人都知道为什么会这样,以及我如何解决这个问题或解决这个问题?
我目前正在使用的解决方案是belove,但这并不是我想要做的事情,因为它确实使运行时非常不可靠,因为我无法确定结果.
function GetInt(MyNum:string):integer;
begin
try
result := strtoint(MyNum);
except
result := 0;
end;
end;
Run Code Online (Sandbox Code Playgroud)
作为一个例子,我做了这个脚本,突然我得到$ ReBEFF不是一个有效的整数.(突然间它已经运行好几个小时了)
oldB是一个Byte,它作为转换为十六进制的数字处理.oldB设置为始终为0,它应该永远不会更改,尤其是对于甚至不在十六进制数字系统内的Re
xx0000 = B
00xx00 = G
0000xx = R
Run Code Online (Sandbox Code Playgroud)
示例脚本(这不是唯一一个遇到字符串问题的代码部分,它无缘无故地随机出现在整个应用程序中)
var
oldR:byte = 0;
oldG:byte = 30;
oldB:byte = 0;
_Down:bool = false;
function GetColor(R, G, B:byte):integer;
var
MyColor:string;
begin
MyColor := '';
MyColor := MyColor + inttohex(B, 2);
MyColor := MyColor + inttohex(G, 2);
MyColor := MyColor + inttohex(R, 2);
result := strtoint('$' + MyColor);
end;
procedure TMainF.DonateColorTimer(Sender: TObject); …Run Code Online (Sandbox Code Playgroud) 我有一个表单类TfrmWelcome,我希望能够在窗体(frmWelcome.MainPanelSourceEditor)的主要部分单击按钮时动态添加备忘录.
我对某些代码的尝试失败如下.我收到错误"未声明的标识符WelcomeMemo".我怎么能得到这个编译和工作?
type
WelcomeMemo : TMemo;
end;
implementation
procedure SetHelpWelcome;
begin
WelcomeMemo : TMemo.Create(frmWelcome);
with TMemo(FindComponent('WelcomeMemo')) do
begin
Parent := frmWelcome.MainPanelSourceEditor;
Run Code Online (Sandbox Code Playgroud) delphi ×7
excel ×2
delphi-xe3 ×1
delphi-xe6 ×1
delphi-xe8 ×1
firebird ×1
firedac ×1
helper ×1
pascal ×1
string ×1
wm-copydata ×1