delphi

Cast from TObject to interface type

Hi, related to my last question, I now have the following problem: function TNodeFactory <T>.CreateNode (ID : Integer) : INodeInterface <T>; var NodeClass : TClass; begin NodeClass := FindRegisteredClass (ID); Result := NodeClass.Create; end; This yields a compiler error: E2010 Incompatible Types: 'INodeInterface<TNodeFa...

"As" operator for constrained generic types

Consider: TTest <T : class, constructor> = class public function CreateMyObject : T; end; function TTest<T>.CreateMyObject : T; var Obj : TObject; begin Obj := T.Create; Result := (Obj as T); end; Why isn't this possible? Compiler yields an "Operator not applicable to this type" error message for the as operator. T is constr...

How to analyze dump file from delphi dll ?

Hi all, I'm an escalation engineer on a product which use both c# and delphi 2006 code. In most cases c# issues are debugged with windbg and delphi 2006 issues with eurekalog. But when the issue is a delphi memory usage, eurekalog don't give enough information to fix the issue and the only thing i have to debug it is a full memory dum...

Delphi and Microsoft ATL security issue

My impression is that standard Delphi uses the Win32 API. Recently Microsoft has been communicating a problem regarding ATL that requires application developers to rebuild ATL-using applications after installing an update on their machines. Will this practice be the general case also for Delphi developers, or are they in the clear wit...

Create an exact copy of TPanel on Delphi5

I have a TPanel pnlMain, where several dynamic TPanels are created (and pnlMain is their Parent) according to user actions, data validations, etc. Every panel contains one colored grid full of strings. Apart from panels, there are some open source arrows components and a picture. Whole bunch of stuff. Now I want user to be able to print...

How does one create Microsoft Management console(MMC) snap-in in Delphi 2009 ?

Are there an wizard or templates in delphi 2009 to write a MMC console ? EDIT: Colin Wilson components look great thanks. ...

TAnimate in Windows XP/Vista with themes enabled won't work

A coworker has been using a custom AVI to indicate progress during some longer operations for years. It's always worked fine. Recently he decided to move from Delphi 7 to Delphi 2007, in part to get theme support for his applications. (We've finally got most people, but not all, running on XP.) The animation stopped working. Disabling t...

Why do conditional breakpoints slow my program down so much?

When I'm debugging something that goes wrong inside a loop, say on the 600th iteration, it can be a pain to have to break for every one. So I tried setting a conditional breakpoint, to only break if I = 600. That works, but now it takes almost a full minute to reach that point, where before it was almost instantaneous. What's going on...

Recommended reporting tool for smaller applications?

Hello, There are quite a few VCLs for Delphi to build reports, so I'd like some feedback on which one to check. It's just to build a few pages, ie. a microIVS application, so I don't need enterprise-level solutions. I don't expect any open-source tools, but if there's a good one out there... I know about the following: Rave Reports,...

Hosting WSH (VBScript, JavaScript) in your delphi application?

I'm looking to execute user supplied scripts from my Delphi application. Is it possible to host the Windows Script Host engine in my application and supply it with scripts to execute? Or, is there a better way to approach this problem? P.S I'm not looking for third-party components. ...

Class Types and Constructor Calls

If I write type MyClass = class of TMyClass; ... Obj := MyClass.Create; the correct constructor (the one in TMyClass) is called. If I write var ClassVar : TClass; ... ClassVar := TMyClass; Obj := ClassVar.Create; only the TObject constructor is called. Why? What's the difference between the two versions? Can I force the TMyCl...

Will a Delphi form always fire OnResize when it's shown?

If I create a new Delphi form, hook its OnResize event, and run the app, OnResize is fired before the window is shown. What I don't know is whether this will always happen, for any window. (For anyone familiar with the Windows API, I've traced it to the ShowWindow call in TCustomForm.ShowingChanged (Forms.pas line 5503 in Delphi 2007), ...

How can I access the palette of a TPicture.Graphic?

I have searched the web for hours but I can not find anything about how to get the palette from a TPicture.Graphic. I also need to get the color values so I can pass these values to a TStringList for filling cells in a colorpicker. Here is the code that I currently have: procedure TFormMain.OpenImage1Click( Sender: TObject ); var i: ...

Under what conditions will a TForm fire OnResize on show?

As an extension of this question: TForm.OnResize is sometimes fired before a form is first shown, but not always. For example, if BorderStyle is either bsDialog or bsNone, then OnResize will not fire. For all other BorderStyle values (and with all other properties at their defaults), OnResize does fire. Are there other things that affe...

How do I declare a TField as nullable?

I'm setting up an ADO-based client dataset, and when I try to insert a null value into a TIntegerField, on Post I get Project raised exception class EDatabaseError with message 'Non-nullable column cannot be updated to Null'. I know I've seen a way to set a TField as nullable before, but I can't remember where or how. Does anyone know ...

Is Delphi's TADOConnection thread-safe?

I'm writing a Delphi 7 application which needs to access the same SQL Server database from many different threads simultaneously. Can I use a single shared TADOConnection, or must each thread create their own? ...

Delphi: How to get the value of an output parameter of a stored procedure?

I want to programatically create a SQLDataSet in Delphi and use it to execute a Stored Procedure and get the value of an output parameter. Looks easy but I can't make it work. Here is a dumb stored procedure in SQL Server: CREATE PROCEDURE [dbo].getValue @x INT OUTPUT AS BEGIN SET @x = 10; END Now here is one of the variations tha...

Recommended barcode type?

Hello, This is a question for people with a good experience with barcodes. The FastReport report generator supports the following barcode standards: Code 2_5 39, 39 Extended 93, 93 Extended Codabar 128A, 128B, 128C EAN128A, 128B, 128C EAN 13 EAN 8 MSI PostNet UPC A, E0, E1, Supp2 Since the solution is meant for small shops, I need ...

TClientDataSet - SaveToStream throws Access violation

I have a problem with saving data to stream with a ClientDataSet. I put data in the ClientDataSet and try to: ... var strmBENU: TMemoryStream; implementation ... TForm1.Button1Click(Sender: TObject); begin ClientDataSet1.SaveToStream(strmBENU); end; ... Clicking Button1, here is what I get: Access violation at adress 0049C...

AccessViolation when using C++ DLL from Delphi

I have a weird problem trying to use a DLL written in C++ from a Delphi (Turbo Delphi 2006) program. When I run the Delphi program (see below) from the command line, everything works fine. Also, when I run it from the Delphi environment without debugging (CTRL+SHIFT+F9), everything is fine. However, when running it with debugging (F9), ...