BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Win32 error 1400 - invalid handle with TPanel

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Sonnich
Guest





PostPosted: Thu Jan 05, 2006 12:50 pm    Post subject: Win32 error 1400 - invalid handle with TPanel Reply with quote



Hi all!

I have a component based on TCustomChart, which a few components on it.
A TPanel causes this error.
The panel is default invisible, create as:

pnl1 := TPanel.Create(self);
pnl1.Parent := Self;
pnl1.BringToFront;
pnl1.BevelInner := bvNone;
pnl1.BevelOuter := bvNone;
pnl1.Color := Legend.Color;
pnl1.Visible := False;

This causes the error when the app is being closed.

Simply, by removing the "visible = false" and I avoid the problem.

Can anyone explain?
How do I create a panel, which is disabled?

/Sonnich

Back to top
alanglloyd@aol.com
Guest





PostPosted: Sat Jan 07, 2006 5:59 am    Post subject: Re: Win32 error 1400 - invalid handle with TPanel Reply with quote



Check that the panel has a window handle for your interest ...

if not Pnl1.HandleAllocated then
ShowMessage('Pnl1 does not have a Handle);

.... and ensure that it does have a handle by calling ...

Pnl1.HandleNeeded;

I don't know why the handle is not created (if that is the case) but
this may be the problem. Maybe if the window is not visible then no
handle is allocated.

Do you specifically Free the panel before closing the app. You should
because you have created it.

Alan Lloyd

Back to top
Maarten Wiltink
Guest





PostPosted: Sat Jan 07, 2006 1:45 pm    Post subject: Re: Win32 error 1400 - invalid handle with TPanel Reply with quote



<alanglloyd (AT) aol (DOT) com> wrote

[...]
Quote:
Do you specifically Free the panel before closing the app. You should
because you have created it.

This is a good rule in general, but TComponent (from which TPanel
derives) does have infrastructure in place to have another component
free it: the Owner property and parameter to Create.

Groetjes,
Maarten Wiltink



Back to top
Sonnich
Guest





PostPosted: Thu Jan 12, 2006 8:41 am    Post subject: Re: Win32 error 1400 - invalid handle with TPanel Reply with quote

Well, I found the problem.

I call a function from another thread, which enables the panel if
needed, something like:

procedure SetMyPanel(somevar: boolean);
mypanel.visible := somevar;

But when calling this from a thread, it fails. Seems like the "true"
set from there is related to thre thread.

So instead from the thread I do so:

otherclass.somevar := true;
sync...(somefunc)

procedure somefunc;
mypanel.visible := somevar;

then it works.

The point is, that the thread is a one-shot. It terminates rigth after
doing this.

S



Maarten Wiltink wrote:
Quote:
alanglloyd (AT) aol (DOT) com> wrote in message
news:1136613557.135981.261760 (AT) g47g2000cwa (DOT) googlegroups.com...
[...]
Do you specifically Free the panel before closing the app. You should
because you have created it.

This is a good rule in general, but TComponent (from which TPanel
derives) does have infrastructure in place to have another component
free it: the Owner property and parameter to Create.

Groetjes,
Maarten Wiltink


Back to top
Nicholas Sherlock
Guest





PostPosted: Thu Jan 12, 2006 7:13 pm    Post subject: Re: Win32 error 1400 - invalid handle with TPanel Reply with quote

Sonnich wrote:
Quote:
Well, I found the problem.

I call a function from another thread, which enables the panel if
needed, something like:

procedure SetMyPanel(somevar: boolean);
mypanel.visible := somevar;

But when calling this from a thread, it fails. Seems like the "true"
set from there is related to thre thread.

Danger, Will Robinson! Danger!

You cannot access the VCL from outside the main thread. It is not thread
safe. Use synchronize or a similar solution.

Cheers,
Nicholas Sherlock

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.