473,789 Members | 2,773 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2898
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("user 32.dll")]
extern static bool ShowWindow(IntP tr hWnd,int nCmdShow);
int SW_MAXIMIZE = 3;
int SW_HIDE = 0;

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

this.ResumeLayo ut();
}

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
31985
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 page that is fullscreen big and move to co-ordinates (0,0) I've written some code to do that: <script language="JavaScript"> <!-- function resize_()
1
2177
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 size of my screen but i can't resize it from the edge of the form like we can do to any windows form. i have alot of application that i can do it there, i checked all thus application and every thing is the same. what can be the reason? thank's...
1
2899
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 my child forms as false & the respective minimize & maximize box property to false, i get the control box with restore button as enabled (when i dock my child form in the MDI form with dockstyle as fill) which restores the
2
3573
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 contains the panel) to the task bar and get it back, the graphics are gone. I guess that I need to add an event handler to the pane (or the form?), but which event do I have to handle? And which method do I call on the panel to get it repainted?...
4
1839
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
3200
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 frm.Dock = DockStyle.Fill frm.Anchor = AnchorStyles.Left + AnchorStyles.Right + AnchorStyles.Top + AnchorStyles.Bottom
0
943
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 maximized, image portion expands but the buttin size is fixed. how to fix the size of the button according to the image portion.......
6
5786
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 achieve is after the window has been dragged to a new size (or maximized/restored) then I redraw the images within the form. If I do it on Resize, then it tries to redraw as the form is being resized,
10
44087
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 screen. I used to write code in Java a few years ago (2005), and you could stretch a form with the mouse and all the controls and fonts would resize to larger or smaller size. Does .Net framework 3.5 support this kind of functionality? Or -...
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10412
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.