Board index » cppbuilder » event when a frame gets focused

event when a frame gets focused


2005-10-24 06:51:00 PM
cppbuilder1
I wonder which event I can override when a frame get's focused.. I want to
update a grid, but only when the user selects the frame and makes it active.
/Simon
 
 

Re:event when a frame gets focused

Simon Rydberg wrote:
Quote
I wonder which event I can override when a frame get's focused.. I want to
update a grid, but only when the user selects the frame and makes it active.
Where is the grid ? I wonder how a user could select a frame. Do you
mean a TFrame ? More that one TFrame on a TForm ? Please describe a
scenario.
Hans.
 

Re:event when a frame gets focused

I have a frame that I'm going to "glue" on a form/tabsheet/panel and I want
to update the grid on the form when the user see the frame, or make the
frame active. But I can't find that event. And I only want to to the update
the first time the user makes the frame active. not every time he clicks on
it. But I want to update the frame if it's in a tabsheet and the user
switches between the sheets. So every time the frame becomes the active one
I want to update the grid.
Hope that you understand what I mean.
/simon
"Hans Galema" < XXXX@XXXXX.COM >skrev i meddelandet
Quote
Simon Rydberg wrote:
>I wonder which event I can override when a frame get's focused.. I want
>to update a grid, but only when the user selects the frame and makes it
>active.

Where is the grid ? I wonder how a user could select a frame. Do you
mean a TFrame ? More that one TFrame on a TForm ? Please describe a
scenario.

Hans.
 

{smallsort}

Re:event when a frame gets focused

Simon Rydberg wrote:
Quote
I have a frame
Sorry, but do you mean a TFrame ? I asked you already.
Quote
that I'm going to "glue" on a form/tabsheet/panel and I want
to update the grid on the form when the user see the frame, or make the
frame active.
Do you mean a TStringGrid ?
Lets suppose you atached a TFrame on a TForm.
Quote
But I can't find that event.
Now what do you mean with this TFrame becoming active? That also
I asked before.
Quote
And I only want to to the update
the first time the user makes the frame active. not every time he clicks on
it.
Does clicking on a TFrame make it active ?
If you want things to be done only once than you only need
a private bool which will tell you.
private: // User declarations
bool updatedone;
As soon as you did the update set the bool to true. Check the
bool before updating.
Quote
But I want to update the frame if it's in a tabsheet and the user
switches between the sheets. So every time the frame becomes the active one
I want to update the grid.
A TTabSheet has an OnShow event that you can use for that. A TTabSheet
will be part of a TPageControl. You can also use the TPageControl's
OnChange event.
Quote
Hope that you understand what I mean.
As you can see I still had questions.
Hans.
 

Re:event when a frame gets focused

It's a TFrame and on the TFrame there is a TAdvStringGrid from tmsSoftware,
works in a similar way as a ordinary TStringGgrid.
What I mean with the frame becoming active is, when the user selects the
form/tabsheet that the TFrame is glued on. For example, consider the
following code:
...
TFrameView *view1 = new TFrameView(this);
view1 ->Name = "view1";
TFormPasteForm *form1= new TFormPasteForm(this, view1);
form1->Show();
TFrameView *view2 = new TFrameView(this);
view1 ->Name = "view2";
TFormPasteForm *form2= new TFormPasteForm(this, view2);
form2->Show();
...
and in
__fastcall TFormPasteForm::TFormPasteForm(TComponent* Owner, TFrame *frame)
: TForm(Owner)
{
if (frame != NULL)
{
frame->Parent = this;
frame->Align = alClient;
frame->Show();
}
}
This is basicly what I mean, and on the TFrameView I have some components,
including a TAdvStringGrid that I want to update when the user selects the
form that the TFrameView is on.
So the user selects form1 and I want to run some code, when the user later
select form2 I want to run some code, and if the user selects form1 I want
to run some code, and if he selects form2 again I want to run some code.
This is what I mean by "The frame is active" it's the TFrameView that the
user is currently looking at or starting edit. The frame that the user is
currently interacting with.
I'm looking after a way that the frame itself knows when to update itself
when it becomes active. Trying to avoid dependencies.
For example using a TabSheets OnShow event makes the tabsheet aware of
TFrameView. It would have been fine if I had the option to make TFrameView
implement an interface, for example:
class FrameUpdater{
public:
virtual void update()=0;
};
and later on...
class TFrameView : public TFrame, public FrameUpdater
{
...
void update() { updating my grids and compo};
...
}
and then in the onshow event:
...
((FrameUpdater*)myGluedFrame)->update();
but multipel inheritance on vcl classes is not allowed in Borland Builder 5,
it is however possible in Borland Builder 6 but the project that I'm working
on can't compile in version 6 due to third-party dependencies.
Do not know if it is possible to do what I want.
/simon
"Hans Galema" < XXXX@XXXXX.COM >skrev i meddelandet
Quote
Simon Rydberg wrote:
>I have a frame

Sorry, but do you mean a TFrame ? I asked you already.

>that I'm going to "glue" on a form/tabsheet/panel and I want to update
>the grid on the form when the user see the frame, or make the frame
>active.

Do you mean a TStringGrid ?

Lets suppose you atached a TFrame on a TForm.

>But I can't find that event.

Now what do you mean with this TFrame becoming active? That also
I asked before.

>And I only want to to the update the first time the user makes the frame
>active. not every time he clicks on it.

Does clicking on a TFrame make it active ?

If you want things to be done only once than you only need
a private bool which will tell you.

private: // User declarations
bool updatedone;

As soon as you did the update set the bool to true. Check the
bool before updating.

>But I want to update the frame if it's in a tabsheet and the user
>switches between the sheets. So every time the frame becomes the active
>one I want to update the grid.

A TTabSheet has an OnShow event that you can use for that. A TTabSheet
will be part of a TPageControl. You can also use the TPageControl's
OnChange event.

>Hope that you understand what I mean.

As you can see I still had questions.

Hans.
 

Re:event when a frame gets focused

Simon Rydberg wrote:
Quote
I'm looking after a way that the frame itself knows when to update itself
when it becomes active. Trying to avoid dependencies.
Yes. At the moment I have no solution.
Quote
class TFrameView : public TFrame, public FrameUpdater
{
...
void update() { updating my grids and compo};
...
}

and then in the onshow event:
...
((FrameUpdater*)myGluedFrame)->update();
Why not simple:
class TFrameView : public TFrame
{
...
public:
void update() { updating my grids and compo};
...
}
and then in the onshow event:
...
myGluedFrame->update();
Please start t{*word*220} your quotes. (Do not repost complete messages).
Hans.