I have a project which has several forms which are connected to a SQL database (read and write). Apart from the parent form, each form starts in center position and in the size I set for it in the properties (which apparently it is considered by the system as the minimum size). When I click the maximize button it goes full screen and that is my problem.
I want the child form to be just a little smaller than the main form (so that I can see the header from behind). When I write my preferred maximum size in properties field it just doesn't work.
I used the first solution written here: Is it possible to set the Maximum Width for a Form but leave the Maximum Height Unrestricted?. It gave me a restriction for the maximized size. However, it not only makes the form get out of center, but as soon as I click on the form it goes back to minimum size.
The other issue is that my project is suppose to run on more than one computer with different resolutions. So, i don't think giving it a specific size would help.
Bottom line is, I want the size of my child form to maximize to a limit just a little smaller than the parent form which is full screen.
Can anyone help me?
It seems you're trying to create a Multiple Document Interface (MDI) style application. This style isn't very common any more, but here are some examples on how to do so.
The StackOverflow example you gave uses the MaximumSize property. That property doesn't apply when the user clicks the 'maximize' button at the top right. It is used for when the form is configured to allow resizing (by grabbing the handle at bottom right). Maximize functionality will either fill the full screen, or for MDI applications, the entire MDI parent window -- and it's always been that way.
Related
I need to make a C# Form screenshot, but there is a catch.
I need it to be a form at certain resolution AND form itself must not flicker to a user, so somehow in background it need to make an screenshot at certain form dimension.
I tried various things but i cannot make form resized without actually resize a window and than take a screenshot. It's anoying since, to user a window will flicker in mean time -> go to resolution -> make screen shot -> go back to old resolution.
Making a deep-copy of form is a more or less no go since it would needed a lot of rewriting things.
I tried things like: Attempt 1 | Attempt 2 | Attempt 3
But still problem with resizing window and flicker from one size to other.
I have dotnet 2.0 (don't ask why).
This is a very specific problem, and I'm sure there are no real code solutions for that. This is a design-technical issue, and some possible ways to avoid this are
1. You don't resize the form back,
2. You make screenshots only possible in your specific size,
3. You disable the resizing in general and set your size to the default size.
Used solution was to paint seperate picture boxes to the memory and than merge all this seperate images to one big image.
I'm trying to make, essentially, a screen capture program, that captures the pixel values under the current window. (I'm working in C#, in Visual Studio 2015.) However, for various reasons, the window itself needs to be opaque (for filters and such). How can I best achieve this?
It is possible to find the window below yours and get a screenshot of it even if it is hidden with the method: PrintWindow (see PInvoke.net as well)
See Copying content from a hidden or clipped window in XP?
It is very simple to do in Winforms. Just set the form's Opacity value to 99%. Now Graphics.CopyFromScreen() will not see your window anymore.
Except when the window underneath yours is also a layered window, then it also won't be visible to CopyFromScreen() for the same reason. Then you have to set Opacity to 0, copy and set it back to 0.99. Very quick, probably good enough for what you want to do.
I'm trying to create a windows form app that "owns" the top area of a screen. Think of it as just a rectangular form width = screen size and height = 20px or so. The app would always be on top and would be borderless (i.e. FormBorderStyle=none). The questionable part, for example, if a user maximizes a window like chrome or some other application, it should treat the bottom of this windows form app as the top of the screen. This way since the form app is always on top, it doesn't cover up any of the maximized application's window.
Any clues on how to do this.. can it be done with windows forms? The only questionable part is how to "own" a portion of the screen.
Let me know if clarification is needed. Thanks in advanced.
What you need is to set the Screen.WorkingArea which is readonly you should use PInvoke to achieve this you can find your answer in this thread
To get the working area of the display you can use Screen.WorkingArea property
I have been working on a project in c# and I have the starting box size pretty small around, 700px by 450px.
Everything looks great on that size but when I maximize it, all the forms and etc stay the same size and just stick to the corner of the window.
I am curious if there is a way to get the boxes to adjust accordingly to the size of the actual windows form so if they click on the maximize button it doesn't look weird.
I have looked quite a bit online and everything I have tried doesn't seem to work. Also I am using visual studio 2013.
Thanks for the help!
I'm not sure I 100% understand what's going on, and please excuse me if I'm just saying things you already know, but controls inside of forms can be anchored. This helps because--for instance-- if a control is anchored on all sides then no matter how the form they reside in is resized they will grow with it.
The anchor property is in the property window.
As far as forms inside of forms that you would just have to grab the size property of the mdi window and grow the child forms based on this.
You could use the resize event in mdi form to fire off an interface method that all of your child forms implement maybe?
Learn how to use the Anchor or Dock properties to position and size controls relative to their container in WinForms
We have a WPF application that has a main window, and 1 child window shown by ShowDialog with ShowInTaskBar set to false.
We save their positions on close, and set Window.Left and Top when re-opened.
Problem is, when you remote desktop into a computer with multiple monitors and then open the child window with a saved position offscreen, there is no way to bring it onto the single monitor.
Is there a something we can change on the child window to make windows handle this issue? The main window doesn't have this issue (I thought it might be related to ShowInTaskBar or the fact it is the main window).
Is there a better way for us to store the window location?
There is no default way within WPF to access any available screen other then the primary screen.
WPF does have SystemParameters.PrimaryScreenHeight and SystemParameters.PrimaryScreenWidth to work with the primary screen however to get information on screens excpluding the primary you would have to make use of the System.Windows.Forms.Screen class.
If you went the System.Windows.Forms.Screen class route you could save relevant data about the window based on the screen at which it resides. Then upon reading the values in you can force the window to the desired screen based on the number of screens residing in the System.Windows.Forms.Screen.AllScreens array. It gives you flexibility for placement as you can take advantage of all available screen within the system versus just the primary.
EDIT:
If you are not concerned with getting the screen information in a modular manner (information per screen versus the aggregate of all available screens) and do not want to make use of the System.Windows.Forms.Screen class you can make use of the SystemParameters.VirtualScreen* properties which will provide the aggregate of available screens.
It should always be possible to get any window back on screen. The following steps hook the currently active window to the mouse cursor:
Press Alt+Space to open the system menu
Press M for 'Move'
Press the right arrow key
now move the mouse