Menu
  • HOME
  • TAGS

Delphi 2010 - Overbyte ICS FTP upload with progress bar

delphi,delphi-2010

TFtpClient has an OnProgress/OnProgress64 event: OnProgress: Display the current file transfer progression. property OnProgress : procedure(Sender : TObject; Count : LongInt; var Abort : Boolean) of object; Unit FtpCli You need to create the TFtpClient object and assign an event handler to it, then you can perform your Put() command...

Delphi 2010 - Watchfolder - Check if a file is in use - Add item to listbox while the listbox is in loop

delphi,delphi-2010

A for loop's control value is evaluated only once, at the beginning of the loop. Adding entries to the list should not be causing a bounds error, as the Count will not be shrinking. The loop will stop when it reaches the old Count. However, removing an item would shrink...

How can I get List of objects with Generic type in Delphi

delphi,generics,delphi-2010

If you want a TDataList that holds one specific subclass of TSystemBaseEntity, define TDataList to be a generic class, with a type constraint This is defined as TDataList<T:TSystemBaseEntity> = class(TPersistent) private FValues: TObjectList<T>; protected function SetCaption: string; virtual; public procedure Execute; virtual; abstract; property Values: TObjectList<T> read FValues; end; And...

Reading large binary files

delphi,delphi-2010,c++builder,binaryfiles,binary-data

You may use multi-level decimation - just store every Nth, N^2th and so on samples (for example, 10th, 100, 1000, 10000...). When user changes window size, choose appropriate level, which contains about 1000 samples in this window, load and show these samples quickly (1000 points is just reasonable number for...

How to free object contained in another object [closed]

delphi,oop,delphi-2010

The correct way is to have A take ownership of B and let A's destructor free B. That way, your exception handler only as to worry about freeing A, and it will free B if it was created before the exception was raised. type ClassA = class public B: ClassB;...

Excel 2010 automation constants not working in Delphi XE7

excel,delphi,delphi-2010,ole,delphi-xe7

It's probably a data type issue. $FFFFEFD7 as a signed 32 bit integer is -4137 (and is what Excel expects). According to a quick goolge search Delphi Longint is signed 32 bit int, so maybe there is some type casting going on... According to OP's own research, setting System.Variants.DispatchUnsignedAsSigned :=...

Get File Version for Delphi XE2 and later

delphi,unicode,delphi-2010,delphi-xe7

Your code works perfectly well when compiled by all versions of Delphi. The only logical conclusion therefore, as to why the code reports a version of 1.0.0.0 is that the version is 1.0.0.0. In other words your problem will not be found by looking at this code. Your problem will...

How to get window main menu bar bounds?

delphi,screenshot,delphi-2010

You can get all the information you need if you have window handle. GetClientRect function will give you window client area, but top left coordinate will be (0,0). To translate that into offset you have to get screen coordinates of that point with ClientToScreen function and then just subtract window...

Programatically press ALT+TAB until the active caption matches a given string in Delphi

delphi,delphi-2010

Like this procedure Keybd_Press (const AKey : byte); begin Keybd_Event (AKey,0,0,0); end; procedure Keybd_Release (const AKey : byte); begin Keybd_Event (AKey,0,KEYEVENTF_KEYUP,0); end; Keybd_Press (VK_MENU); Keybd_Press (VK_TAB); Keybd_Release (VK_TAB); Keybd_Release (VK_MENU); ...

TPopupmenu Ownerdraw

delphi,delphi-2010,popupmenu,ownerdraw

There is TMenuItem.OnDrawItem each menu item gets it own (or shared) event.

Run function inside a thread and get result

delphi,delphi-2010

I managed to make this work and syncronize the gui with the result. In one listbox I keep the files that are in use and in another listbox i keep the files that can be procesed. The following thread solves the problem with the gui freezing and also it takes...

Function to increment filename

delphi,delphi-2010

Like so many programming problems, the key is to break the problem down into small pieces. First of all, let's write a function to decode the original file name into its constituent parts: procedure DecodeFileName(const Input: string; out Stem, Ext: string; out Number: Integer); var P: Integer; begin Ext :=...

How to realize Singleton pattern with Generics for TForm descendants?

delphi,generics,design-patterns,singleton,delphi-2010

The constructor constraint in Delphi is pretty much useless in my opinion. And it is of no real use to you since you need to create TForm descendants and they have a constructor that receives a parameter. You should constrain your generic type T to derive from TForm. type TgrsObj...

Amazon MWS API Call Using Delphi/Indy

delphi,delphi-2010,indy,indy10,amazon-mws

Found the problem: Indy (and Synapse too) adds the port number to the "Host" header line, and I had not realized that extra bit until I watched the headers more closely with Fiddler (thanks, @Graymatter!!!!). When I change the endpoint to be mws.amazonservices.com:443 (instead of just mws.amazonservices), then my signature...

Error: “Undeclared identifier” using a form from another Unit - Delphi 2010

delphi,delphi-2010

In uBancoHoras you have defined function fBH: TfBH; ... implementation ... function fBH: TfBH; begin Result := TfBH(MM.GetFormInstance(TfBH)); end; So you have defined a global function called fBH that returns an instance of the TfBH form class, seemingly through some sort of factory method (probably defined in MainModule?). There is...

How to solve error 'DesignIntf.dcu' not found in Project (Not Package)

delphi,delphi-7,delphi-2010

Ok, this solved the extraordinary problem: In .dpk files you can add 'DesignIDE' in the requires section. In .dpr files you can do things like that in the uses section-> DesignIntf in 'C:\Program Files (x86)\Embarcadero\RAD Studio\7.0\source\ToolsAPI\de\DesignIntf.pas', DesignerTypes in 'C:\Program Files (x86)\Embarcadero\RAD Studio\7.0\source\ToolsAPI\DesignerTypes.pas', DesignMenus in 'C:\Program Files (x86)\Embarcadero\RAD Studio\7.0\source\ToolsAPI\DesignMenus.pas'; [The path...

How to pass a method's nested procedure as a parameter?

delphi,delphi-2010

DoWithoutEvents() takes a TProc as input: type TProc = procedure; Only a standalone non-class procedure and an anonymous procedure can be assigned to a TProc. _WorkOnForm is neither of those, it is a local procedure instead. A local procedure has special compiler handling that ties it to its parent's stack...

Value of PixelsPerInch varying with windows themes?

delphi,winapi,delphi-2010,delphi-xe7

Your application has not declared itself to be high DPI aware. As such, it is subject to DPI virtualization. That explains why 150% scaling gives a DPI of 96 when themed. Why don't you get DPI of 96 when in the classic theme? Well, that's because DPI virtualization relies on...

Why do I have generic anonymous method incompatible type?

delphi,generics,delphi-2010,anonymous-methods

That is because type inference in Delphi is poor. It could in fact infere T from the first parameter but unfortunately the compiler is not satisfied then for the second parameter which would perfectly match. You have to explicitly state the type parameter like this: TgrsObj.Using<TStringStream>(TStringStream.Create, procedure(ss: TStringStream) begin ss.WriteString('test...