PC Review


Reply
Thread Tools Rate Thread

Sizing form...

 
 
Me
Guest
Posts: n/a
 
      4th Dec 2003
Why won't my form shrink down to a smaller size?

Here is the code:

private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new
System.Drawing.Size(200, 200);
this.ClientSize = new
System.Drawing.Size(200, 200);
this.ControlBox = false;
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Location = new
System.Drawing.Point(10, 10);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.StartPosition =
System.Windows.Forms.FormStartPosition.Manual;

}





protected override void OnMouseDown
(MouseEventArgs e)
{
System.Drawing.Size x;
x = this.ClientSize;
x = this.Size;

this.Height = 5;
this.Width = 300;

x = this.ClientSize;
x = this.Size;

base.OnMouseDown (e);
}

..


 
Reply With Quote
 
 
 
 
Gabriele G. Ponti
Guest
Posts: n/a
 
      4th Dec 2003
Hi,

Windows sends the WM_GETMINMAXINFO message to your window when the size is
about to change. By implementing your own window procedure and handling this
message you can change the minimum dimensions allowed.

For more information please see the following document:

WM_GETMINMAXINFO Notification
http://msdn.microsoft.com/library/en...MINMAXINFO.asp

Regards,

Gabriele


 
Reply With Quote
 
 
 
 
Me
Guest
Posts: n/a
 
      4th Dec 2003
Isn't there a C# method for doing this?

Thanks


>-----Original Message-----
>Hi,
>
>Windows sends the WM_GETMINMAXINFO message to your

window when the size is
>about to change. By implementing your own window

procedure and handling this
>message you can change the minimum dimensions allowed.
>
>For more information please see the following document:
>
>WM_GETMINMAXINFO Notification
>http://msdn.microsoft.com/library/en-

us/winui/WinUI/WindowsUserInterface/Windowing/Windows/Wind
owReference/WindowMessages/WM_GETMINMAXINFO.asp
>
>Regards,
>
> Gabriele
>
>
>.
>

 
Reply With Quote
 
Gabriele G. Ponti
Guest
Posts: n/a
 
      4th Dec 2003
Not that I know.


 
Reply With Quote
 
Tom Clement
Guest
Posts: n/a
 
      4th Dec 2003
Your code works fine for me. When I click on the form, it resizes as
expected.

This thread is a bit confusing to me, since one responder seemed to think
you were asking about setting the minimum size for a form. You do not need
to handle the window message to do this. As you might expect, you can just
set the MinimumSize and MaximumSize properties on the form.

Tom Clement
Apptero, Inc.


"Me" <(E-Mail Removed)> wrote in message
news:098f01c3ba72$089c3980$(E-Mail Removed)...
> Why won't my form shrink down to a smaller size?
>
> Here is the code:
>
> private void InitializeComponent()
> {
> //
> // Form1
> //
> this.AutoScaleBaseSize = new
> System.Drawing.Size(200, 200);
> this.ClientSize = new
> System.Drawing.Size(200, 200);
> this.ControlBox = false;
> this.FormBorderStyle =
> System.Windows.Forms.FormBorderStyle.FixedSingle;
> this.Location = new
> System.Drawing.Point(10, 10);
> this.MaximizeBox = false;
> this.MinimizeBox = false;
> this.Name = "Form1";
> this.StartPosition =
> System.Windows.Forms.FormStartPosition.Manual;
>
> }
>
>
>
>
>
> protected override void OnMouseDown
> (MouseEventArgs e)
> {
> System.Drawing.Size x;
> x = this.ClientSize;
> x = this.Size;
>
> this.Height = 5;
> this.Width = 300;
>
> x = this.ClientSize;
> x = this.Size;
>
> base.OnMouseDown (e);
> }
>
> .
>
>



 
Reply With Quote
 
Gabriele G. Ponti
Guest
Posts: n/a
 
      4th Dec 2003
Tom,

MinimumSize and MaximumSize work fine, but they don't allow you to shrink
the window less than the size of the caption. I believe this is what he was
looking for.

Gabriele


 
Reply With Quote
 
Tom Clement
Guest
Posts: n/a
 
      5th Dec 2003
Gabriele,
Ah, I see. That's good to know.

From the code he provided, it appears that the form is
BorderStyle.FixedSingle, which does not have a caption, so I'm not sure what
the problem is. I did run his code and it changed the form size as he
seemed to expect.

Tom


"Gabriele G. Ponti" <ggponti.at.hotmail.com> wrote in message
news:OO$(E-Mail Removed)...
> Tom,
>
> MinimumSize and MaximumSize work fine, but they don't allow you to shrink
> the window less than the size of the caption. I believe this is what he

was
> looking for.
>
> Gabriele
>
>



 
Reply With Quote
 
Me
Guest
Posts: n/a
 
      5th Dec 2003
So... if you cannot size the form smaller than
the size of the caption... is there a form that I can use
that does not have this restriction?

I have done the WM_GETMINMAXINFO "work around" and wierd
stuff starts happening to the form when you shrink it
really small for example: you can only size "up" some
times and other times you can only size "down".

With a Win32 window you can make it any size you desire,
without restrictions... is a form an analogous entity as
a window ?

Thanks
Me

>-----Original Message-----
>Gabriele,
>Ah, I see. That's good to know.
>
>From the code he provided, it appears that the form is
>BorderStyle.FixedSingle, which does not have a caption,

so I'm not sure what
>the problem is. I did run his code and it changed the

form size as he
>seemed to expect.
>
>Tom
>
>
>"Gabriele G. Ponti" <ggponti.at.hotmail.com> wrote in

message
>news:OO$(E-Mail Removed)...
>> Tom,
>>
>> MinimumSize and MaximumSize work fine, but they don't

allow you to shrink
>> the window less than the size of the caption. I

believe this is what he
>was
>> looking for.
>>
>> Gabriele
>>
>>

>
>
>.
>

 
Reply With Quote
 
Me
Guest
Posts: n/a
 
      5th Dec 2003
The form shrunk down to 5 pixels in size ?

Me

>-----Original Message-----
>Gabriele,
>Ah, I see. That's good to know.
>
>From the code he provided, it appears that the form is
>BorderStyle.FixedSingle, which does not have a caption,

so I'm not sure what
>the problem is. I did run his code and it changed the

form size as he
>seemed to expect.
>
>Tom
>
>
>"Gabriele G. Ponti" <ggponti.at.hotmail.com> wrote in

message
>news:OO$(E-Mail Removed)...
>> Tom,
>>
>> MinimumSize and MaximumSize work fine, but they don't

allow you to shrink
>> the window less than the size of the caption. I

believe this is what he
>was
>> looking for.
>>
>> Gabriele
>>
>>

>
>
>.
>

 
Reply With Quote
 
Me
Guest
Posts: n/a
 
      5th Dec 2003
Ok... here is what I have done....


Near the top of my Form:

using System.Runtime.InteropServices; // Marshal

//Declare wrapper managed POINT class.
[ StructLayout (LayoutKind.Sequential) ]
public class POINT
{
public int x;
public int y;
}


//Declare wrapper managed MouseHookStruct
class.
[ StructLayout(LayoutKind.Sequential)]
public class MinMaxInfoStruct
{
public POINT ptReserved;
public POINT ptMaxSize;
public POINT ptMaxPosition;
public POINT ptMinTrackSize;
public POINT ptMaxTrackSize;
}








Inside the form class:


const int WM_GETMINMAXINFO = 0x0024;

protected override void WndProc(ref Message m)
{
if( m.Msg == WM_GETMINMAXINFO )
{
MinMaxInfoStruct info = (MinMaxInfoStruct)
Marshal.PtrToStructure(m.LParam,
typeof(MinMaxInfoStruct));

info.ptMinTrackSize.y = 2;
Trace.WriteLine( "Y after assignment ",
info.ptMinTrackSize.y.ToString() );

int y = info.ptMinTrackSize.y;
Trace.WriteLine( "Y from 'struct' ", y.ToString() );

Marshal.StructureToPtr( info, m.LParam, false );
}

base.WndProc (ref m);
}



Again the mouse routine:

protected override void OnMouseDown(MouseEventArgs e)
{
Trace.WriteLine( "mouse down" );
System.Drawing.Size x;
x = this.ClientSize;
x = this.Size;

this.Size = new System.Drawing.Size( 400, 1 );

x = this.ClientSize;
x = this.Size;
Trace.WriteLine( "size ", this.Size.ToString() );

base.OnMouseDown (e);
}


Trace output:

2: Y after assignment
2: Y from 'struct'
mouse down
2: Y after assignment
2: Y from 'struct'
{Width=318, Height=38}: size



What gives?????

Thanks
Me
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Non Graphic Window Sizing? =?Utf-8?B?RHJvYmVydHMzNA==?= Windows XP Help 0 2nd Aug 2004 01:35 AM
windows sizing headtheball Windows XP Help 3 3rd Apr 2004 01:01 AM
Windows Explorer sizing problem =?Utf-8?B?TWlrZQ==?= Windows XP Help 0 18th Mar 2004 11:36 PM
Sizing, highlighting & scrolling Stan Windows XP Help 0 7th Mar 2004 08:00 PM
Re: Window sizing dev Windows XP Help 0 6th Dec 2003 01:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:58 AM.