Basic question

  • Thread starter Thread starter philip
  • Start date Start date
P

philip

If the main window of my application is maximized, all the windows call by
program (it is not a mdi application) open themselves maximized.
The window called by the main window has this code for its Load event :


Private Sub ShowOneImage_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.BackgroundImage = ImageFromFile("xxx.jpg")
Form1.Size = New System.Drawing.Size(Me.BackgroundImage.Width,
Me.BackgroundImage.Height)
Me.Height = Me.BackgroundImage.Size.Height
Me.Width = Me.BackgroundImage.Size.Width
End sub

In spite of this code, if the calling window is maximized, the called window
is maximized.

If the main window is not maximized, then all is good.

Which property of the called window must I change to avoid this problem ?

Thanks for response.
 
philip said:
Which property of the called window must I change to avoid this
problem ?

I don't think you can change this.

The behaviour of MDI child forms is that they are either all maximized or
none of them are. As soon as one of your child forms maximizes, so do all
the others. You'll see this in any MDI application you can find without
exception (to the best of my knowledge).

The only way you can stop this is to have some of your forms set as
non-MDI-child forms, but of course the behaviour of the windows will be
different then as they will float in front of the MDI parent instead of
being contained within it.
 
philip said:
If the main window of my application is maximized, all the windows
call by program (it is not a mdi application) open themselves
maximized.
The window called by the main window has this code for its Load
event :


Private Sub ShowOneImage_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
Me.BackgroundImage = ImageFromFile("xxx.jpg")
Form1.Size = New System.Drawing.Size(Me.BackgroundImage.Width,
Me.BackgroundImage.Height)

Where did you declare "Form1"? Shouldn't this be "Me.size = ..."?
Me.Height = Me.BackgroundImage.Size.Height
Me.Width = Me.BackgroundImage.Size.Width
End sub


Armin
 
Explicitly set the windowstate property of the called window to normal in
its own load event.
That should do the trick.
 
Explicitly set the windowstate property of the called window to normal in
its own load event.
That should do the trick.
 
Philip,

I think that if you answer the reply from Armin it is much easier to answer.

Cor

philip said:
BUT my application is not a MDI application...

Thanks for your attention
 
I changes my way.
Now, I set the property of the called window in the calling window.
Here is the code :

ShowOneImage.WindowState = FormWindowState.Normal
ShowOneImage.Show()
ShowOneImage.WindowState = FormWindowState.Normal
ShowOneImage.BackgroundImage = ImageFromFile ("XXX.Jpg")
ShowOneImage.AutoScaleMode = Windows.Forms.AutoScaleMode.None
ShowOneImage.Size = New
System.Drawing.Size(ShowOneImage.BackgroundImage.Width,
ShowOneImage.BackgroundImage.Height)
ShowOneImage.Height = ShowOneImage.BackgroundImage.Size.Height
ShowOneImage.Width = ShowOneImage.BackgroundImage.Size.Width
ShowOneImage.Text = Me.Titre_originalTextBox.Text

As you can see, I take all precautions, setting twice
'FormWindowState.Normal', before and after the opening of called window.
I have always the same problem. If the calling window is maximized, the
called window is maximized.

But, curious, that doesn't happen in debug mode.
Only if I launch the rebuilded '.exe' file of the application...
I don't know what I must do...

Thanks for interesting yourself to my problem.

Philip
 
philip said:
I changes my way.
Now, I set the property of the called window in the calling window.
Here is the code :

ShowOneImage.WindowState = FormWindowState.Normal
ShowOneImage.Show()
ShowOneImage.WindowState = FormWindowState.Normal
ShowOneImage.BackgroundImage = ImageFromFile ("XXX.Jpg")
ShowOneImage.AutoScaleMode = Windows.Forms.AutoScaleMode.None
ShowOneImage.Size = New
System.Drawing.Size(ShowOneImage.BackgroundImage.Width,
ShowOneImage.BackgroundImage.Height)
ShowOneImage.Height =
ShowOneImage.BackgroundImage.Size.Height ShowOneImage.Width =
ShowOneImage.BackgroundImage.Size.Width ShowOneImage.Text =
Me.Titre_originalTextBox.Text

As you can see, I take all precautions, setting twice
'FormWindowState.Normal', before and after the opening of called
window. I have always the same problem. If the calling window is
maximized, the called window is maximized.

But, curious, that doesn't happen in debug mode.
Only if I launch the rebuilded '.exe' file of the application... I
don't know what I must do...

Thanks for interesting yourself to my problem.


What's the value of the Startposition property? Should be "Manual", I guess.

Armin
 
For me, there is a problem.
Try this :
Create a form, on which you add a Button1.
Copy the following code :

Public Class Form11
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim bottomForm As New Form()
Dim topMostForm As New Form()
' Set the size of the form larger than the default size.
topMostForm.Size = New Size(300, 300)
' Set the position of the top most form to center of screen.
topMostForm.StartPosition = FormStartPosition.CenterScreen
' Display the form as top most form.
topMostForm.TopMost = True
topMostForm.WindowState = FormWindowState.Normal
topMostForm.Show()
End Sub
End Class

Launch by Menu 'Debug/Start debugging'
All is good. The starting window can be maximized or normal, no problem the
second window appears 'FormWindowState.Normal'.

But now, launch menu 'Build/Rebuild' and launch the '.exe' program build in
'\bin\release' directory of the application.
Maximize the first window. Click on button1 : the TopMostForm appears
'Maximized'.
If you launch the 'exe' file another time and you minimize the first window
at the beginning of program, before you click on Button1, then the
TopMostForm appears 'Normal', in its asked (300,300) size

Personnally, other problem, when I launch the program, the first window
appears ALWAYS 'Maximized'.
I am obliged to give 'False' to the 'MaximizeBox' property. That avoid the
maximization of the main window using the '.exe' file. But it's not
interesting...

Thanks for your interest, sincerely.

Philip
 
I had not seen your response.

StartPosition is on 'WindowsDefaultLocation'

Thanks for listening to me
 
Philip,

How can this code affect the first form, did you not set by accident in the
form designer properties to start it as maximised form.

You will not be the first.

I hope this helps,

Cor
 
philip said:
For me, there is a problem.
Try this :
Create a form, on which you add a Button1.
Copy the following code :

Public Class Form11
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim bottomForm As New Form()
Dim topMostForm As New Form()
' Set the size of the form larger than the default size.
topMostForm.Size = New Size(300, 300)
' Set the position of the top most form to center of screen.
topMostForm.StartPosition = FormStartPosition.CenterScreen
' Display the form as top most form.
topMostForm.TopMost = True
topMostForm.WindowState = FormWindowState.Normal
topMostForm.Show()
End Sub
End Class

Launch by Menu 'Debug/Start debugging'
All is good. The starting window can be maximized or normal, no
problem the second window appears 'FormWindowState.Normal'.

But now, launch menu 'Build/Rebuild' and launch the '.exe' program
build in '\bin\release' directory of the application.
Maximize the first window. Click on button1 : the TopMostForm
appears 'Maximized'.


I can not reproduce this. It appears Normal, not Maximized.

Can you send me a small zipped(!) sample project? Insert a "_" between "no"
and "spam" in my email address.


Armin
 
I send an zipped sample of the app to Armin Zingler to show the problem (he
asked me to do that)
Thanks
Philip
 
philip said:
I send an zipped sample of the app to Armin Zingler to show the
problem (he asked me to do that)


....and Armin answered:

"I can not reproduce the problem. I do it exactly as you described. Neither
the 1st nor the 2nd window is ever opened maximized."


Armin
 
Is it possible that is a problem of my computer, which has an RADEON X800
GTO card, with two screens ?
Is it interressing to look at the options of the driver ?

Thanks for response

Philip
 
Back
Top