Delphi

Only number in TEdit, Delphi

。_饼干妹妹 提交于 2020-05-29 07:17:27
问题 How can I add a TEdit that only accept numbers? I search information but nothing helps me. I need a TEdit that does not accept any letter or strings. procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not (Key in [#8, '0'..'9', DecimalSeparator]) then begin ShowMessage('Invalid key: ' + Key); Key := #0; end else if (Key = DecimalSeparator) and (Pos(Key, Edit1.Text) > 0) then begin ShowMessage('Invalid Key: twice ' + Key); Key := #0; end; end; 回答1: In modern Delphi

Only number in TEdit, Delphi

和自甴很熟 提交于 2020-05-29 07:16:27
问题 How can I add a TEdit that only accept numbers? I search information but nothing helps me. I need a TEdit that does not accept any letter or strings. procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not (Key in [#8, '0'..'9', DecimalSeparator]) then begin ShowMessage('Invalid key: ' + Key); Key := #0; end else if (Key = DecimalSeparator) and (Pos(Key, Edit1.Text) > 0) then begin ShowMessage('Invalid Key: twice ' + Key); Key := #0; end; end; 回答1: In modern Delphi

Setting an Enum property on a .NET object

岁酱吖の 提交于 2020-05-29 07:06:04
问题 Moving on from this question: Setting a "nullable" property on a .NET object Thanks to Olivier for his help so far. I am now using this import for the .NET type library: https://github.com/DelphiWorlds/MiscStuff/blob/master/Test/mscorlib_TLB.pas which is based on v4 of the CLR, as opposed to the antiquated version I was using. ..and I now have this code: procedure TDotNetObject.SetEnumProperty(const APropertyName: string; const AValue: OleVariant; const ATypeName: string; const AIndex:

Setting an Enum property on a .NET object

淺唱寂寞╮ 提交于 2020-05-29 07:02:05
问题 Moving on from this question: Setting a "nullable" property on a .NET object Thanks to Olivier for his help so far. I am now using this import for the .NET type library: https://github.com/DelphiWorlds/MiscStuff/blob/master/Test/mscorlib_TLB.pas which is based on v4 of the CLR, as opposed to the antiquated version I was using. ..and I now have this code: procedure TDotNetObject.SetEnumProperty(const APropertyName: string; const AValue: OleVariant; const ATypeName: string; const AIndex:

Setting an Enum property on a .NET object

对着背影说爱祢 提交于 2020-05-29 07:01:20
问题 Moving on from this question: Setting a "nullable" property on a .NET object Thanks to Olivier for his help so far. I am now using this import for the .NET type library: https://github.com/DelphiWorlds/MiscStuff/blob/master/Test/mscorlib_TLB.pas which is based on v4 of the CLR, as opposed to the antiquated version I was using. ..and I now have this code: procedure TDotNetObject.SetEnumProperty(const APropertyName: string; const AValue: OleVariant; const ATypeName: string; const AIndex:

Why doesn't TCusomWinSocket.ReceiveBuf ever return 0?

旧城冷巷雨未停 提交于 2020-05-29 04:18:45
问题 When it comes to sockets, TClientSocket and TServerSockets are my favourite because of their simple usage. My task is very simple. I need to send a file (RAW) through these 2 components, so I have 2 routines like the ones below: procedure csRead(Sender: TObject; Socket: TCustomWinSocket); var MSCli : TMemoryStream; cnt : Integer; buf : array [0..1023] of byte; begin MSCli := TMemoryStream.Create; try repeat cnt := Socket.ReceiveBuf(buf[0], 1024); //This loop repeats endlesly MSCli.Write(buf[0

Use “System.SysUtils” or “SysUtils” in Delphi?

风流意气都作罢 提交于 2020-05-29 02:59:47
问题 In Delphi XE3, it seems that one can use either "System.SysUtils" or "SysUtils", "Vcl.FileCtrl" or "FileCtrl". I read the article in http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/usingnamespaces_xml.html , it seems the former is called full qualified namespace, while the latter is the generic name. But if i understand correct, one should add statements like: "Uses System, Vcl", before one can use the units under these namespaces. But I check

Use “System.SysUtils” or “SysUtils” in Delphi?

孤人 提交于 2020-05-29 02:59:14
问题 In Delphi XE3, it seems that one can use either "System.SysUtils" or "SysUtils", "Vcl.FileCtrl" or "FileCtrl". I read the article in http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/usingnamespaces_xml.html , it seems the former is called full qualified namespace, while the latter is the generic name. But if i understand correct, one should add statements like: "Uses System, Vcl", before one can use the units under these namespaces. But I check

How I can get the peak memory on Mac OS?

断了今生、忘了曾经 提交于 2020-05-25 19:56:19
问题 In Windows I can get the Peak Memory usage by calling GetProcessMemoryInfo function TProcess.Peek: Cardinal; var PMC: PPROCESS_MEMORY_COUNTERS; PMCSize: Cardinal; begin PMCSize := SizeOf(PROCESS_MEMORY_COUNTERS); GetMem(PMC, PMCSize); try PMC^.cb := PMCSize; if GetProcessMemoryInfo(FHandle, PMC, PMCSize) then Exit(PMC^.PeakWorkingSetSize) else Exit(0); finally FreeMem(PMC); end; end; What is the Mac OS equivalent to do this? 回答1: You can use /usr/bin/time -l <cmd> like this: /usr/bin/time -l

TTreeView - Collapse and Expand Images not Alligned

六月ゝ 毕业季﹏ 提交于 2020-05-24 07:04:29
问题 Does anyone know how I can align the collapse/expand images with the center of my icon? Using a white theme they are correct, but in the dark theme, the arrows seem to be bottom-aligned: 回答1: If you're using VCL Style Utils components, then modify UxTheme_TreeView in Vcl.Styles.UxTheme.pas case iPartId of TVP_GLYPH: begin LColor := StyleServices.GetSystemColor(clWindowText); LRect := pRect; LRect.Top := LRect.Top + 1; // <---- here's the change //LRect.Top := LRect.Top + 5; LRect.Left :=