如何在Delphi 2010中设置待办事项列表类别.此语法不起作用:
// TODO 1 -cImportant: Do this!
Run Code Online (Sandbox Code Playgroud) 我正在为Delphi 2010中的大型应用程序开发一个新模块.
我在两个项目的项目组中组织了我的源代码,一个用于构建完整的应用程序,另一个用于启动我的测试套件(与主应用程序共享一些源代码).
在单元的初始化期间,我需要采取不同的行动,这取决于我正在编译的两个中的哪一个.
unit MySharedUnit
var
flag : TFlagValues;
implementation
[...]
initialization
if IsTestProject then
flag := TestValue
else
flag := ReleaseValue;
end.
Run Code Online (Sandbox Code Playgroud)
目前,我使用项目定义的环境变量(仅在一个项目的选项中定义)来决定活动项目.
我的问题是:
是否有另外一种或更优雅的方法可以做到这一点,比如内置的#define'd值,当测试应用程序应该在Release模式下运行时,不需要我手动修改项目选项?
根据Firebird官方文档,包含Unicode字符串(SQL Server称为NVARCHAR)的列应声明为VARCHAR(x) CHARACTER SET UNICODE_FSS.所以我这样做了,但是当我用DBExpress查询表时,我得到的结果是一个TStringField,它只是AnsiString,而不是我期待的TWideStringField.
如何让DBX从Unicode字符串列中获取Unicode字符串结果?
我的应用程序是用Delphi 2010编译的.该应用程序加载Delphi 7编译的DLL,它加载Delphi 2010编译的DLL.
D2010 app LOADS D7 DLL LOADS D2010 DLL
Run Code Online (Sandbox Code Playgroud)
D7 DLL Widestrings的导出函数使用和Delphi 2010 DLL的导出函数使用strings.
众所周知,strings在Delphi 2010中是Unicode(2字节),在Delphi 7中它们是Ansi(1字节).
我的所有测试都告诉我,尽管不应该这样做,但它仍在工作.我想知道:
它为什么有效?
什么可能出错?
我应该使用哪个内存管理器(Delphi 2010或Delphi 7内存管理器DLL)
我有一个运行长操作的模型对象.我正在尝试在线程中运行其中一些操作以保持接口响应,一次下载2件事等,但我想尽可能地从接口代码中隐藏这些细节.我正在尝试使用AsyncCall库,但有问题.
type EUpdaterAction = (auFoundCurrentVersion, auFoundUpdateVersion);
type
TUpdater = class
public
procedure loadCurrentVersion();
procedure notify(action: EUpdaterAction);
end;
procedure TUpdater.loadCurrentVersion();
begin
TAsyncCalls.Invoke(procedure
begin
Assert(Windows.GetCurrentThreadId() <> System.MainThreadID);
//Really long code
TAsyncCalls.VCLSync(procedure begin notify(auFoundCurrentVersion); end);
end);
end;
Run Code Online (Sandbox Code Playgroud)
我在Windows 8.1上安装了全新的Delphi 2010.
我创建了一个新项目,在Packages下,我选择"Build with runtime packages".
我编译它并立即得到错误"[dcc致命错误] E2202必需包'找不到IndyCore'"
我已经检查过:包含IndyCore140.bpl的包可以在$ BDS\bin目录中找到,就像所有其他Indy相关的包一样.IndyCore.dcp文件也可以在$ BDS\lib和$ BDS\lib\debug中使用.
这让我疯了.任何提示?
这是我启用"显示命令行"选项时添加的命令行(为了便于阅读,添加了换行符):
dcc command line for "Project2.dpr"
c:\delphi\delphi2010\bin\dcc32.exe
--no-config
-LUrtl;vcl;vclx;vclimg;vclactnband;dbrtl;vcldb;vcldbx;bdertl;vcltouch;xmlrtl;
dsnap;dsnapcon;TeeUI;TeeDB;Tee;adortl;VclSmp;vclie;inet;inetdb;webdsnap;
websnap;inetdbbde;inetdbxpress;soaprtl;DbxCommonDriver;DbxClientDriver;
DBXInterBaseDriver;DBXMySQLDriver;dbexpress;dbxcds;tdbf;intrawebdb_100_140;
Intraweb_100_140;IndyCore;IndySystem;IndyProtocols
-M
-Q
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE
-DDEBUG
-Ic:\delphi\delphi2010\lib;"C:\Users\Public\Documents\RAD Studio\7.0\dcp"
-LE"C:\Users\Public\Documents\RAD Studio\7.0\Bpl"
-LN"C:\Users\Public\Documents\RAD Studio\7.0\Dcp"
-NB"C:\Users\Public\Documents\RAD Studio\7.0\Dcp"
-Oc:\delphi\delphi2010\lib;"C:\Users\Public\Documents\RAD Studio\7.0\dcp"
-Rc:\delphi\delphi2010\lib;"C:\Users\Public\Documents\RAD Studio\7.0\dcp"
-Uc:\delphi\delphi2010\lib;"C:\Users\Public\Documents\RAD Studio\7.0\dcp"
-K00400000
-NO"C:\Users\Public\Documents\RAD Studio\7.0\Dcp"
Project2.dpr
Run Code Online (Sandbox Code Playgroud)
我找不到任何可疑的东西.
编辑:Stefan Glienke在Google+上建议检查PATH环境变量,因为它可能太长了.它长约1400个字符.我将它减少到最低限度,224个字符,但它没有解决问题.
我希望我的Delphi应用程序在通知区域中显示动画托盘图标.我也搜索了这个,但我只得到了TTrayIcon我不使用的结果.
我使用Shell_NotifyIcon并无法弄清楚如何在通知区域中设置托盘图标的动画.(TTimer)用于为此设置Animate Interval 的Timer 应该能够随时停止和启动.
问题是我不知道如何TTimer在完成表单的第一次恢复后启动.
我的意思是用户打开我的程序,并将其最小化到系统托盘,它的系统托盘图标动画很好,用户再次出于某种原因恢复它,他再次将其最小化为系统托盘,然后系统托盘图标动画,TTimer应该能够重新开始,不应该像没有Animate的普通系统托盘图标那样显示.
我怎样才能做到这一点?
提前致谢.
Ctrl+ Shift+ K+ A展开所有折叠的方法,但是我找不到折叠文件中所有方法的方法。
我正在编写一个程序,使用Delphi 2010对字节序列进行Z85Encoding.所以我写了一个funtiom
function Z85Encode(input, output: TStream): integer
Run Code Online (Sandbox Code Playgroud)
并希望传入一个流.接下来我写了一个重载函数
function Z85Encode(b: TBytes): string;
Run Code Online (Sandbox Code Playgroud)
将字节序列写入TBytesStream(与TMemoryStream相同),调用encode函数,然后将编码数据读取到Result字符串.
问题是我发现TStream.Read的行为与文档非常不同,我无法理解.你可以用其他方式来完成这个功能,但我不太明白为什么?我可能想知道Delphi如何实现TBytes类型.
为了说明我的问题,我编写了以下测试程序
procedure Test;
var
iStream: TMemoryStream;
n: integer;
a: TBytes;
b: TBytes
c: array [0..4] of Byte;
begin
b := TEncoding.UTF8.GetBytes('abcdefghij'); // byte from 97 to 106
iStream := TMemoryStream.Create;
try
iStream.Write(b, Length(b));
iStream.Seek(0, soBeginning);
n := iStream.Read(a, 5); // expect only 5 bytes read, but the whole array is back.
ShowMessage(IntToStr(n)); // n is 5
ShowMessage(IntToStr(Length(a))); // length is 10!!
iStream.Seek(0, soBeginning);
n := iStream.Read(c, …Run Code Online (Sandbox Code Playgroud) 当我运行时,这个短信来了:字符串文字可能最多有255个元素
这是我的代码:
dm.qr_emp.SQl.Add('insert into emp_per(nom, prenom, date_naiss1, cle_ccp,nomf,prenomf,lieu_naiss,sex,adr,id_corps,id_fonction,id_categ,montant_resp,compte_ccp,etat,sal_base,id_grade,id_banque,id_degree,sal_unique,pfc,iep,num_social,sal_principale,ind,salaire,montant_irg,ss,nbr_enfant,nbr_enfant_sup) ');
dm.qr_emp.SQL.Add('values('+quotedstr(edit1.Text)+', '+quotedstr(edit2.Text)+','+quotedstr(formatdatetime('yyyy-dd-mm',datetimepicker1.DateTime))+', '+ edit4.Text+','+quotedstr(edit5.Text)+','+quotedstr(edit3.Text)+','+quotedstr(edit6.Text)+','+quotedstr(ComboBox3.Text)+','+quotedstr(edit8.Text)+','+ inttostr(id_corps)+','+ inttostr(id_fonction)+', '+quotedstr(edit10.Text)+','+floattostr(salair_responsabilite)+','+quotedstr(edit7.Text)+','+quotedstr(ComboBox5.Text)+','+floattostr(salaire_base)+','+ inttostr(id_grade)+','+ inttostr(id_banque)+','+ inttostr(id_degree)+','+quotedstr(ComboBox8.Text)+','+ floattostr(pfc)+','+quotedstr(edit15.Text)+','+quotedstr(edit13.Text)+','+ floattostr(sal_principale)+','+floattostr(ind)+','+quotedstr(edit20.text)+','+floattostr(montant_irg)+','+floattostr(ss)+', '+quotedstr(edit23.Text)+', '+quotedstr(edit26.Text)+' )');
dm.qr_emp.ExecSQL;
Run Code Online (Sandbox Code Playgroud) delphi-2010 ×10
delphi ×9
asynchronous ×1
dbexpress ×1
dll ×1
firebird ×1
indy ×1
system-tray ×1