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 

Re: how to manage focus on an aggregate (composite) componen

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Aug 18, 2003 11:27 pm    Post subject: Re: how to manage focus on an aggregate (composite) componen Reply with quote




"Dennis Jones" <djones (AT) nospam (DOT) com> wrote


Quote:
I have an aggregate component which is made up of several
sub-components, the most critical of which are a string grid and
a scroll bar. When I click on the scroll bar, it recevies (and keeps)
the focus, so all keyboard input starts going to it.

Any particular reason why you are not simply using the TStringGrid's native
scrollbars?

Quote:
How can I keep the focus on the string grid, and yet still allow
mouse events to occur on the scroll bar?

Have you tried shifting the focus back to the TStringGrid after the mouse
button has been released?


Gambit


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.510 / Virus Database: 307 - Release Date: 8/14/03



Back to top
Dennis Jones
Guest





PostPosted: Tue Aug 19, 2003 12:44 am    Post subject: Re: how to manage focus on an aggregate (composite) componen Reply with quote




"Dennis Jones" <djones (AT) nospam (DOT) com> wrote

Quote:

"Remy Lebeau (TeamB)" <gambit47 (AT) yahoo (DOT) com> wrote in message
news:3f415f5b$1 (AT) newsgroups (DOT) borland.com...

"Dennis Jones" <djones (AT) nospam (DOT) com> wrote in message
news:3f414ef2$1 (AT) newsgroups (DOT) borland.com...

Have you tried shifting the focus back to the TStringGrid after the
mouse
button has been released?

No. I thought about it though. I figured doing that was a "hack" and
that
there must be a better, more standard (and elegant) way to handle this
situation. If that is what I have to do, however, then that is what I will
do.

Oops...TScrollBar doesn't make the OnMouseUp event visible. Any
suggestions?

- Dennis



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue Aug 19, 2003 2:18 am    Post subject: Re: how to manage focus on an aggregate (composite) componen Reply with quote




"Dennis Jones" <djones (AT) nospam (DOT) com> wrote


Quote:
Oops...TScrollBar doesn't make the OnMouseUp event visible. Any
suggestions?

Simply derive a new class from TScrollBar and promote the event to
public/__published manually:

class TMyScrollBar
{
__published:
__property OnMouseUp;
};

Then create an instance of your derived class instead of TScrollBar itself.


Gambit


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.510 / Virus Database: 307 - Release Date: 8/14/03



Back to top
Dennis Jones
Guest





PostPosted: Tue Aug 19, 2003 2:39 am    Post subject: Re: how to manage focus on an aggregate (composite) componen Reply with quote


"Remy Lebeau (TeamB)" <gambit47 (AT) yahoo (DOT) com> wrote

Quote:

"Dennis Jones" <djones (AT) nospam (DOT) com> wrote in message
news:3f417306$1 (AT) newsgroups (DOT) borland.com...

Simply derive a new class from TScrollBar and promote the event to
public/__published manually:

Yeah, I thought of that too. I guess I usually have the right idea, just
not always sure if it is the most sound approach.

Thanks Remy.

- Dennis



Back to top
Dennis Jones
Guest





PostPosted: Tue Aug 19, 2003 4:47 am    Post subject: Re: how to manage focus on an aggregate (composite) componen Reply with quote


"Remy Lebeau (TeamB)" <gambit47 (AT) yahoo (DOT) com> wrote

Quote:

"Dennis Jones" <djones (AT) nospam (DOT) com> wrote in message
news:3f417306$1 (AT) newsgroups (DOT) borland.com...

Simply derive a new class from TScrollBar and promote the event to
public/__published manually:

class TMyScrollBar
{
__published:
__property OnMouseUp;
};

Then create an instance of your derived class instead of TScrollBar
itself.


Well, it was a good idea, but it doesn't work. The OnMouseUp event gets
called for right and middle mouse button clicks, but not for left mouse
button clicks. I'm guessing that the WM_LBUTTONDOWN/WM_LBUTTONUP messages
are handled by the Windows scrollbar control and are therefore never heard
from again (a left-mouse-click black hole?).

However, I did find a solution that works. I use TScrollBar's OnChange
event to set the focus back to the grid. This was initially problematic
because I kept getting "control has no parent window" errors during my
component's construction (whether at design time or runtime). But if I
assign the OnChange event handler very late in the component's constructor
(after a call to Loaded()), that problem goes away. And the OnChange event
seems to give me what I needed to handle mouse events in the scrollbar and
still give the focus back to the grid when I'm done.

- Dennis



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) 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.