delphi

How can I print text fields at the right coordinates?

I don't have any background in programming and this is my first shot. I wrote a Delphi program that is supposed to print on a result sheet. I work in an institute and we have to establish hundreds of result sheets every 2 months. It's really difficult to do that and different handwriting is also an important issue. I have this code: if ...

TVirtualStringTree - resetting non-visual nodes and memory consumption

I have an app that loads records from a binary log file and displays them in a virtual TListView. There are potentially millions of records in a file, and the display can be filtered by the user, so I do not load all of the records in memory at one time, and the ListView item indexes are not a 1-to-1 relation with the file record offset...

THttprio onBeforeExecute changing the soapRequest

I've imported some wsdl for a project. i want to change the SoapRequest on HttpRio onBeforeExecute event, but as i changed the request, im getting some errors how can i change the request xml file with stringReplace function on this event. i've tried to change the size of stream, i ve changed the encoding etc. but anyway it didnt work. ...

Delphi: Alternative to using Reset/ReadLn for text file reading

i want to process a text file line by line. In the olden days i loaded the file into a StringList: slFile := TStringList.Create(); slFile.LoadFromFile(filename); for i := 0 to slFile.Count-1 do begin oneLine := slFile.Strings[i]; //process the line end; Problem with that is once the file gets to be a few hundred megabytes, i ha...

Delphi: how to efficently read a big binary file, converting it to hexadecimal for passing it as a varbinary(max) parameter?

I need to convert a binary file (a zip file) into hexadecimal representation, to then send it to sql-server as a varbinary(max) function parameter. A full example (using a very small file!) is: 1) my file contains the following bits 0000111100001111 2) I need a procedure to QUICKLY convert it to 0F0F 3) I will call a sql server funct...

Faster way of initializing arrays in Delphi

I'm trying to squeeze every bit of performance in my Delphi application and now I came to a procedure which works with dynamic arrays. The slowest line in it is SetLength(Result, Len); which is used to initialize the dynamic array. When I look at the code for the SetLength procedure I see that it is far from optimal. The call sequence...

How To Get the Name of the Current Procedure/Function in Delphi (As a String)

Is it possible to obtain the name of the current procedure/function as a string, within a procedure/function? I suppose there would be some "macro" that is expanded at compile-time. My scenario is this: I have a lot of procedures that are given a record and they all need to start by checking the validity of the record, and so they pass ...

Delphi Rad Studio - Can I stop components being recompiled each time I compile/build

It might have something to do with library and other paths, but every time I build/compile software in DRS which uses a bought component like TMS controls the TMS controls keep getting recompiled, too. How do I stop that? ...

[Delphi] TImage losing loaded picture

Running Turbo Delphi Pro. I'm using TImage to display a png image. When I restart Delphi and load the dpr file, TImage is still there, but the picture is lost, requiring a reload of the picture before compiling. At first I thought it's a path issue, so I loaded the picture from the same directory as the dpr, but it didn't help. What ...

Why won't my control accept keyboard input?

I've built a custom control that I'm trying to send input to. It will accept mouse input and report MouseDown, MouseMove and MouseUp correctly, but for whatever reason, it won't accept keyboard input. When I click on it, it doesn't receive focus, and any keys I press get interpreted by whatever control had the focus already. This is p...

Delphi 2009: How do I prevent network application from leaking critical section?

As part of Vista certification, Microsoft wants to make sure that an application exits without holding on to a lock (critical section): TEST CASE 31. Verify application does not break into a debugger with the specified AppVerifier checks (Req:3.2) As it turns out, network applications built using Delphi 2009 does break into the de...

Delphi TADOQuery SaveToFile problem

I have written an application that allows a user to create and run a query, then save the report to file. They can load the report from file at a later date and view on screen. I use a TADOQuery component to run the query, and call SaveToFile when the query has returned data. I then use LoadFromFile to load the data back into a TADOQuer...

Handling update errors in multiple records in the TClientDataset's ReconcileError method

I'm trying to use the ReconcileError event to allow the user to correct the data after an update error which occurred in a specific record among others. Example: I have a dataset with one field and 3 records, this field have a unique constraint on the database, then I change one value to conflict when it reaches the database, then I ca...

Delphi: How to respond to WM_SettingChange/WM_WinIniChange?

i need to know when my application recieves a WM_SETTINGCHANGE message (formerly known as WM_WININICHANGE). Problem is that the message pump in TApplication sends it down a black hole (default handler) before i can get a chance to see it: procedure TApplication.WndProc(var Message: TMessage); ... begin Message.Result := 0; for I...

Delphi Unit local variables - how to make each instance unique?

Ok, this, I'm sure is something simple that is easy to do. The problem : I've inherited scary spaghetti code and am slowly trying to better it when new features need adding - generally when a refactor makes adding the new feature neater. I've got a bunch of code I'm packing into a single unit which, in different places in the appli...

Delphi: Center Specific Line in TRichEdit by Scrolling

I have a Delphi 2007 TRichEdit with several lines in it. I want to scroll the richedit vertically such that a specific line number if approximately centered in the visible/display area of the richedit. For example, I want to write the code for CenterLineInRichEdit in this example: procedure CenterLineInRichEdit(Edit: TRichEdit; LineNu...

Is there any way to prevent a Delphi application from using Virtual Storage on Vista/Win 7 without enabling Runtime Themes?

The question pretty much says it all. I have an app with an older component that doesn't work right if runtime themes are enabled. But if I don't enable them, the app always ends up messing with the virtual store. Thanks! Update: Using Mark's solution below, the application no longer writes to the Virtual Store. But, now it won't ac...

Trapping errors in TClientDataSet.CommandText

I have a TClientDataSet connected to a TDataSetProvider, which in turn is connected to a TAdsQuery. I set the SQL command and then open the ClientDataset something like this: try CDS.CommandText := 'SELECT * FROM tablename WHERE fieldname = 1'; CDS.Open except // trap exception here - this never gets executed! end; If the SQL st...

delphi - how to get the progress of socket.SendStream ?

hi all ! I use dephi7's client/server socket components to send a file with tfilestream from client to server. I'am able to get the progress of file received at server side, but at client side, how do i get the progress of the file sent ? this is how I send the file: fstream:=tfilestream.Create(opendialog1.FileName,fmOpenRead); cl...

Can I use Delphi to write to BDE an PHP to read from it?

I strongly prefer not to use additional 3rd party components, libraries or DLLs (at least in v1.0), unless there is absolutely no other solution. Question: (how) can I use Delphi to progrtiamatically crate a BDE database and write to it, then use PHP to read from it? Any URLs for examples of tutorial? People are advising against it...