一个非常简单的测试用例:
alt text http://17slon.com/krama/hotkey.png
procedure TForm3.btnCopyClick(Sender: TObject);
begin
HotKey2.HotKey := HotKey1.HotKey;
end;
Run Code Online (Sandbox Code Playgroud)
在第一个THOTKey中按"PgDn"键,显示"Page Down".单击==>按钮,第二个THOTKey将显示"Num 3".
如果按下修改器(Shift等),也会发生类似的事情.该行为也适用于PgUp,Home,End和Ins.
据我所见,这发生在Windows内部:(正确的虚拟代码(34)沿着HKM_SETHOTKEY消息发送.
有人知道一个很好的解决方法吗?目前,我得到的唯一想法是发送伪造的WM_KEYDOWN/WM_KEYUP消息,参数设置为VK_NEXT和MapVirtualKey(VK_NEXT),但这有点难看......
热键只是简单的THOTKeys:
object HotKey1: THotKey
Left = 12
Top = 14
Width = 121
Height = 19
InvalidKeys = []
Modifiers = []
TabOrder = 0
end
object HotKey2: THotKey
Left = 194
Top = 14
Width = 121
Height = 19
InvalidKeys = []
Modifiers = []
TabOrder = 1
end
object btnCopy: TButton
Left = 143
Top = 14
Width = …Run Code Online (Sandbox Code Playgroud) 我有以下定义.
type
TOmniTaskDelegate = reference to procedure(const task: IOmniTask);
Run Code Online (Sandbox Code Playgroud)
我应该使用什么类型的容器(应该在D2009中支持)来存储TOmniTaskDelegate实例的列表?目前我正在使用,array of TOmniTaskDelegate但我对此并不满意.
我正在尝试将此代码片段转换为Delphi,而我却陷入困境for each objWBL in colObjects.
if not objBcdStore.EnumerateObjects( &h10200003, colObjects ) then
WScript.Echo "ERROR objBcdStore.EnumerateObjects( &h10200003 ) failed."
WScript.Quit(1)
end if
for each objWBL in colObjects
WScript.Echo ""
WScript.Echo "Windows Boot Loader"
WScript.Echo "-------------------"
WScript.Echo "identifier " & GetBcdId( objWBL.Id )
If objWBL.Id = current then
if not objWBL.GetElement(BcdOSLoaderInteger_NumberOfProcessors, objElement ) then
WScript.Echo "ERROR WBL GetElement for " & Hex(BcdOSLoaderInteger_NumberOfProcessors) & " failed."
WScript.Quit(1)
end if
WScript.Echo "numproc " & objElement.Integer
if not objWBL.GetElement(BcdOSLoaderBoolean_UseBootProcessorOnly, objElement ) then
WScript.Echo …Run Code Online (Sandbox Code Playgroud) 我有一个算法.我想在某个时候暂停它,然后在用户按下按钮后继续.我怎么做?我浏览了文档,搜索了互联网,但还没有运气.
这是一个相关的代码片段:
if A[i]>A[i+1]
then
begin
Zameni(i,i+1);
done:=true;
sleep(pauza);
br:=br+1;
end;
Run Code Online (Sandbox Code Playgroud)
现在,我使用睡眠(pauza只是一个常数,意味着在塞尔维亚暂停).理想情况下,我想用一个可以间隔睡眠的程序替换该行,或者根据配置设置等待按下按钮.
编辑1:啊,是的,如果它不明显 - 它是一个图形应用程序,而不是控制台,所以拍打"readln"将无法正常工作(遗憾).
不幸的是,我没有从我的开发PC中写这个问题所以我可能会犯一些错误.请抱歉...所以 - 我的问题 - 您使用什么方法在应用程序中实现错误记录?
在web(http://delphi.about.com)是很好的事件处理程序,但它只是复制文件中的系统错误,但我想通过捕获内存和堆栈(和处理器信息,如果我有时间)扩展其功能).我是否应该知道我是否动态调用它,而不是在表单上添加其组件?
procedure TForm1.ApplicationEvents1Exception(Sender: TObject; E: Exception) ;
var
ErrorLogFileName : string;
ErrorFile : TextFile;
ErrorData : string;
begin
ErrorLogFileName := ChangeFileExt(Application.ExeName,'.error.log') ;
AssignFile(ErrorFile, ErrorLogFileName) ;
//either create an error log file, or append to an existing one
if FileExists(ErrorLogFileName) then
Append(ErrorFile)
else
Rewrite(ErrorFile) ;
try
//add the current date/time and the exception message to the log
ErrorData := Format('%s : %s',[DateTimeToStr(Now),E.Message]) ;
WriteLn(ErrorFile,ErrorData) ;
finally
CloseFile(ErrorFile)
end;
//Show the exception
Application.ShowException(E) ;
end; …Run Code Online (Sandbox Code Playgroud) 我试图通过"OnMouseMove事件"使用Scanline获取图像中的当前像素.
相当于这个的东西:
Label1.Caption := IntToStr(Image1.Picture.Bitmap.Canvas.Pixels[X,Y]);
Run Code Online (Sandbox Code Playgroud)
有任何想法吗 ?
我正在撕扯我的头发!
即使像这样的工作很简单:
procedure MyAdoQueryTest();
const MYSQL_CONNECT_STRING='Driver={MySQL ODBC 5.1 Driver};Server=%s;Port=3306;Database=%s;User=%s;Password=%s;Option=3;';
var AdoConnection : TADOConnection;
ADOQuery : TADOQuery;
Param : TParameter;
begin
AdoConnection := TADOConnection.Create(Nil);
AdoConnection.ConnectionString := Format(MYSQL_CONNECT_STRING,['localhost',
'mysql',
'root',
'']);
AdoConnection.LoginPrompt := False;
AdoConnection.Connected := True;
ADOQuery := TADOQuery.Create(Nil);
ADOQuery.Connection := AdoConnection;
ADOQuery.Sql.Clear();
ADOQuery.SQl.Add('SHOW :what_to_show');
Param := ADOQuery.Parameters.ParamByName('what_to_show');
Param.DataType := ftString;
Param.Value := 'databases';
ADOQuery.Prepared := true;
ADOQuery.Active := True;
end;
Run Code Online (Sandbox Code Playgroud)
(顺便说一下,我真的需要使用'Param'变量和3个语句,或者我只能'ADOQuery.Parameters.ParamByName('what_to_show').值:='数据库';?)
无论如何,当我运行它时,我得到一个例外,ADOQuery.SQl.Add('SHOW :what_to_show');其中说"参数类型错误,超出可接受的范围或彼此冲突".
我要做的是创建两个中心函数:一个将接受并执行任何不会返回任何数据的SQL语句(如INSERT INTO)和将要返回的任何数据(如SELECT).
我目前只使用AdoConnection,但我现在正在尝试使用AdoQuery,因为我想参数化我的SQL语句来处理带引号的字符串.
我可以有halpz吗?
好的,我一直试图找出我正在制造的每一个可能的错误,但我放弃......我需要帮助!我正在写的是一个应用程序来管理我的工作租金,当日期过去时,我的应用程序从2个文本文件中删除名称.我编写了3个小函数(程序)来完成这项工作.这里:
这个从dates.dat文件加载并删除包含该员工姓名的行.
procedure remDate(emp: String);/// Removes employee from date file
var
pos1, i: integer;
dateList: TStringList;
begin
dateList:=TStringList.Create;
dateList.LoadFromFile('Data\dates.dat');
for i:=0 to dateList.Count-1 do begin
pos1:=AnsiPos(emp, dateList[i]);
if pos1<>0 then begin
dateList.Delete(i);
dateList.SaveToFile('Data\dates.dat');
end;
end;
dateList.Free;
end; //eo remDate
Run Code Online (Sandbox Code Playgroud)
这个从perm.dat文件中删除包含员工姓名的行.
procedure remPerm(emp: String);/// Removes employee from perm file
var
pos1, i: integer;
permList: TStringList;
begin
permList:=TStringList.Create;
permList.LoadFromFile('Data\perm.dat');
for i:=0 to permList.Count-1 do begin
pos1:=AnsiPos(emp, permList[i]);
if pos1<>0 then begin
permList.Delete(i);
permList.SaveToFile('Data\perm.dat');
end;
end;
permList.Free;
end; //eo remPerm
Run Code Online (Sandbox Code Playgroud)
这个把它们粘在一起.isDue是一个简单的函数,它比较2个日期,如果日期是今天或过去,则返回TRUE.
procedure updatePerms; …Run Code Online (Sandbox Code Playgroud) 我热衷于在Delphi语言中找到未记录的新条件定义和关键字.
像{$ WARN GARBAGE ON}这样的东西
http://qc.embarcadero.com/wc/qcmain.aspx?d=77686
我在Quality Central报告了这些内容,但问题已经关闭并且"升级到内部数据库".
这是什么意思?我是否应该期待这个已有一年半问题的答案?
使用OmniThreadLibrary和Delphi XE4,我希望运行多个在后台处理数据的线程,为我现有的代码增加速度.
调用下面的过程时,Application GUI将停止处理任何输入,直到所有线程都完成为止.我的理解是,.NoWait即使线程正在运行,using也应允许该过程退出.
procedure Test(input: TStringList; output: TList<TMaintFore>);
var
outQueue: IOmniBlockingCollection;
transaction: TOmniValue;
begin
outQueue := TOmniBlockingCollection.Create;
Parallel.ForEach(0, input.Count - 1)
.NoWait
.Into(outQueue)
.Execute(
procedure(const value: integer; var result: TOmniValue)
begin
result := TMaintFore.Create(input[value]);
end
);
end;
Run Code Online (Sandbox Code Playgroud)
我对ForEach循环的理解是否不正确,建议我应该使用替代方法来实现后台处理?任何关于正确使用OmniThreadLibrary的建议都表示赞赏.
Vista Service Pack 2上的Delphi 6似乎无法从dfm加载图像列表并在IDE中再次保存.dfm损坏的项目无法重建.
我运行项目时的错误是:
读取imagelist1.Bitmap时出现EReadError错误:无法从流中读取ImageList数据
有什么建议吗?
提前致谢
我的应用程序中有线程在另一个应用程序中显示消息框,在线程创建它的每个事件上都带有标题“测试”,在该线程结束时,我想关闭所有这些消息。
我试图创建这样的循环
while FindWindow(Nil,PChar('Test')) <> 0 do
begin
Sleep(5); //if i remove the sleep the application will hanging and froze.
SendMessage(FindWindow(Nil,PChar('Test')), WM_CLOSE, 0, 0); // close the window message
end;
Run Code Online (Sandbox Code Playgroud)
但是这个循环只有当我手动关闭最后一条消息时才有效
注意:消息框来自另一个不在同一个应用程序中的应用程序有这个线程。
我正在尝试校验一个图像,但是给出一个结果,尝试添加值和Adler-32需要很长时间,但两者都会在很长一段时间内完成(大约2秒).
添加值:
Function Checksum_CountryFlag(Img : TPicture):Integer;
var j, k, Checksum : Integer;
begin
Checksum := 0;
For j := 0 to Img.Width do
For k := 0 to Img.Height do
If (((Img.Bitmap.Canvas.Pixels[j,k]) <> 15577344) And ((Img.Bitmap.Canvas.Pixels[j,k]) <> 15311104) And ((Img.Bitmap.Canvas.Pixels[j,k]) <> 3816255) And ((Img.Bitmap.Canvas.Pixels[j,k]) <> 10526623) And ((Img.Bitmap.Canvas.Pixels[j,k]) <> 12303034) And ((Img.Bitmap.Canvas.Pixels[j,k]) <> 9013641)) Then
begin
Checksum := Checksum + Img.Bitmap.Canvas.Pixels[j,k];
end;
Result := Abs(Checksum);
end;
Run Code Online (Sandbox Code Playgroud)
阿德勒-32:
Function Checksum_Adler32(Img : TPicture):Integer;
var i,a,b,j,k : Integer;
begin
a := 1; b …Run Code Online (Sandbox Code Playgroud) delphi ×13
bcdstore ×1
bug-tracking ×1
comments ×1
components ×1
containers ×1
delphi-xe ×1
delphi-xe4 ×1
dynamic ×1
for-loop ×1
static ×1
tstringlist ×1
winapi ×1
wmi ×1