我实现了这个代码,但我又无法搜索子目录.
procedure TFfileSearch.FileSearch(const dirName:string);
begin
//We write our search code here
if FindFirst(dirName,faAnyFile or faDirectory,searchResult)=0 then
begin
try
repeat
ShowMessage(IntToStr(searchResult.Attr));
if (searchResult.Attr and faDirectory)=0 then //The Result is a File
//begin
lbSearchResult.Items.Append(searchResult.Name)
else
begin
FileSearch(IncludeTrailingBackSlash(dirName)+searchResult.Name);
//
end;
until FindNext(searchResult)<>0
finally
FindClose(searchResult);
end;
end;
end;
procedure TFfileSearch.btnSearchClick(Sender: TObject);
var
filePath:string;
begin
lbSearchResult.Clear;
if Trim(edtMask.Text)='' then
MessageDlg('EMPTY INPUT', mtWarning, [mbOK], 0)
else
begin
filePath:=cbDirName.Text+ edtMask.Text;
ShowMessage(filePath);
FileSearch(filePath);
end;
Run Code Online (Sandbox Code Playgroud)
结束;
我在E:\驱动器中搜索*.ini文件.所以最初filePath是E:*.ini.但代码不会搜索E:\ drive中的目录.怎么纠正呢?
提前致谢
我正在尝试制作一个模拟时钟,其中我希望在Seconds更改时使我的'秒'线不可见.我试图将笔模式设置为,pmNotCopy但它只给出笔颜色的反转.必须在此设置什么属性才能Form1.Canvas.Pen.Mode:=<Blank>使My Line消失?
任何其他想法也不胜感激.
谢谢
我已经将这段代码放在一起用于创建动态表单
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TForm2 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
a:TForm2;
begin
a:=TForm2.Create(nil);
end;
Run Code Online (Sandbox Code Playgroud)
结束.
我收到错误,说找不到资源tform2.我必须做什么?
谢谢
我正在使用此代码来检查是否TStringList创建:
procedure TForm1.Button1Click(Sender: TObject);
var
sVariable : TStringList;
begin
if not Assigned(sVariable) then
sVariable:= TStringList.Create;
end;
Run Code Online (Sandbox Code Playgroud)
但条件False总是如此,为什么会发生这种情况?如何检查TStringList对象是否已创建?
Ps我知道有一个类似的问题问题,我试过在那个问题上发布的解决方案,但它对我不起作用.
我使用了一个函数在Delphi 7中创建我的桌面的截图.我得到了正确的截图,但是拍摄的照片大小约为3 MB.通常,屏幕截图的大小为150 KB左右.我不知道为什么.这是我的代码:
procedure TForm1.btnDesktopShotClick(Sender: TObject);
VAR
ScreenH, ScreenW : Integer;
dc : HDC;
hWin :Cardinal;
bm : TBitMap;
begin
//get handle of desktop
try
hWin :=GetDesktopWindow;
dc:=getDC(hWin);
ScreenH :=GetDeviceCaps(dc,VertRes);
ScreenW :=GetDeviceCaps(dc,HORZRES );
//set bitmap
bm:=TBitmap.Create;
bm.Width :=ScreenW ;
bm.Height :=ScreenH ;
//copy to dest bitmap
BitBlt(bm.Canvas.Handle,0,0,bm.Width ,bm.Height ,dc,0,0,SRCCOPY );
Image1.Picture.Bitmap.Assign(bm);
Image1.Picture.SaveToFile('screenShotDesktop.jpeg');
finally
ReleaseDC(hWin,DC);
end;
end;
Run Code Online (Sandbox Code Playgroud)
帮助将不胜感激.
谢谢
有人可以告诉我以下弹出窗口的名称是什么:

如何为我的应用程序创建这样的弹出窗口?
我怀疑FreeAndNil是否是处理对象的理想方法.我遇到过类似的代码
StringList1.Free;
StringList1 := Nil;
Run Code Online (Sandbox Code Playgroud)
用来.上述行是否过度,或者是更好的做事方式?这两种方法有什么区别?
如何禁用TDateTimePicker以允许选择超出系统日期和时间的日期?例如,如果我的系统日期是2012年11月6日,我将无法选择2012年11月6日以后的日期.
此外,我们能否只在特定范围内选择日期?
我使用以下代码在默认浏览器中显示NSE索引.
String downloadURL = "http://in.finance.yahoo.com/q;_ylt=AkieA" +
"_4_rXXRBh2SH7_U3kXyULlG;_ylu=X3oDMTE1Nmc5cjBnBHBvcwMyBHNlY" +
"wNmb290ZXIteWZpbmFuY2UEc2xrA25pZnR5NTA-?s=^NSEI";
java.awt.Desktop myNewBrowserDesktop = java.awt.Desktop.getDesktop();
java.net.URI myNewLocation = new java.net.URI(downloadURL);
myNewBrowserDesktop.browse(myNewLocation);
Run Code Online (Sandbox Code Playgroud)
提到的URL已从雅虎网站本身复制.但是,当我运行代码时,我收到如下错误:
java.net.URISyntaxException:索引140处的查询中的非法字符:http: //in.finance.yahoo.com/q;_ylt=AkieA_4_rXXRBh2SH7_U3kXyULlG;_ylu=X3oDMTE1Nmc5cjBnBHBvcwMyBHNlYwNmb290ZXIteWZpbmFuY2UEc2xrA25pZnR5NTA-?s= ^ NSEI
我不知道出了什么问题; 我已经成功地与其他网址做了同样的事情.请帮忙.
我想在stringList中添加30个不同的字符串.我不想加AList.Items.Add30次.我也不想将字符串保存在数组中并运行循环.我想可能是我可以写一个单独的AList.Add(不是循环),其中要添加的字符串由分隔符分隔.例如
AList.Add('Data1' + <Delim> + 'Data2' ...)
怎么做 ?请注意,我只是好奇是否可以这样做.如果不是因为有更好的方法来实现这一点,那就没关系了.(将字符串保存在数组中并使用循环添加数据是我的想法)
提前致谢