[lazarus] Duplicate condition in HandleNeeded

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Dec 3 12:42:09 EST 2002

On Tue, 03 Dec 2002 18:27:23 +0100
Martin Smat <martin.smat at tiscali.cz> wrote:

> Let me explain why I asked. I have added Else part with some testing 
> code. It looks like this:
> if not HandleAllocated then
> begin
> ...
> if not HandleAllocated then
> CreateHandle
> else begin // TESTING CODE HERE
> assignfile(f,'debug.txt'); // f is declared as textfile
> rewrite(f);
> writeln(f,'Handle is allocated');
> closefile(f);
> end;
> end;
> Then I compiled and ran Lazarus but the file debug.txt was never 
> created. So hence I think the second condition “If not HandleAllocated” 
> is useless (always true).

Most handles are created, because the form starts creating them. When a new
form has not yet created its handle and one of its components needs its
handle, the above case will happen.

> But if the handle can be really created in the 
> recursion then leave this line as it is (I'm not LCL wizard).
> Don't blame me I'm so punctilious, I know that the cleanups aren't 
> priority nowadays and I don't want raise a quarrel about one line of 
> code but I have another simple question.
> In constructor TcustomForm.CreateNew is following code:
> ...
> BeginFormUpdate;
> FBorderStyle:= bsSizeable;
> inherited Create(AOwner);
> ... // 15 lines here
> FBorderStyle := bsSizeable;
> ...
> Why is there “FborderStyle := bsSizeable” twotimes? 
> Has it any hidden mysterious sense which I can't see?

Lack of time. ;)
I deleted the second one.


More information about the Lazarus mailing list