delphi-7

How to remove focus from currently focused component?

╄→гoц情女王★ 提交于 2020-06-22 10:23:46
问题 I have a DB component which DataLink.UpdateRecord is called when it receives CM_EXIT message. This message is sent when it loses focus. When I click post button, it doesn't lose focus and value is not written to datasource. How can I reach an effect of component losing focus without switching it to other one? 回答1: You could use: procedure TCustomForm.DefocusControl(Control: TWinControl; Removing: Boolean); 回答2: We accomplish this by setting the Self.ActiveControl := nil. That causes all of

Create and run TTimer in runtime

半城伤御伤魂 提交于 2020-05-12 04:57:09
问题 I'm trying to achieve in Delphi a behavior similar to Javascript's setTimeout() procedure : run things after a delay of some seconds. To do so, I'm creating a TTimer at runtime, running it, and then free it. Here is my code: procedure createAndRunTimer(); procedure goTimer(Sender: TObject); begin (sender as ttimer).enabled := false; // do stuff here sender.free; end; var t : TTimer; begin t := TTimer.Create(frmprinc); t.Interval := 5000; t.OnTimer := goTimer(t); end; But my code won't compile

Create and run TTimer in runtime

倖福魔咒の 提交于 2020-05-12 04:56:46
问题 I'm trying to achieve in Delphi a behavior similar to Javascript's setTimeout() procedure : run things after a delay of some seconds. To do so, I'm creating a TTimer at runtime, running it, and then free it. Here is my code: procedure createAndRunTimer(); procedure goTimer(Sender: TObject); begin (sender as ttimer).enabled := false; // do stuff here sender.free; end; var t : TTimer; begin t := TTimer.Create(frmprinc); t.Interval := 5000; t.OnTimer := goTimer(t); end; But my code won't compile

Delphi Error Dataset not in Insert or Edit Mode

最后都变了- 提交于 2020-04-12 19:51:12
问题 Objective: Click on the button on the TRxDBCombo to call a search box On Selecting the record from search box, the result is set as Field Value for the TComboEditBox and is posted in the TRxMemoryData Dataset The Error: Dataset not in Insert or Edit Mode appears the second time of calling this function TDBEditBox1.SetFocus; Form_Search:= TForm_Search.Create(Application); with Form_Search do Begin showmodal; //Get Result from Database if trim(TempResult) <> '' then Begin TDBEditBox1.Field

FastString Alternatives to Delphi XE2

我的未来我决定 提交于 2020-04-07 03:54:33
问题 When I asked this question a while ago, the FastString unit came to solve my problem. Now I am starting to migrate my software from D7 to XE2. My question is, what alternatives do I have now since it appears that FastString will no longer solve the problem? ...or, more optimistically, does Delphi itself solves this performance issues? 回答1: A Lot of the FastCode routines have been included in recent Delphi, so you might not need 3rd party libraries anymore. Try with the stock RTL/VCL, then see

Delphi - Detect Int64 Overflow Error

你。 提交于 2020-02-24 09:10:46
问题 In Delphi how can I detect overflow errors for Int64 ? For Integers we could do: type MyInt = Integer; //Int64 function TryMaxTimes10(out Res: MyInt): boolean; var a, b: MyInt; begin {$Q+} try a := High(MyInt); b := 10; Res := a * b; //REF1 Result := True; except Result := False; end; {$Q-} end; For MyInt = Integer , line REF1 gives an exception and so TryMaxTimes10 returns false . But if we change MyInt to MyInt = Int64 , then REF1 does not give an exception and TryMaxTimes10 returns true !

Delphi - Detect Int64 Overflow Error

家住魔仙堡 提交于 2020-02-24 09:09:20
问题 In Delphi how can I detect overflow errors for Int64 ? For Integers we could do: type MyInt = Integer; //Int64 function TryMaxTimes10(out Res: MyInt): boolean; var a, b: MyInt; begin {$Q+} try a := High(MyInt); b := 10; Res := a * b; //REF1 Result := True; except Result := False; end; {$Q-} end; For MyInt = Integer , line REF1 gives an exception and so TryMaxTimes10 returns false . But if we change MyInt to MyInt = Int64 , then REF1 does not give an exception and TryMaxTimes10 returns true !