delphi-xe2

Indy and REST - Can I prevent exceptions?

♀尐吖头ヾ 提交于 2019-12-10 15:43:11
问题 Is there a way to prevent Indy from raising exceptions on any/all HTTP statuses? My understanding of the IgnoreReplies array is that it'll prevent those statuses from ever coming back, but that's not what I want. I want ALL statuses coming back, and none of them to raise an exception. There are plenty of REST services that return 404 for example, and that's considered a perfectly "valid" response. I really don't want 1/2 of my code in exception handlers, so is there way to get the current

Text File Writing performances in Delphi

ε祈祈猫儿з 提交于 2019-12-10 15:25:33
问题 My soft treat incoming strings (from Telnet or HTTP or...), and I have to write text file with Delphi XE2 for having a trace of incomming treated strings. As sometimes the string may crash the program I need to be sure to have the string in my file. So I open/close the file for every incoming string and I have some performance problems. Typically (for my code test) 8 seconds for My code is here, is there a way to improve the perfs keeping the function ? (For test just create a Form with a

How to solve “Need imported data reference” while building with runtime packages

送分小仙女□ 提交于 2019-12-10 15:06:40
问题 To help us modularize a monolithic application, we are in the process of setting up packages for use in debug builds, while still compiling to a single exe for release builds. One of our packages (EAUtils) contains a unit that is now producing [DCC Error] E2201 Need imported data reference ($G) to access 'SMsgDlgWarning' from unit 'SystemUtils' . This happens when building the EAUtils package itself. I am not into building packages that depend on EAUtils yet. EAUtils only depends on rtl/vcl

Is it possible to dynamically create form without having *.dfm and *.pas files?

穿精又带淫゛_ 提交于 2019-12-10 13:39:18
问题 is it possible to create and show TForm without having source files for it ? I want to create my forms at runtime and having the empty *.dfm and *.pas files seems to me useless. Thank you 回答1: Do you mean like this? procedure TForm1.Button1Click(Sender: TObject); var Form: TForm; Lbl: TLabel; Btn: TButton; begin Form := TForm.Create(nil); try Form.BorderStyle := bsDialog; Form.Caption := 'My Dynamic Form!'; Form.Position := poScreenCenter; Form.ClientWidth := 400; Form.ClientHeight := 200;

Constant object cannot be passed as var parameter

喜欢而已 提交于 2019-12-10 12:58:12
问题 This is the trouble code.. multresult := mult(mult(temp, quatview), conjugate(temp)); Full procedure procedure TForm2.RotateCamera(var angle: Single; x: Single; y: Single; z: Single); var temp, QuatView, multResult : TQuaternion; begin temp.x := x * sin(Angle/2); temp.y := y * sin(Angle/2); temp.z := z * sin(Angle/2); temp.w := cos(Angle/2); quatview.x := camera1.Position.x; quatview.y := camera1.Position.y; quatview.z := camera1.Position.z; quatview.w := 0; multresult := mult(mult(temp,

OmniThread: How to pass a TRect in SetParameter?

荒凉一梦 提交于 2019-12-10 11:54:03
问题 In a program using the OmniThread library, how can I pass a TRect in SetParameter? Example: procedure TestParameters(const ATask: IOmniTask); begin // how can I access the TRect here? end; FTestTask := CreateTask(TestParameters, 'TestParameters') .MonitorWith(OTLMonitor) .SetParameter('FormRect', Self.ClientRect) // does not work .Run; Is there a general rule how to use different types in SetParameter? 回答1: Use TOmniValue.FromRecord<T> and TOmniValue.ToRecord<T> . procedure TestParameters

Right to left ComboBox in Delphi XE2 with styles

萝らか妹 提交于 2019-12-10 11:04:23
问题 I have problems when I use ComboBox in Delphi XE2 with Custom styles(Emerald Light Slate) and this property: BiDiMode := bdRightToLeft; Style := csDropDownList; That ComboBox without Custom style: And with Custom styles(Emerald Light Slate): How i can fix it? 回答1: The issue it seems located in the DrawItem method of the TComboBoxStyleHook (the vcl style hook of the TComboBox), you can fix this overriding this method. Try this sample code (this solution is far from being perfect but is a start

Attaching an object to an already existing ListItem?

那年仲夏 提交于 2019-12-10 11:02:18
问题 In a ListView, how can I attach an object at any time to an already existing ListItem? (I know I can attach an object to a ListItem with AddItem , however I need to attach the object after the ListItem has been created). 回答1: You can access it through the TListItem.Data property. For example: var ListItem: TListItem; begin ListView1.AddItem('Item 1', nil); ... ListItem := ListView1.Items[0]; ListItem.Data := Edit1; TEdit(ListItem.Data).Text := 'Updated text...'; end; 回答2: You could solve this

TButton deficiencies

醉酒当歌 提交于 2019-12-10 10:37:19
问题 TButton in Delphi XE2 has a Style property. When this property is set to bsSplitButton then a drop-down arrow is displayed on the right side of the button: However, this drop-down area has some inconveniences: In many cases it is too narrow, the static width of the drop-down area is only 11 pixels. There is no explicit hover indication just for the drop-down area when the mouse pointer hovers over the drop-down area. How can a descendant of TButton be implemented which repairs this

How to sort a ClientDataSet on a calculated field?

独自空忆成欢 提交于 2019-12-10 09:56:28
问题 I'm trying to sort a ClientDataSet on a calculated boolean field, but for some reason the data is not sorted. I have a boolean field named Highlight with FieldKind set to fkInternalCalc , and an index defined like this: IndexDefs[0].DescFields = 'Highlight'; IndexDefs[0].Fields = 'Highlight;PatNo'; IndexDefs[0].Name = 'PatNo'; IndexDefs[0].Options = [ixDescending]; and obviously I have set my client dataset's IndexName to 'PatNo' . When I run my application, the data in the CDS is sorted on