delphi

Using Volume Shadow Copy Service (VSS) in Delphi

Does anyone have sample code to copy open (in-use and locked by another program) files using Volume Shadow Copy Service (VSS) API? There was an article about this in The Delphi Magazine (September 2005). But that code is no longer available and even if it was, it's not current. I am looking for sample code that works with current versi...

wintypes.dcu not found and code completion stops working

I'm getting the error: wintypes.dcu not found several times a day in the Delphi 2009 IDE, after this error code completion stops working, also I can't open any unit's source code with Ctrl + Click, then I have to reopen the IDE to fix it. Anyone has a clue about what can be causing this? The only IDE extension I have installed is GExpe...

How do I discover if my delphi application currently has a modal window?

I've got a timer running in my Delphi MDI application and I'd like to use it to pop up a message if something changes in the background. But I don't want that message to pop up when the the application has a modal dialog in the foreground because the user couldn't do anything about it. So what I'd like to know is how can I check for th...

Where to store program settings instead of HKEY_LOCAL_MACHINE?

I have some program settings that are currently stored in HKEY_LOCAL_MACHINE. Due to Vista and locked down users, some users don't have permission to HKEY_LOCAL_MACHINE, and those values don't really belong to HKEY_LOCAL_USER either (it has to be the same for all users), what's the best alternative location for storing these? Majority o...

Hooking a Stacktrace in Delphi 2009

The Exception class in Delphi 2009 received a number of new features. A number of them are related to getting a stacktrace: property StackTrace: string *read* GetStackTrace; property StackInfo: Pointer read FStackInfo; class var GetExceptionStackInfoProc: function (P: PExceptionRecord): Pointer; class var GetStackInfoStringProc: funct...

How do you use F1 help in Delphi 2007?

In my application, originally built with Delphi 7, I use the SPHelpIntegration code to enable CHM help via the F1 interface. I figured that this wasn't needed in Delphi 2007, so I removed the units and built my app. I then press F1 and get a message that no help interface is installed. The online help doesn't tell me a lot about what is ...

What is the fastest way to Parse a line in Delphi?

I have a huge file that I must parse line by line. Speed is of the essence. Example of a line: Token-1 Here-is-the-Next-Token Last-Token-on-Line ^ ^ Current Position Position after GetToken GetToken is called, returning "Here-is-the-Next-Token" and sets the Cur...

Sidebar form

How can I create a Sidebar form in delphi. I try the ScreenSnap and Align properties but I need that the form stay visible even if the user maximize other forms, without been on top. Just like the windows sidebar do. update from the comments: if a window is maximized it maximizes next too the window, not in front of or behind. Thanks ...

How to repaint a parent form while a modal form is active?

In Delphi 2006, I am showing a modal form. User input in that form can change data that might be displayed currently on the parent form which is the mainform. To reflect those changes I need to force a repaint of some ownerdrawn components on the mainform. I tried to do that like this from the modal form: MainForm := Application.MainFor...

Showing TFrame descendant's additional properties on the object inspector

Delphi object inspector doesn't show TFrame descendants's additional properties by design. People tend to suggest using a known trick which is commonly used for showing TForm descendant's properties on the Object inspector. The trick is: registering custom module for TForm descendants to Delphi IDE via design time package like: Register...

How do you format your Compound Statements in Delphi and C#?

As a long time Pascal and Delphi developer, I always line up my begin and ends thus : begin if x = y then begin ... ... end else for i := 0 to 20 do begin ... ... end; end; What drives me nuts is code formatted thus : begin if x = y then begin ... ... end else for i := 0 t...

Generics problem

Why EAccessViolation is raised? uses Generics.Collections; ... var list: TList<TNotifyEvent>; ... begin list := TList<TNotifyEvent>.Create(); try list.Add(myNotifyEvent); list.Remove(myNotifyEvent); // EAccessViolation at address... finally FreeAndNil(list); end; end; procedure myNotifyEvent(Sender: TObj...

Delphi and XPath functions

Can I use Xpath node set function position() in Delphi's function selectNodes() to select only a certain number of element from a node list? If I do like this: selectNodes('Item[1]') its all fine and I get the element with index 1, but when I try selectNodes('Item[position()<10]') I get exception 'unknown method', when I try se...

How can I get the X,Y position of a TWinControl (relative to the screen)

I'm trying to show a custom hint in a TWinControl but I can't figure out how to get it's position. Using position 0,0 shows the hint on the top of my screen (outside the window) so I guess it must be the position of the control on the screen. Edit: I've found the TControl Property ClientOrigin which returns what I've expected, is it c...

How to automatically set Version Info in Delphi?

I would like to have my CodeGear Delphi 2007 project to automatically set the debug module attributes depending on whether my project is in debug or release mode. I can manually set this value by right clicking on the project->Version Info->Edit values as needed. These are for the project as a whole and are the same for the debug and re...

How to force a Descendant class to either use directly the Ancestor method or have a new implementation not calling inherited?

We have the TAncestor class which has a virtual method GetFile. We will have some TDescendant = class(TAncestor) which may override GetFile. We want to insure that in such a case those overriden methods do not call inherited in their implementation. But if they don't implement GetFile and just use the one from TAncestor, it's fine. Is th...

delphi 2007 command line compiler dcc32.cfg problem

I'm using the command line compiler for builds. One problem I see is that the paths mentioned there seem to need to be the short versions of the filenames such that they don't contain any spaces. I don't know so much about this even though I have used it for some time. I recently upgraded to d2009 and the problem started then. Is the...

Profiler and Memory Analysis Tools for Delphi

I recently upgraded from Delphi 4 to Delphi 2009. With Delphi 4 I had been using GpProfile by Primoz Gabrijelcic as a profiler and Memory Sleuth by Turbo Power for memory analysis and leak debugging. Both worked well for me. But I now need new tools that will work with Delphi 2009. The leader in Profiling/Analysis tools for Delphi by a...

Do you test on high-res screens and with non-standard/high contrast colour schemes?

I use a non-default Windows colour scheme on most of my machines, and have a laptop with a 124 DPI screen, which Windows is set to. A lot of programs I tested or even use daily seem to have problems with that, showing for example non-standard sizes of controls, cut-off UI elements, unreadable text and so on. There is the whole range fr...

Techniques for writing critical text data

We take text/csv like data over long periods (~days) from costly experiments and so file corruption is to be avoided at all costs. Recently, a file was copied from the Explorer in XP whilst the experiment was in progress and the data was partially lost, presumably due to multiple access conflict. What are some good techniques to avoid...