我试图通过使用TIdIMAP4Indy 10.6.0.4975 来获取我的IMAP邮箱的未读邮件数.
问题是,UnseenMsgs即使访问的邮箱中有一些未读邮件,该属性也会返回0.这是我使用的代码:
procedure TForm1.FormClick(Sender: TObject);
var
TotalMsgs: Integer;
UnseenMsgs: Integer;
begin
IdIMAP41.Connect(True);
IdIMAP41.SelectMailBox('Inbox');
TotalMsgs := IdIMAP41.MailBox.TotalMsgs; // returns correct value
UnseenMsgs := IdIMAP41.MailBox.UnseenMsgs; // <- returns always 0
IdIMAP41.Disconnect(False);
end;
Run Code Online (Sandbox Code Playgroud)
为什么TIdMailBox.UnseenMsgs属性返回0而不是正确的数字?
我在Windows 10上使用Delphi Berlin.我需要在基于tStringGrid的tForm上使用tOpenDialog.
当我双击一个与打开的对话框上的固定列或行重叠的文件onFixedCellClick事件在打开对话框消失后立即自动触发.在下图中,文件位于第一行的固定行的相同位置.
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
OpenDialog1: TOpenDialog;
procedure FormClick(Sender: TObject);
procedure StringGrid1FixedCellClick(Sender: TObject; ACol, ARow: Integer);
procedure FormCreate(Sender: TObject);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Options := StringGrid1.Options + [goFixedColClick, goFixedRowClick];
end;
procedure TForm1.FormClick(Sender: TObject);
begin
OpenDialog1.Execute;
end;
procedure TForm1.StringGrid1FixedCellClick(Sender: TObject; ACol, ARow: Integer);
begin
Caption := '';
end;
Run Code Online (Sandbox Code Playgroud)
在大多数情况下,我可以通过移动对话框窗口或单击文件一次并单击打开按钮来处理此问题,但我无法保证将使用此功能的其他人会这样做.
是什么原因以及如何解决这个问题?
我在Windows 10中使用Delphi 10.1 Berlin.
我有两个不同大小的记录.我编写代码来遍历其中两个TList<T>记录来测试经过的时间.循环遍历较大记录的列表运行速度要慢得多.
任何人都可以解释原因,并提供一个解决方案,使循环运行更快?
type
tTestRecord1 = record
Field1: array[0..4] of Integer;
Field2: array[0..4] of Extended;
Field3: string;
end;
tTestRecord2 = record
Field1: array[0..4999] of Integer;
Field2: array[0..4999] of Extended;
Field3: string;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
_List: TList<tTestRecord1>;
_Record: tTestRecord1;
_Time: TTime;
i: Integer;
begin
_List := TList<tTestRecord1>.Create;
for i := 0 to 4999 do
begin
_List.Add(_Record);
end;
_Time := Time;
for i := 0 to 4999 do
begin
if _List[i].Field3 = 'abcde' then
begin …Run Code Online (Sandbox Code Playgroud) 我在Windows 10中使用柏林.
以下消息处理程序在构建的应用程序中运行良好,但不在调试模式下.
我该如何调试消息处理程序?
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure onReceive(var message: TMessage); message WM_COPYDATA;
end;
procedure TForm1.onReceive(var message: TMessage);
begin
Memo1.Lines.Add('a');
end;
Run Code Online (Sandbox Code Playgroud)
发件人代码如下,结构的值没有意义.
procedure TForm1.FormClick(Sender: TObject);
var
_Handle: Cardinal;
_CopyDataStruct: TCopyDataStruct;
begin
_Handle := FindWindow(nil, 'test form');
_CopyDataStruct.dwData := 0;
_CopyDataStruct.cbData := Sizeof(_Handle);
_CopyDataStruct.lpData := @_handle;
SendMessage(_Handle, WM_COPYDATA, Handle, integer(@_CopyDataStruct));
end;
Run Code Online (Sandbox Code Playgroud) 在以下代码中:=不作为赋值运算符.帮助说"The:= symbol有时被称为赋值运算符".当它没有被称为赋值操作符时,我在帮助中找不到.
procedure TForm1.TestProcedure;
var
_Integer , _TemporaryInteger : Integer;
_StringList, _TemporaryStringList: TStringList;
begin
_Integer := 1;
_TemporaryInteger := _Integer;
_TemporaryInteger := 2; // doesn't change the original value that _Integer is 1
_StringList := TStringList.Create;
_StringList.Add('a');
_TemporaryStringList := _StringList;
_TemporaryStringList[0] := 'b'; // changes the original value _StringList[0] into 'b'
end;
Run Code Online (Sandbox Code Playgroud) 我使用tRichEdit来设置线条颜色.我想像tMemo一样减少行间距.
当我手动输入字母时,行空间自动减少但是当我使用tRichEdit.lines.add时没有任何反应.
如果不可能有替代品吗?

我在Windows 10中使用西雅图.
我尝试打印公共IP地址和网关地址.
最后一行发生访问冲突.
当我删除第1行时,它运作良好.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, System.Win.ComObj, Vcl.StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, winapi.iphlpapi, winapi.iptypes, winapi.winsock;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
IdHTTP1: TIdHTTP;
procedure FormCreate(Sender: TObject);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
_IPAdapterAddresses: PIP_ADAPTER_ADDRESSES;
_SizePointer: Integer;
begin
Label2.Caption := Label2.Caption + ' ' + IdHTTP1.Get'http://ipinfo.io/ip'); // line 1
_IPAdapterAddresses := AllocMem(_SizePointer);
GetAdaptersAddresses(2, 128, nil, _IPAdapterAddresses, @_sizepointer);
Label1.Caption := Label1.Caption + ' ' + string(inet_ntoa(_IPAdapterAddresses^.FirstGatewayAddress.Address.lpSockaddr.sin_addr)); // access violation
end;
Run Code Online (Sandbox Code Playgroud)
当我修改最后一行时,它可以正常工作.
Label1.Caption …Run Code Online (Sandbox Code Playgroud) 我使用的是Delphi 10和Windows 10.
以下代码使插入符号和选择在Edit1中消失.
procedure TForm1.Edit1Enter(Sender: TObject);
begin
Edit1.PasswordChar := '*';
end;
Run Code Online (Sandbox Code Playgroud)
焦点移动到另一个控件后,在onClick上运行良好.
我不能使用onClick,因为焦点按Tab键移动而Edit1应该以默认#0开头,因为它在焦点进入之前保存了'password'文本.
我怎么解决这个问题?