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 

Switch focus between TpaintBox and TStringGrid

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Students)
View previous topic :: View next topic  
Author Message
didan
Guest





PostPosted: Thu Apr 12, 2007 9:15 pm    Post subject: Switch focus between TpaintBox and TStringGrid Reply with quote



Hi
I have a TPaintBox and TStringGrid in a same form. I put
DefocusControl( StringGrid1, true) in TPaintBox1 MouseDown
event. The data in stringGrid will be deleted after I clicked paintbox if I clicked Delete key except the situation when one of
the StringGrid's cell was masked.
Can you help me? Thanks in advance.
Back to top
Hans Galema
Guest





PostPosted: Thu Apr 12, 2007 9:15 pm    Post subject: Re: Switch focus between TpaintBox and TStringGrid Reply with quote



didan wrote:
Quote:
Hi
I have a TPaintBox and TStringGrid in a same form. I put
DefocusControl( StringGrid1, true) in TPaintBox1 MouseDown

Why are you doing that?

Quote:
event. The data in stringGrid will be deleted after I clicked paintbox if I clicked Delete key except the situation when one of
the StringGrid's cell was masked.

And what is the question?

It is unclear to me if the things that you describe already happen
or that you want them to happen.

How does one click a Delete key by the way?

Hans.
Back to top
Hans Galema
Guest





PostPosted: Thu Apr 12, 2007 11:30 pm    Post subject: Re: Switch focus between TpaintBox and TStringGrid Reply with quote



didan wrote:

Quote:
PaintBox is used for user to draw graphics.

I know.

Quote:
Therefor,both
PaintBox and StringGrid receive user's inputs.

For a TStringGrid ok. But for a TPaintBox I wonder what you mean.

Quote:
If user edits
StringGrid first then switch to draw graphics, such as to
delete a line, the PaintBox will receive this delete stroking.

A TPaintBox has no OnKeyDown or OnKeyPress or OnKeyUp event
so it does not react on the user pressing a Delete key.

Quote:
I tried to use DefocusControl to remove the focus from
stringGrid to PaintBox

You cannot give focus to a TPaintBox. If you could then the
user clicking a TPaintBox object would give focus to it.

Quote:
so that the StringGrid won't receive
user's any key stroking. It didn't work.

By using DefocusControl() the form will get the focus. So keystrokes
go to the form. Use OnKeyDown or OnKeyPress or OnKeyUp event of
the form.

Hans.
Back to top
didan
Guest





PostPosted: Thu Apr 12, 2007 11:32 pm    Post subject: Re: Switch focus between TpaintBox and TStringGrid Reply with quote

Quote:

Why are you doing that?


PaintBox is used for user to draw graphics. Therefor,both
PaintBox and StringGrid receive user's inputs. If user edits
StringGrid first then switch to draw graphics, such as to
delete a line, the PaintBox will receive this delete stroking.
I tried to use DefocusControl to remove the focus from
stringGrid to PaintBox so that the StringGrid won't receive
user's any key stroking. It didn't work.
Hope it makes my question clear. I'm sorry for the confusing.
Thanks for try to help me.
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Apr 13, 2007 1:43 am    Post subject: Re: Switch focus between TpaintBox and TStringGrid Reply with quote

"Hans Galema" <notused (AT) notused (DOT) nl> wrote in message
news:461e7bcf$1 (AT) newsgroups (DOT) borland.com...

Quote:
A TPaintBox has no OnKeyDown or OnKeyPress or
OnKeyUp event so it does not react on the user pressing
a Delete key.

TPaintBox is a TGraphicControl descendant. It has no HWND of its own,
and thus cannot receive user input event from the OS at all.

Quote:
You cannot give focus to a TPaintBox.

True, but you can take focus away from the TStringGrid.

Quote:
By using DefocusControl() the form will get the focus.

Only if the form is the direct Parent of the StringGrid. Otherwise,
the StringGrid's Parent would be focused instead.


Gambit
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Apr 13, 2007 1:46 am    Post subject: Re: Switch focus between TpaintBox and TStringGrid Reply with quote

"didan" <relaxandfree (AT) yahoo (DOT) com> wrote in message
news:461e4d09$1 (AT) newsgroups (DOT) borland.com...

Quote:
I put DefocusControl( StringGrid1, true) in TPaintBox1 MouseDown
event.


Make sure the form's ActiveControl property is not still pointing to
the StringGrid after you have removed the focus.


Gambit
Back to top
Didan
Guest





PostPosted: Fri Apr 13, 2007 3:43 am    Post subject: Re: Switch focus between TpaintBox and TStringGrid Reply with quote

Yes, PaintBox doesn't fire key event, but I use form's key
event to receive delete keystroke. It accidentally deletes the
inputs on StringGrid. That is how I get problem.
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue Apr 17, 2007 2:04 am    Post subject: Re: Switch focus between TpaintBox and TStringGrid Reply with quote

"didan" <relaxandfree (AT) yahoo (DOT) com> wrote in message
news:4623d861$1 (AT) newsgroups (DOT) borland.com...

Quote:
I guess it may be the case. How can I check it?

ActiveControl is a pointer to a component instance. Just make sure it
it not pointing at the TStringGrid. Or just explicitially set it to
NULL after you call DefocusControl().


Gambit
Back to top
didan
Guest





PostPosted: Tue Apr 17, 2007 2:11 am    Post subject: Re: Switch focus between TpaintBox and TStringGrid Reply with quote

Quote:

Make sure the form's ActiveControl property is not still pointing to
the StringGrid after you have removed the focus.


Gambit



I guess it may be the case. How can I check it? Thanks for help
Back to top
didan
Guest





PostPosted: Wed Apr 18, 2007 1:59 am    Post subject: Re: Switch focus between TpaintBox and TStringGrid Reply with quote

Quote:

ActiveControl is a pointer to a component instance. Just make sure it
it not pointing at the TStringGrid. Or just explicitially set it to
NULL after you call DefocusControl().


Gambit

Hi Gambit
It still doesn't work. If the cursor is on a cell, the cell
always receives key press. What else can I try?
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Apr 18, 2007 3:42 am    Post subject: Re: Switch focus between TpaintBox and TStringGrid Reply with quote

"didan" <relaxandfree (AT) yahoo (DOT) com> wrote in message
news:4625270c$1 (AT) newsgroups (DOT) borland.com...

Quote:
It still doesn't work. If the cursor is on a cell, the cell
always receives key press. What else can I try?

Then you are not taking focus away from the TStringGrid in the first
place.


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