Form minumum size

M

Marcel

Hi,

I'm trying to overlay a form over another form. This form contains 3
textboxes. I want it placed over a listview, exactily over 1 row.
That's all working, but the overlay form is to big, even though I make
frm.height not bigger then the row. When i check the height properties, it
is correct, but on screen it is bigger.
Does a winform form has a minimum size (I set the minumum to 0, no border,
no controlbox, no min/max/close buttons) ?

Marcel
 
H

Herfried K. Wagner [MVP]

* "Marcel said:
I'm trying to overlay a form over another form. This form contains 3
textboxes. I want it placed over a listview, exactily over 1 row.
That's all working, but the overlay form is to big, even though I make
frm.height not bigger then the row. When i check the height properties, it
is correct, but on screen it is bigger.

Yes, actually there is a minimum size. You can create a 'Region' of
appropriate size and shape at runtime and assign it to the form's
'Region' property to make the form appear smaller.
 
H

Herfried K. Wagner [MVP]

* "Marcel said:
I can make a region, but the form does not have a region property ?

\\\
Imports System.Drawing.Drawing2D
..
..
..
Dim gp As New GraphicsPath()
gp.AddRectangle(New Rectangle(0, 0, 22, 22))
Me.Region = New Region(gp)
gp.Dispose();
///
 
M

Marcel

Me is your form?
in my case, Me does not have a region property, I cannot find it.
i'm using vb.net, but that shouldn't make a difference, should it?
 
H

Herfried K. Wagner [MVP]

* "Marcel said:
Me is your form?
in my case, Me does not have a region property, I cannot find it.

You can place the code everywhere in your form where you want to change
the size, so 'Me' is referring the the current object.
i'm using vb.net, but that shouldn't make a difference, should it?

That's actually VB.NET code if you remove the ';' at the end of the last
line (typo).
 
M

Marcel

sorry, as I said before, a form has no region property, so how can I assign
a region to it?
Maybe I'm completly missing the point, but I can't find it. Not in the docs,
not in the intellisense
 
M

Marcel

OK, i found it. Although it's not in the doc's and intellisense doesn't
shows it, it's still there.
Thanks.

Marcel said:
sorry, as I said before, a form has no region property, so how can I assign
a region to it?
Maybe I'm completly missing the point, but I can't find it. Not in the docs,
not in the intellisense
 
J

Jacob Grass [MVP]

Marcel said:
OK, i found it. Although it's not in the doc's and intellisense doesn't
shows it, it's still there.
Thanks.

Go to Tools -> Options -> Text Editor ->Visual Basic and uncheck Hide
Advanced Members.
 
M

Marcel

OK, I found it. Feel like a beginner.
But, I created a new region, but the Form is now showing nothing...
Maybe I go for another solution, the main form looses focus, which is
logical, but is may be confusing for the user.
 
H

Herfried K. Wagner [MVP]

* "Marcel said:
OK, I found it. Feel like a beginner.
But, I created a new region, but the Form is now showing nothing...
Maybe I go for another solution, the main form looses focus, which is
logical, but is may be confusing for the user.

Post your code!
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi Marcel,

If you set form's MinimumSize property to (0,0) the form minimum size is
restricted of what is set for the system.
You can get those restrictions from SystemInformation.MinimumWindowSize. On
my machine it is W:123, H:34.

If you set form's minimum size to some other value different than (0,0) this
will be the minimum size of your form. However my test shows that this is
true only if you have bordless form without caption bar (your case). If you
have resizable bord it gets restricted size anyways.

To sumarize: set your form's minimum size to something meaningful to you,
but not (0,0) like 5,5 and then you'll heve control over the form size
 
M

Marcel

OK,
The basic idea is to mimic windows explorer where when you have selected a
file and hit f2 or click on it,
it wil display a edit box. I wan't the same with my listview, but for 3
columns.
I created a form with 3 textboxes on it that must overlay on the selected
item of the listview.
The 'region-way' doesn't show the form. I choosed an other option: setting
the top,left,height en widt property via customproperties who are use in the
editform paint event. That works.
Only problem is that the form where the listview is on, looses focus, which
can be confusing for the end user. (And I'am a perfectionist!)
Here's the code: (frmEdit is the edit form)

Public Sub ShowEditScreen()

Dim frm As frmEdit
Dim r As Rectangle
Dim reg As Region

With lsvSource

If .FocusedItem Is Nothing Then
Exit Sub
End If

frm = New frmEdit
r =
..RectangleToScreen(.FocusedItem.GetBounds(ItemBoundsPortion.Entire))
reg = New Region(New RectangleF(r.X, r.Y, r.Width, r.Height))
frm.Region = reg
frm.txtArtist.Height = r.Height
frm.txtAlbum.Height = r.Height
frm.txtSong.Height = r.Height

With .FocusedItem

frm.txtArtist.Text = .Text
frm.txtSong.Text = .SubItems(1).Text
frm.txtAlbum.Text = .SubItems(2).Text

End With

frm.txtArtist.Left = 0
frm.txtArtist.Width = .Columns(0).Width
frm.txtSong.Left = frm.txtArtist.Left + frm.txtArtist.Width + 1
frm.txtSong.Width = .Columns(1).Width
frm.txtAlbum.Left = frm.txtSong.Left + frm.txtSong.Width + 1
frm.txtAlbum.Width = .Columns(2).Width

End With

frm.ShowDialog()

End Sub



Marcel
 
M

Marcel

Aha, I should have known about SystemInformation.MinimumWindowSize....

Stoitcho Goutsev (100) said:
Hi Marcel,

If you set form's MinimumSize property to (0,0) the form minimum size is
restricted of what is set for the system.
You can get those restrictions from SystemInformation.MinimumWindowSize. On
my machine it is W:123, H:34.

If you set form's minimum size to some other value different than (0,0) this
will be the minimum size of your form. However my test shows that this is
true only if you have bordless form without caption bar (your case). If you
have resizable bord it gets restricted size anyways.

To sumarize: set your form's minimum size to something meaningful to you,
but not (0,0) like 5,5 and then you'll heve control over the form size


--
HTH
B\rgds
Stoitcho Goutsev (100) [C# MVP]
Marcel said:
Hi,

I'm trying to overlay a form over another form. This form contains 3
textboxes. I want it placed over a listview, exactily over 1 row.
That's all working, but the overlay form is to big, even though I make
frm.height not bigger then the row. When i check the height properties, it
is correct, but on screen it is bigger.
Does a winform form has a minimum size (I set the minumum to 0, no border,
no controlbox, no min/max/close buttons) ?

Marcel
 
H

Herfried K. Wagner [MVP]

* "Marcel said:
OK,
The basic idea is to mimic windows explorer where when you have selected a
file and hit f2 or click on it,
it wil display a edit box. I wan't the same with my listview, but for 3
columns.
I created a form with 3 textboxes on it that must overlay on the selected
item of the listview.
The 'region-way' doesn't show the form. I choosed an other option: setting
the top,left,height en widt property via customproperties who are use in the
editform paint event. That works.
Only problem is that the form where the listview is on, looses focus, which
can be confusing for the end user. (And I'am a perfectionist!)
Here's the code: (frmEdit is the edit form) [...]
reg = New Region(New RectangleF(r.X, r.Y, r.Width, r.Height))

Create the region at (0, 0), then move the form.
 
M

Marcel

Yes, that worked. But I also had to set the width. But I stick with the
solution of setting the minumim size on 1,1 instead of 0,0. That seems to
work to and you won't have to set things twice.

Another question, how can you place a form as a control on another form.
This is for keeping the focus on the first form.

Herfried K. Wagner said:
* "Marcel said:
OK,
The basic idea is to mimic windows explorer where when you have selected a
file and hit f2 or click on it,
it wil display a edit box. I wan't the same with my listview, but for 3
columns.
I created a form with 3 textboxes on it that must overlay on the selected
item of the listview.
The 'region-way' doesn't show the form. I choosed an other option: setting
the top,left,height en widt property via customproperties who are use in the
editform paint event. That works.
Only problem is that the form where the listview is on, looses focus, which
can be confusing for the end user. (And I'am a perfectionist!)
Here's the code: (frmEdit is the edit form) [...]
reg = New Region(New RectangleF(r.X, r.Y, r.Width, r.Height))

Create the region at (0, 0), then move the form.
 
H

Herfried K. Wagner [MVP]

* "Marcel said:
Yes, that worked. But I also had to set the width. But I stick with the
solution of setting the minumim size on 1,1 instead of 0,0. That seems to
work to and you won't have to set things twice.

Another question, how can you place a form as a control on another form.
This is for keeping the focus on the first form.

<URL:http://vbaccelerator.com/article.asp?id=13309>
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi Marcel,


To set a form as a control to another form. Set form's TopLevel property to
'false' this property is not exposed in the property browser so you have to
do it from code.
Once the property is set add the form to the parent's Controls collection.
Unlike the other controls you have to call Form.Show method explicitly.


--
HTH
B\rgds
Stoitcho Goutsev (100) [C# MVP]

Marcel said:
Yes, that worked. But I also had to set the width. But I stick with the
solution of setting the minumim size on 1,1 instead of 0,0. That seems to
work to and you won't have to set things twice.

Another question, how can you place a form as a control on another form.
This is for keeping the focus on the first form.

selected
in
the
editform paint event. That works.
Only problem is that the form where the listview is on, looses focus, which
can be confusing for the end user. (And I'am a perfectionist!)
Here's the code: (frmEdit is the edit form) [...]
reg = New Region(New RectangleF(r.X, r.Y, r.Width, r.Height))

Create the region at (0, 0), then move the form.
 
M

Marcel

Thank you all for the info.

Marcel
Stoitcho Goutsev (100) said:
Hi Marcel,


To set a form as a control to another form. Set form's TopLevel property to
'false' this property is not exposed in the property browser so you have to
do it from code.
Once the property is set add the form to the parent's Controls collection.
Unlike the other controls you have to call Form.Show method explicitly.


--
HTH
B\rgds
Stoitcho Goutsev (100) [C# MVP]

Marcel said:
Yes, that worked. But I also had to set the width. But I stick with the
solution of setting the minumim size on 1,1 instead of 0,0. That seems to
work to and you won't have to set things twice.

Another question, how can you place a form as a control on another form.
This is for keeping the focus on the first form.

selected
for
use
in
the
editform paint event. That works.
Only problem is that the form where the listview is on, looses
focus,
which
can be confusing for the end user. (And I'am a perfectionist!)
Here's the code: (frmEdit is the edit form)
[...]
reg = New Region(New RectangleF(r.X, r.Y, r.Width, r.Height))

Create the region at (0, 0), then move the form.
 

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