67 Posted Topics
Re: [code=delphi] for i := 1 to a do begin name := Format('file_%d.txt',[i]); if FileExists(name) then begin assign (f,name); (include variable into file name) reset (f); read (something unimportant here); close (f); end; end; [/code] | |
Re: Menu: Project->Options->Forms. Drgag&Drop order. or Menu: Project->View source. | |
Re: for Delphi 2009 [code=delphi] uses Winsock; const WINSOCK_VERSION = $0101; function GetIPAddress(name: AnsiString): string; const WSVer = $101; var wsaData: TWSAData; P: PHostEnt; begin Result := ''; if WSAStartup(WSVer, wsaData) = 0 then begin begin P := GetHostByName(PAnsiChar(name)); if P <> nil then Result := iNet_ntoa(PInAddr(p^.h_addr_list^)^); end; WSACleanup; end; end; … | |
Re: [code=delphi] for i:=0 to MainForm.MDIChildCount-1 do MainForm.MDIChildren[i].Show; [/code] | |
Re: [code=delphi] var inFile, outFile: TStringList; Row, rowCount: integer; begin inFile := TStringList.Create; try Row := 0; inFile.LoadFromFile('inFilename.out'); while Row < inFile.Count do begin if Pos('state summary:',inFile.Strings[Row]) > 0 then begin inc(Row); outFile := TStringList.Create; try rowCount := 0; while (rowCount < 10) do begin outFile.Add(inFile.Strings[Row]); inc(Row); inc(rowCount); if Row = … | |
Re: Look in the direction of the INI-file - TInifile. | |
Re: Pascal procedure WriteComponentResFile(const FileName: string; Instance: TComponent); File Classes Description Use WriteComponentResFile to save the component specified by the Instance parameter to the specified file, storing it in a resource-file format. To read a component written with WriteComponentResFile, call ReadComponentResFile. | |
Re: Yes. Easy. Save: [code=delphi] procedure TForm1.SaveButtonClick(Sender: TObject); var i: integer; begin with TStringList.Create do try for i := 0 to self.ControlCount-1 do if (self.Controls[i] is TEdit) then Add(self.Controls[i].Name+'='+(self.Controls[i] as TEdit).Text); SaveToFile('Filename.txt'); finally Free; end; end; [/code] load: [code=delphi] procedure TForm1.LoadButtonClick(Sender: TObject); var i,idx: integer; begin with TStringList.Create do try LoadFromFile('Filename.txt'); … | |
Re: 1.Make cursor in cursor editor (hand.cur). 2.Make text file "cursors.rc": HAND CURSOR HAND.CUR 3.Compile: "C:\Program Files\CodeGear\RAD Studio\6.0\bin\brcc32.exe" cursor.rc 4.In program: [code=delphi] const crHand = 10; .... implementation {$R Cursor.res} ..... procedure TForm1.Create(Owner: TObject); begin Screen.Cursors[crHand] := LoadCursor(hInstance,'HAND'); end; ... uses: Screen.Cursor := crHand; [/code] | |
Re: Try it: [Code=delphi] function TProcessControl.GetProcessList(AList: TStrings): Boolean; var hSnapshoot: THandle; pe32: TProcessEntry32; begin Result := true; AList.Clear; hSnapshoot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hSnapshoot <> -1) then begin pe32.dwSize := SizeOf(TProcessEntry32); if (Process32First(hSnapshoot, pe32)) then repeat AList.AddObject(pe32.szExeFile,TObject(pe32.th32ProcessID)); until not Process32Next(hSnapshoot, pe32); CloseHandle (hSnapshoot); end else Result := False; end; [/code] Example: … | |
Re: Avoid cycles. Can simplify: [code=delphi] Memo1.Lines.Add(ListBox1.Items.Strings[ListBox1.ItemIndex]); [/code] | |
Re: Try StartTransaction and CommitTransaction | |
Re: Maybe this will help [url]http://www.alphaskins.com/[/url] | |
Re: [code=delphi] procedure TForm1.FormResize(Sender: TObject); begin Panel1.Width := (ClientWidth div 100) * 80; Panel1.Height := (ClientHeight div 100) * 80; Panel1.Left := (ClientWidth div 2) - (Panel1.Width div 2); Panel1.Top := (ClientHeight div 2) - (Panel1.Height div 2); Image1.Width := (Panel1.Width div 100) * 80; Image1.Height := (Panel1.Height div 100) * … | |
Re: for disable input other digit, for TEdit.OnKeyPress: [code=delphi] procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not (Key in ['1','2','3']) then Key := #0; end; [/code] or, for check range: [code=delphi] function ValueInRange(const Val: string; const Min,Max: integer): Boolean; begin Result := (Trim(Val) <> '') and ((Val >= IntToStr(Min)) and … | |
Re: Try this. Comments in Russian, translated laziness. It should be clear. [code=delphi] var myFile : TextFile; printDialog : TPrintDialog; begin // Создание диалога выбора принтера printDialog := TPrintDialog.Create(Form1); // Если пользователь выбрал принтер (или значение по умолчанию), то печатайте! if printDialog.Execute then begin // Попытка открыть файл принтера AssignPrn(myFile); // … |
The End.