473,387 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to resize a maximized form

I have a situation where I need to display a form in a panel. Everything
works great except if the form is maximized and the panel's size changes. In
this case the maximized form's bounds do not change. I tried updating the
form's Bounds property in the panel's SizeChanged event but this does not
work because the Bounds property seems to be ignored until the form is
restored to the normal state. I also tried using the form's SetBoundsCore
method and setting the form's MaximizedBounds property but these didn't work
either.

Is there any way to change the form's bounds while it is in the maximized
state? I am familiar with MdiClient control and I noticed that the MdiClient
implements the desired behavior but I can not use an MdiClient in my
situation.

Thanks for any help!
Lance
Jun 28 '07 #1
4 2873
Hi Lance,

I performed a test based on your description and did see the problem on my
side.

In fact, there're many limitations when a form is shown within a control.
For example, if the form has a TextBox on it, and the form is shown within
a control, say a Panel, you'll see that you can't set the input caret in
the TextBox when you click in the TextBox.

Your problem is another limitation related to this topic. A workaround of
your problem is to handle the Panel's SizeChanged event and in the event
handler, hide the form and then show the from as a maximized window to
force the form to repaint itself.

The following is the sample code.

using System.Runtime.InteropServices;
[DllImport("user32.dll")]
extern static bool ShowWindow(IntPtr hWnd,int nCmdShow);
int SW_MAXIMIZE = 3;
int SW_HIDE = 0;

void panel1_SizeChanged(object sender, EventArgs e)
{
this.SuspendLayout();
// the 'frm' is the form that is shown within a Panel
ShowWindow(frm.Handle, SW_HIDE );
ShowWindow(frm.Handle, SW_MAXIMIZE);

this.ResumeLayout();
}

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 29 '07 #2
Hi Linda,

Thanks a lot for your help and for taking time to understand my issue. Your
suggestion was helpful although the limitations that you pointed out make me
feel like I should rethink my design to see if there is a slick way to avoid
having to show a form in a control.

Thanks again,
Lance

Jun 29 '07 #3
Hi Lance,

Thank you for your prompt reply.

Generally speaking, if we need to show something in a container, e.g. a
Panel, or a SplitContainer, we create a UserControl and show the
UserControl in the container.

Showing a UserControl in a container won't have the limitations when we
show a WinForm in the container.

In your scenario, you could create a UserControl for each form you'd like
to show in the panel and then show the UserControl in the panel instead of
the form.

Hope this helps.
If my suggestion is not appropriate to your practice, please feel free to
let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Jul 3 '07 #4
Hi Linda,

Thanks for the idea. Your help is always appreciated.

Lance

Jul 5 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: franz | last post by:
hallo everyone, i have a popup window 500x400px centered in the middle of the screen and inside it there's a mini-photogallery. what i want is to click on a thumbnail and open in the same window a...
1
by: guy | last post by:
Hi! we design forms in size of 800,600 because this is the size of our clients screen, the problem is that i can maximize the form from the control box or double click on the top border,to the...
1
by: Sumit | last post by:
Hi all, I have an MDI form in which i open some other forms. I dont want the Control Box (having minimize, restore/maximize and close button) Even though I have set the controlbox property of...
2
by: Christian Soltenborn | last post by:
Hi guys, I have a question to VB .NET: I add a Graphics object to a panel and use a bunch of DrawLine methods etc (it's really nice and convenient). But: As soon as I send my form (which...
4
by: john andrew | last post by:
-- hello How do you start a form maximized in VB.net and for that matter in VB6 as well? It is a simple silly question that I couldnt get the answer for. thanks
4
by: Russ Green | last post by:
I have a VB.NET app that uses lots of forms which I am loading into a panel cotrol using..... Me.pnlMain.Controls.Clear() frm.TopLevel = False frm.WindowState = FormWindowState.Maximized...
0
by: summiyashaheen | last post by:
i want the button to resize on a window form in vb.net when the window is maximized or resotered. there is an image as background. buttons are placed according to the image parts. when the window is...
6
by: Tarren | last post by:
Hi: I am trying to get access to the event after a window has been resized. The events I have been using SizeChanged and Resize all fire after any pixel size change. What I am trying to...
10
by: =?Utf-8?B?UmljaA==?= | last post by:
A lot of users at my workplace use different screen resolutions, and I build apps to use 1680 x 1050 pixels res by default. But some users are using 800 x 600, and the apps are too large for their...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.