如果我执行它,我的应用程序将不会响应,直到找到所有文件和他们到列表框我的问题是如何我可以使这个功能多线程,以避免不相应的情况!我仍然是Delphi novoice
procedure TfrMain.FileSearch(const PathName, FileName : string; txtToSearch : string; const InDir : boolean);
var Rec : TSearchRec;
Path : string;
txt : string;
fh : TextFile;
i : integer;
begin
Path := IncludeTrailingBackslash(PathName);
if FindFirst(Path + FileName, faAnyFile - faDirectory, Rec) = 0 then
try
repeat
AssignFile(fh, Path + Rec.Name);
Reset(fh);
Readln(fh,txt);
if ContainsStr(txt, txtToSearch) then
ListBox1.Items.Add(Path + Rec.Name);
until FindNext(Rec) <> 0;
finally
FindClose(Rec);
end;
If not InDir then Exit;
if FindFirst(Path + '*.*', faDirectory, Rec) = …Run Code Online (Sandbox Code Playgroud) 我想检查当用户点击标签时
是否在ListBox中选择了一个项目,如果我执行就像我得到了这个错误list index out of bounds
procedure TfrMain.Label15Click(Sender: TObject);
var
saveDialog : TSaveDialog;
FileContents: TStringStream;
saveLine,Selected : String;
begin
saveDialog := TSaveDialog.Create(self);
saveDialog.Title := 'Save your text or word file';
saveDialog.InitialDir := GetCurrentDir;
saveDialog.Filter := 'text file|*.txt';
saveDialog.DefaultExt := 'txt';
saveDialog.FilterIndex := 1;
Selected := ListBox1.Items.Strings[ListBox1.ItemIndex];
if Selected <> '' then
begin
if saveDialog.Execute then
begin
FileContents := TStringStream.Create('', TEncoding.UTF8);
FileContents.LoadFromFile(ListBox1.Items.Strings[ListBox1.ItemIndex]);
FileContents.SaveToFile(saveDialog.Filename);
ShowMessage('File : '+saveDialog.FileName)
end
else ShowMessage('Save file was not succesful');
saveDialog.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud) 如何删除创建的标签,我google了很长时间但没有出现!,我尝试FindComponent但faild,我要做什么?我应该将父母设置为其他组件,如TPanel或什么?我感到很困惑!
procedure TForm1.Button1Click(Sender: TObject);
var
lblLink: TLabel;
begin
for i := 0 to stringtList.Count-1 do
begin
lblLink := TLabel.create(self);
with lblLink do
begin
name:='lblLink'+inttostr(i);
caption:inttostr(i);
Parent := self;
font.style := [fsUnderline];
cursor := crHandPoint;
color := clBlue;
font.Color := clBlue;
end;
end;
end;
Run Code Online (Sandbox Code Playgroud) 它吓坏了我,我无论如何都找不到把漂浮物扔给wchar_t,或者我看错了地方!
float cNumbers[9] = {1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0};
float x = 3.0;
float temp = 0.0;
wchar_t data[] = {0};
for(int i=0; i < sizeof(cNumbers); i++){
temp = x / cNumbers[i];
bool isInt = temp == static_cast<int>(temp);
if(isInt){
data = temp; //this is a big fail
addToList(hWnd,data);
}
}
void addToList(HWND hWnd,const wchar_t * data ){
SendMessage(GetDlgItem(hWnd,IDC_LISTBOX),LB_ADDSTRING,0,(LPARAM)data);
}
Run Code Online (Sandbox Code Playgroud)
问题是我想将浮点值转换为wchar_t以将其发送到列表框
我有一个问题,当我使用TRegEx对长文本和长文本来自网络!,我使用Indy获取网页源,然后我使用正则表达式找到链接!但正则表达式不能正常工作的问题!
我的正则表达式:
'/stream_map=(.[^&]*?)&/i'
Run Code Online (Sandbox Code Playgroud)
资源:
const HTTP_RESPONSE_OK = 200;
function GetPage(aURL: string): string;
var
Response: TStringStream;
HTTP: TIdHTTP;
begin
Result := '';
Response := TStringStream.Create('');
try
HTTP := TIdHTTP.Create(nil);
try
HTTP.Get(aURL, Response);
if HTTP.ResponseCode = HTTP_RESPONSE_OK then begin
Result := Response.DataString;
end else begin
// TODO -cLogging: add some logging
end;
finally
HTTP.Free;
end;
finally
Response.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
regex : TRegEx;
exper : string;
result : string;
fmatch : TMatchCollection;
begin
//Edit1.Text = http://www.youtube.com/watch?v=rzADrNmwYI0&feature=player_embedded
Memo1.Text := GetPage(Edit1.Text); …Run Code Online (Sandbox Code Playgroud) 我制作了一个使用 WIN32 将字符串发送到列表框的函数
char data[] = "abcd";
addToList(hWnd,data);
void addToList(HWND hWnd,char data[] ){
SendMessage(GetDlgItem(hWnd,IDC_LISTBOX),LB_ADDSTRING,0,(LPARAM)data);
}
Run Code Online (Sandbox Code Playgroud)
当我执行此操作时,它会将数据发送到列表框,但问题出现在奇怪的字符中,我也尝试过 wchar_t 但问题仍然存在