delphi

Any way to authenticate with a websense server from delphi?

We use a websense internet filter at my workplace. I have an application that tries to retrieve information from the internet. On my client machine, I have to authenticate with websense manually (i.e., open firefox and give my username / password) or I'll get an error in my application when it tries to do the download. The error messa...

Delphi Printer.Printers not refreshing

I have created a Delphi service which is responsible for printing QuckReports to specific printers contained within the printer.Printers list. I pass my routine the printer name and it looks up in the printer.printers array to get the proper index. It then does this: QuickRep1.PrinterSettings.PrinterIndex := iIndex; In the help file...

How to add buttons created at runtime into an array?

Hello, I'm sorry if the question looks stupid,but It seems I can't use my head properly in the last hours. I have a record, type TMain = record Sub:Array of TSubMain; //another record Button:TsSpeedButton; //this is what we need! end; a variable Main:Array of TMain; and function: procedure TFrameSkilLView.CreateButt...

Fade in an alpha-blended PNG form in Delphi

I asked a question about this some years back when Vista was first released, but never resolved the problem and shelved it as something to consider later. I have a splash screen that I went to great effort to make look great. It's a 32bpp alpha-blended PNG. I have some code (which I can dig up if required!) that works great under Windo...

How to create a form in dll?

Hello all friends..... How to create a form in dll. ...

Why does TEnumerable<T> use pass-through methods?

TEnumerable<T>, the base class for all the Generics.Collections container classes, has a very strange declaration. It looks like this: type TEnumerable<T> = class abstract protected function DoGetEnumerator: TEnumerator<T>; virtual; abstract; public function GetEnumerator: TEnumerator<T>; end; function TEnumerable<T>.G...

Modify an Excel Shape from Delphi

How can I modify the text of an existing excel shape from Delphi? I can create a new shape and set its text procedure TForm1.Button1Click(Sender: TObject); var excel, xlShape : variant; begin olecontainer1.CreateObject('Excel.Application',false); excel := olecontainer1.OleObject; excel.workbooks.open('C:\test.xls'); XlShape := ex...

Advice for Delphi Development on a Mac?

I've started developing with Delphi on the Mac and thought I would share my observations and see if anyone else had any advice or tips for Mac development with Delphi. A while back I had some comment discussion about Delphi development on a Mac. It was in the comments of an answer to another question. With the passing of some months, ...

Object orientation and serialization

Consider an interface like IMyInterface = interface procedure DoSomethingRelevant; procedure Load (Stream : TStream); procedure Save (Stream : TStream); end; and several classes that implement the interface: TImplementingClass1 = class (TInterfacedObject, IMyInterface) ... end; TImplementingClass2 = class (TInterfacedObject, ...

Get an instance of a persistent object, given the identifier in string.

In Delphi 7, how to get an instance of a persistent object, given the object identifier in string? function TForm1.GetObject(Identifier: string): TPersistent; begin //what to do here? end; Example of use: //If I have these declared... public MyString: string; MyStringList: TStringList; //the function will be used something lik...

Invalid types: 'Array' and 'dynamic array'

I wrote a function that gives me the length of a dynamic array by converting it to string and asking length(trim(string)); function arraylength(a: array of char): integer; var i: integer; s: string; begin for i:=0 to high(a) do begin s[i] := a[i-1]; Result := length(trim(s)); end; end; In my main program i read text into...

Setting correct printer in MS Word through automation

I have the following automation code: lPrintSetup := fWordObject.Application.Dialogs.Item(wdDialogFilePrintSetup); lPrintSetup.Printer := 'MyPrinter'; lPrintSetup.DoNotSetAsSysDefault := True; lPrintSetup.Execute; lPrintSetup := Null; The Printer property is giving me some problems, sometimes Execute crashes with an EOleException (0x8...

Sending pound signs from Delphi to C# web service

I am sending a large string from Delphi 5 to a C# web service, and I'm having lots of trouble with Pound (£) signs. I URLEncode the string from the Delphi side (which seems to convert them to '%A3'). When it reaches the C# web services it appears as '�'. I have tried changing the encoding of the string on the C# side by using a StreamRea...

pushing screen saver as wallpaper

var ScreenSaver:String; var handle:HWND; begin Handle := FindWindow('Progman', 'Program Manager'); Handle := FindWindowEx(Handle, 0, 'SHELLDLL_DefView', 0); Handle := FindWindowEx(Handle, 0,'SysListView32', 'FolderView'); ScreenSaver := 'C:\windows\system32\Mystify.scr /P' + InttoStr( Handle ); WinExec(pAnsichar(screensaver), SW_SHOWNor...

Delphi: Since when are interface references no longer released at the end of a with-block?

I recently stumbled over a problem caused by some very old code I wrote which was obviously assuming that interface references used in a with statement would be released as soon as the with-block is left - kind of like an implicit try-finally-block (similar to C#'s using-statement if I understood correctly). Apparently (in Delphi 2009) ...

Base class's class procedure should instantiate a descendant's object?

Why in the code below, do I get the "Failed" message rather than "Succeeded" Background: I like to have class procedures that instantiate their owner object, do something, and then free it. However, this approach doesn't work if I have a descendant object: Any suggestions on how to provide class procedures in a base class that can be...

How to send a MAPI email with an attachment to a fax recipient?

I am using this method to send a MAPI email with a PDF attachment from inside a Delphi application. It brings up an MS Outlook "new message" window with the pdf document already attached, and a blank recipient. If you type in a normal email contact, then it goes through fine. However, if you select a fax recipient, it appears in my "S...

How to get the name of an interface at runtime?

If I have an object that implements an interface, it's not too difficult to use RTTI to look up the interface and obtain its GUID. But if I want its name, is there any way to get that? It's simple enough to get a class's name, but for interfaces it seems a bit trickier... ...

How do I let Delphi know I've already handled an exception?

I've set Application.OnException to a custom exception handler so that I can log crashes and give an option to exit. However, I'm now finding that this runs even on exceptions that I've already handled, for instance, exceptions that come up when validating number inputs. Is there a way to have the custom exception handler only run on unh...

How to calculate the number of rows for a report and hide a header.

I'm creating my first report with Rave Reports for delphi. I've got the records displaying nicely and I'm on the final stretch before finishing. I have a set of records which I'm displaying with an if statement on the before print event ONLY if the 'comment' field on the record has data (which is string data). This The problem I have i...