mdi client problems - second try

G

Guest

In our app (VB) client forms are displayed based on what is on the current
client form and the button pressed. A user never selects a client form. You
can think of this process as filling out a very long form with many branches
(e.g., IRS form 1040). Once a client form is loaded it is never unloaded -
just hidden.

I need help resolving these 2 problems:

1) Focus on a text box. I know i can't set the focus in the Load event but
the Activated event only fires when the first client loads. Also, when the
form is redisplayed (i.e., made visible) txtbox.focus, for example, doesn't
work. What I do now is start a timer with a 10ms interval and set the focus
in the timer event. I also think that sometimes when I leave the text box the
Leave event doesn't always fire. There's got to be a better way.

2) Client form size. I would like the client form to be the maximum size
that will fit in the MDI parent. The minimum size of the client forms is set
to 720 X 540. If i set the WindowState to Maximized the first client is
displayed maximized but all the others are displayed at their minimum size.
When the first client form is redisplayed it is also displayed at the minimum
size. This just drives the users crazy. What I've done is after showing the
form the first time or making the form visible on redisplays I set the
child.Dock = DockStyle.Fill. I also do this if the
parent is resized. Now the client is almost maximum size except it still has
its own margins.
 
R

Robby

For the first problem. What could be happening is that the MDI child does
not have focus when it is made visible. After you set Form.Visible = True
call Form.Activate. This will set the form as the active MDI child and give
it focus. Then your call to TextBox.Focus will set the focus to the control
as required.

For the second problem. One solution is to reset the minimum size of the
MDI children to the MDI parent's ClientSize each time the MDI parent is
resized. This will dynamically resize the MDI children along with the
parent as needed.

Hope this helps.

Robby
 
G

Guest

Problem 1. I've tried form.Activate. Here is what happens: Activated fires;
the txtBox.focus is executed; Entered fires and I set the backcolor to blue
and the forecolor to white; Leave fires and I set the colors back to
white/black. If I put a break point at the txtBox.focus command and step it
thru the focus is in txtBox with colors set blue/white (but wait the Leave
fired and the colors should be white/black). If I remove the breakpoint the
focus is not in the txtBox and the colors are white/black. There seems to be
a problem with one window becoming invisible and another becoming visible.
Maybe my 10ms timer lets things settle down. Any other suggestions?

Problem 2.

Tried your suggestions. Not any better than child.Dock = DockStyle.Fill and
doesn't position the window correctly (you still need to dock it or
something) and is still not maximized. Is there anyway of "clicking" the
restore box by code?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top