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 

Editing borderstyle disables edit control functionality?!

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
Andreas Krügersen
Guest





PostPosted: Fri Aug 08, 2003 2:32 pm    Post subject: Editing borderstyle disables edit control functionality?! Reply with quote



Hi,

I'm trying to write a simple modification of the standard edit control.
It should hide its border when it is not focused.
So I've written a new component and overridden the two event
handlers OnEnter and OnExit like this:

procedure TStealthyEdit.DoEnter;
begin
inherited DoEnter;

BorderStyle := bsSingle;
end;

procedure TStealthyEdit.DoExit;
begin
inherited DoExit;

BorderStyle := bsNone;
end;

Now I've discovered two problems when setting a focus on the control:

1) While it updates its border correctly, I can no longer edit its content
I cannot even select text inside the control.

2) When the modified edit control resides inside a panel, the text is not
shown
either.

The same problem occurs when I write an event handler for OnExit and
OnEnter for
a normal edit control.
But strangely it only happens when editing the BorderStyle inside the
handler. When changing the color for example, all works fine.

So what's happening here? I'm using Delphi 5.

regards

Andreas Krügersen
Projecteam
www.projecteam.de


--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

Back to top
Andreas Krügersen
Guest





PostPosted: Fri Aug 08, 2003 3:48 pm    Post subject: Re: Editing borderstyle disables edit control functionality? Reply with quote



Little Update:

It seems that I can still edit the control's contents
but the caret is not shown anymore. I can enter and select text
blindly and see the results but I don't see the caret or the
actual selection.

Strange however, when I switch to another task and back to
my app, the caret is there!

So what does OnEnter do with the Caret? I've even tried to use
MouseDown for showing the border. But since it works only for the mouse,
it is no real solution.



regards

Andreas Krügersen
Projecteam
www.projecteam.de

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

Back to top
Rob Kennedy
Guest





PostPosted: Fri Aug 08, 2003 6:59 pm    Post subject: Re: Editing borderstyle disables edit control functionality? Reply with quote



Andreas Krügersen wrote:
Quote:
Now I've discovered two problems when setting a focus on the control:

1) While it updates its border correctly, I can no longer edit its content
I cannot even select text inside the control.

2) When the modified edit control resides inside a panel, the text is
not shown either.

When you change the BorderStyle property, Delphi actually destroys the
existing window and re-creates it with the new window style. Delphi does
its best to transfer all the attributes from the old window to the new
one, but doing that while in the middle of a focus-changing sequence can
cause major problems for Windows.

You may be able to work around the problem. Instead of setting the
BorderStyle property, change the underlying window style directly using
the SetWindowLong API function. Set or clear the ws_Border flag accordingly.

--
Rob



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing 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.