Delphi

TCPserver without OnExecute event

情到浓时终转凉″ 提交于 2019-12-30 07:00:09
问题 I want to make a TCPserver and send/receive message to clients as needed , not OnExecute event of the TCPserver. Send/receive message is not a problem; I do like that: procedure TFormMain.SendMessage(IP, Msg: string); var I: Integer; begin with TCPServer.Contexts.LockList do try for I := 0 to Count-1 do if TIdContext(Items[I]).Connection.Socket.Binding.PeerIP = IP then begin TIdContext(Items[I]).Connection.IOHandler.WriteBuffer(Msg[1], Length(Msg)); // and/or Read Break; end; finally

Persistent Objects in Windows XP/Delphi 7

我的未来我决定 提交于 2019-12-30 06:56:07
问题 I am trying to make an AlarmSystem in Delphi 7, Windows XP. I have to register alarms in a Database (MS SQL Server 2000). But what if the server is down??? Well, I can imagine that I have to persist objects of TAlarm type. So, how can I do this? Maybe inheriting from TComponent??? Please, how can I do this?? Thanks a lot. I am sorry about my English. Here you have more info... TAlarm is a class that descends from TObject, basically. There are 10 more classes that descend from TAlarm (some

How do I send a command to a single client instead of all of them?

£可爱£侵袭症+ 提交于 2019-12-30 06:49:57
问题 I am writing a simple client/server chat program with Indy 10. My server (idtcpserver) sends a command to the client, and the client answers, but when more than one client is connected and the server sends a command, all the clients connected send data to the server. How I can send a command to a specified client and not all? 回答1: The only way a command could be sent to all connected clients is if your code is looping through all of the clients sending the command to each one. So simply

Why do I get “403 Forbidden” when I connect to whatismyip.com?

让人想犯罪 __ 提交于 2019-12-30 06:47:07
问题 With the following code, I get exception class EIdHTTPProtocolException with message 'HTTP/1.1 403 Forbidden'. Process svchostip.exe (11172) function GetInternetIP:string; var IdHTTPMainUrl : TIdHTTP; begin try IdHTTPMainUrl := TIdHTTP.Create(nil); IdHTTPMainUrl.Request.Host := 'http://www.whatismyip.com/automation/n09230945.asp'; Result := idHTTPMainUrl.Get('http://automation.whatismyip.com/n09230945.asp'); except IdHTTPMainUrl.Free; end; end; 回答1: You need to set your user agent, this is

How to Detect Forward and Back Mouse Button Events in Delphi?

放肆的年华 提交于 2019-12-30 06:29:48
问题 If a mouse has other buttons in addition to the standard left/right/middle (e.g. forward/back), how can we detect those button clicks in Delphi? An example of how this is used is the Internet Explorer, where the forward/back button on the side of a Logitech or MS mouse cycles forward and back between any loaded web pages. This seems to replicate the Backspace/CTRL+Backspace on the keyboard but I tried to detect that using KeyPreview and the KeyPress event but it does not pick it up. Any idea

How to auto fit/scale DBGrid's (or other similar) columns widths according to its contents?

烂漫一生 提交于 2019-12-30 06:13:11
问题 I am trying to make a frame with a DBGrid that will serve for more than 10 tables with half of its fields as defaults, and other fields exclusive for each table. As the space for the columns are limited and I do not want to configure each column of each table manually because it is very poor quality work, I was wondering a way to calculate the width of each column by the largest content of a row inside that column, measured by the own component or by the data set. Does anyone knows the way?

How do I force the linker to include a function I need during debugging?

故事扮演 提交于 2019-12-30 06:08:45
问题 I often make small methods to assist debugging, which aren't used in the actual program. Typically most of my classes has an AsString-method which I add to the watches. I know Delphi 2010 has visualizers, but I'm still on 2007. Consider this example: program Project1; {$APPTYPE CONSOLE} uses SysUtils; type TMyClass = class F : integer; function AsString : string; end; function TMyClass.AsString: string; begin Result := 'Test: '+IntToStr(F); end; function SomeTest(aMC : TMyClass) : boolean;

Floating point support in 64-bit compiler

不羁的心 提交于 2019-12-30 06:07:54
问题 What should we expect from the floating point support in 64-bit Delphi compiler? Will 64-bit compiler use SSE to implement floating point arithmetic? Will 64-bit compiler support the current 80-bit floating type (Extended)? These questions are closely related, so I ask them as a single question. 回答1: For the double=extended bit: Read ALlen Bauer's Twitter account Kylix_rd: http://twitter.com/kylix_rd In hindsight logical, because while SSE2 regs are 128 bit, they are used as two 64-bit

How do I force the linker to include a function I need during debugging?

不想你离开。 提交于 2019-12-30 06:07:27
问题 I often make small methods to assist debugging, which aren't used in the actual program. Typically most of my classes has an AsString-method which I add to the watches. I know Delphi 2010 has visualizers, but I'm still on 2007. Consider this example: program Project1; {$APPTYPE CONSOLE} uses SysUtils; type TMyClass = class F : integer; function AsString : string; end; function TMyClass.AsString: string; begin Result := 'Test: '+IntToStr(F); end; function SomeTest(aMC : TMyClass) : boolean;

Is it possible to use two record helpers for the string type?

那年仲夏 提交于 2019-12-30 06:03:48
问题 I created this helper in order to add some more functions to the string type: type AStringHelper = record helper for string function Invert: string; overload; function InvertMe: string; overload; end; But when I use it in my code, the TStringHelper in System.StrUtils "gets out" and I can't use it's functions. Is it possible to both of them to coexist? 回答1: At most one helper can active at any one point in your code. The documentation says this: You can define and associate multiple helpers