delphi

Where should I put code to execute once after my Delphi app has finished initialising?

I have functions I want to perform after my app has finished initialising and the main form has been created. I did have the code (call it ProcedureX) in the forms OnShow event, but I have just noticed that it is being called twice, because OnShow is firing twice. It fires when the main program DPR calls: Application.CreateForm(TMainF...

Is there any way to validate a filename?

I figured this has to be in the RTL somewhere, but I looked and I can't find it. function IsValidFilename(filename: string): boolean; //returns True if it would be possible to create or open a file with //this name, without modifying the current directory structure In other words, it has to point to an existing folder on a valid local...

Need help locking my code for SQL Server

We want to build into our software the capability to build SQL queries freehand (currently cannot do so with our software), but need to be able to lock it down so that users cannot make any changes, only select data from certain tables. Are there any good guides for helping me to lock this down appropriately (ie, least permissions neede...

Delphi Using LockFile on windows 7 64.

Hi All. I have found that if you open a file that resides on 32 bit server in a share folder from a 64 bit windows 7 machine, read it, lock it and then open it again. When you close all open handles the file actually remains open. The exact steps are: Place a file that is between 7000 and 10000 bytes long in a shared folder on a 32 ...

Delphi Using Indy 10

I'm using Delphi 4, and I want to create a standard non blocking socket with out the clutter of Indy code (Pv4 and Pv6). and i want to get the computers IP address and be able to ping has any one done this. Can I do it with Indy 10 or Indy 9. And has any one made code up to do any of these things and tested it please. ...

How to get a pointer to a method in a base class from a child class in delphi (object pascal)?

Hi! There is example: type TMyBaseClass = class public procedure SomeProc; virtual; end; TMyChildClass = class(TMyBaseClass) public procedure SomeProc; override; end; var SomeDelegate: procedure of object; procedure TMyBaseClass.SomeProc; begin ShowMessage('Base proc'); end; procedure TMyChildClass.SomeProc; ...

Delphi - How I tell the system what printer to use ?

To print the contents of a TRichEdit I use RichEdit.Print('My Document Name'); Some times I need to print it on "printer1" other times I need to print it on "printer2" Question: How I tell the system what printer to use ? ...

Converting a string to TDateTime based on an arbitrary format

Hi, Is there any way in Delphi 5 to convert a string to a TDateTime where you can specify the actual format to use? I'm working on a jobprocessor, which accepts tasks from various workstations. The tasks have a range of parameters, some of which are dates, but (unfortunately, and out of my control) they're passed as strings. Since the...

In DevExpress' Quantum Grids, how do I restrict the click area of a cell with checkbox to the actual checkbox, not the entire cell

I use Delphi (2010) and a DevExpress Quantum Grid (v. 6.52) When I have a TcxGridColumn with a CheckBox editor, the checkbox toggles when the user clicks anywhere within the cell. I want to restrict this so that the user has to click on the actual checkbox. Is there an easy way to do this? We have an enormous amount of grids in our ap...

How to detect TMenuItem right click?

platform:delphi 2010 drop Tmainmenu on form1 drop Tpopupmenu on form1 add mainmenu1 and popupmenu items (mainmenu --> file -->item1 , popupmenu-->popup item1) item1.onRgihtClick show popupmenu f9 file-->item1 right click, popupmenu , select item1 bla bla bla.... object Form1: TForm1 Left = 0 Top = 0 Caption = 'Form1' Cl...

Correct thread destroy

Hello At my form I create TFrame at runtime. At this frame I create background thread with executes commands in endless loop. But when I destroy this frame I should destroy this thread. I try thread.Suspend; thread.Terminate; FreeAndNil(thread); but get AV and ThreadError. How should i destroy thread? ...

[DELPHI] Parent class inside another class

Okay, so I have this class, let's say CMain, that contains a CFruit class. What I would like to do is run functions based on CFruit's type (if it's CPear or CApple, etc). So I'd like to do something like this: type CMain = class myFruit : CFruit; function GetFruit() : CFruit; procedure SetFruit( Fruit : CFruit ); end; proced...

How can I disable screen update which updating a lot of controls?

I have a form with 50 or more controls which I create and add at runtime. I don't want to see then appear one by one; I would rather disable drawing/start buffering at the start & then see them all appear at once. I seem to recall doing something like this in BCB about 10 years ago, but forget how. ...

What Web Application Framework for Delphi is recommended?

There has been some activity in the Web Application Framework area for Delphi (Win32). There are many new projects around, and I would love to see a overview description of their features (code and documentation quality, unit test coverage, ease of installation, minimum Delphi version, security, session management, database access, URL m...

[DELPHI] Array of procedures inside a class pointing to class method

Hello. I have a class (TExample) and I want to have an array of pointers that point to TExample methods. For example, I'd like to have TExample.ThinkOne and do aPointers[1] := @TExample.ThinkOne or something similar. How can I properly do this? Thanks. ...

Why Does SetString Take Less Memory in Delphi (with Unicode)?

This is Delphi 2009, so Unicode applies. I had some code that was loading strings from a buffer into a StringList as follows: var Buffer: TBytes; RecStart, RecEnd: PChar; S: string; FileStream.Read(Buffer[0], Size); repeat ... find next record RecStart and RecEnd that point into the buffer; ...

How to read and write dbf in a native way?

In Delphi for Win32, how to read and write a dbf file in a native way, without the BDE? I know there are some components available in the web, but I have never used any of them, so I don't know wich to choose (if any). ...

Delphi: At runtime find classes that descend from a given base class?

Is there at way, at runtime, to find all classes that descend from a particular base class? For example, pretend there is a class: TLocalization = class(TObject) ... public function GetLanguageName: string; end; or pretend there is a class: TTestCase = class(TObject) ... public procedure Run; virtual; end; or pretend there i...

How to add item to windows explorer content menu in delphi ?

I would like to create menu item in windows explorer content menu (for all file types) which after click will open my application and pass the selected file name to it. Is there any tutorial for this ? I know there is ShellPlus component available but it's a bit outdated. ...

Bitmap with transparency

Hi With code procedure TForm2.Button1Click(Sender: TObject); var oMeta: TMetaFile; oBmp: TBitmap; begin Image1.Transparent := True; Image1.Picture.LoadFromFile('D:\data\WMF.wmf'); oBmp := TBitmap.Create; try oMeta := TMetaFile(Image1.Picture.Graphic); oBmp.SetSize(oMeta.Width, oMeta.Height); oBmp.Canvas.Draw(0...