c# Program in Windows 7 moves Panels around - c#

I have an application I have been working on for a while in VS2008 developing in Windows XP and it has some panels placed in specific spots so the borders line up and look nice and pretty. Now that I have switched to developing in 7, as far as I can tell everything else is in the same place but it moves both panels over a little bit and one up and one down and messes up my nice borders. Since it still works correctly in XP I'm assuming this is a 7 problem or a VS problem with 7. Anyone have an idea whats going on or if its fixable?

So I figured it out. Turns out the client area wasn't narrower, however the titlebar which is part of the dialog box border was two different sizes in XP and 7. Since the panels were in an mdi child, where the border was not shown because it was underneath the parent, the size of the titlebar part of the border was making a difference in the location my panels were shown relative to the parent. To solve this I set FormBorderStyle to none on the child and re-positioned the panels to be in the correct spot without that titlebar. It now looks the same in XP and 7 since that variable bar size is gone.

Windows in Windows 7 have wider borders.
Your form probably has a fixed size that is based on a Windows XP border width.
Therefore, in Windows 7, the form's client area will be narrower.
If this is in fact the problem, you can solve it by setting the form's ClientSize property in the constructor the the value it currently has in XP.
If this is not the problem, please post more details.

Do you need to have your panels pixel-positioned? .NET 2.0 introduced the FlowLayoutPanel and TableLayoutPanel for resizeable positioning of elements.
The TableLayoutPanel is the more useful of the two. You create rows and columns, which can autosize or size proportionally to each other. You dock the TableLayoutPanel in your form or anchor it to all four sides. Then the user can resize your form and everything resizes with it.
Even if your panels are of a specific size, you can anchor them to a side or a corner so that they stick to the side even if the user resizes the form.

Related

How to make a FlowLayoutPanel Resizable at runtime?

I have this GUI for my Winform application with 2 FlowLayoutPanels Docked top and right respectively.
Right now I can only give them a fixed size which cannot be changed by user at run time but I want to make these panel Resizable while the application is running.
I've tried BorderStyle Property but only available options are Fixed3D and FixedSingle which are obviously cannot be resized due to their Fixed! behaviour.
I've already gone through the documentation at MSDN but couldn't find anything.
I want to know if I can make them resizable programmatically?

Different Application Size On Different Screens [duplicate]

This question already has answers here:
.Net controls changing size between computers
(3 answers)
Closed 9 years ago.
First time i'm developing a Windows Form Application with C# . I'm using Visual Studio 2012.
My form's size = 1096x508. Also i set Minimum Size and Maximum Size properties to 1096x508 .
This is screenshot of my app ,
But when i execute this app on another computer, result like this :
As you see, red line (at bottom of app) invisible. Because applciation's height is 508 px (as expected) on my pc but 416px on other computer. Because of this , red line staying out of Form. So we couldn't see it.
In shortly, my Form's size 1096x508px but it's only 823x416px on another computer. Can you tell me why there are difference? And how can i fix this? There are resolution difference between this screens.
The behaviour of your application on those computers may be caused by different dpi (dot-per-inch) settings of the Windows operating system. In order to check that please compare the actuals values in Windows display settings (100%, 125%, ...).
If you want to have your program independent from dpi settings you may try to work with different panels (control containers). Your status bar could have a fixed with, while the game area is a docked panel (filling the remaining space).
In general, staying independent from actual dpi, is a difficult topic. Most of the time you can work with autosizing controls, but you could run out of space if, say, two labels overlay.
The main issue, as you have already discovered, is that computers with a different DPI setting will cause the controls to scale.
What Hans was suggesting in his linked answer is that you need to re-design your form so when it gets re-size messages it will handle them accordingly.
The main way this is normally handled is setting the Anchor property or the Dock property of a control. By default a control will anchor to the top left corner of it's parent container. When it is told to scale it scales down and to the right. By changing the anchor point to be the bottom only it will make your bottom control move up instead of moving down off of the boundaries of the parent.

How do I set form size and location synchronous

I made custom borders for my application, like the VisualStudio 2012
There is one central mainform and 4 smaller, dynamically positioned border forms.
In the mainform I have overidden the events OnMove, OnSizeChanged, OnActivate, OnDeactivate.
In those events I set the location, size and color of the borders.
It works quite nicely, but there is some awful artifacts!
Those are the same artifacts that appear when resizing ANY window.
I made a video with my application to show what kind of atrifacts I mean.
Those appear when moving or resizing the window.
Obviously this problem IS solveable, because VisualStudio2012 does it too (meaning that it doesn't have the problem. Just try it, resize the VS2012 window, it won't flicker)
In my implementation I used the same way that VS2012 uses: 4 layered windows that make up the border of the form.
In case someone doesn't the glitches I'm talking about. Here's the video:
http://youtu.be/kKiPke8ruaI
What I need is a way to "synchronously" set the location and size of the 4 border windows.

C# Toolstrip Causes Supporting Form to Grow

I've rewritten a toolbar that sits at the top of the user's screen. It works, but for some reason, though the app consists of just a form with a Fill-Docked ToolStrip, I cannot get it to stay at the size I specify. It's supposed to be the size of the Windows titlebar, as designed in Visual Studio, but as soon as I run it, it's grown in height by five or six pixels. Everything is set rigidly, the Form and ToolStrip are set to AutoSize=FALSE and I've specified the size in pixels the form should be. I cannot work out what is resizing the form at runtime; the ToolStrip is Docked on Fill mode so it should not cause the form to grow. It all looks perfect in the GUI builder, and I copied most of the configuration from the old VB.Net toolbar it will replace. Can anyone help?
Just a wild guess, but have you tried changing the AutoScaleMode property of the Form to something other than Font?
Haven't found an answer but I'll make sure this is closed. I turned the form transparent and it accomplished what I needed. Still unsure why the form expanded when run.

c# panel layout problem

I have created a panel in c# application that holds rows of 5 textboxes.
Textboxes are added to panel dynamically. It is 500 pixels in width and each textbox is 100 pixels wide.
First textbox is at x-position 0, second at 100, third at 200 and so on.
So the 5 textboxes should fill the panel horizontally. These are shown correctly at my computer but at another computer these textboxes appear as if their width is reduced and they do not extend to end of the panel. They leave blank space at the end of panel.
Can anyone tell me why is this difference in display of textboxes?
There could be a few different reasons for this. Depending on if you are using WinForms (which I am assuming) or WPF. There is a system DPI that can be changed in windows. Windows Vista and 7 take advantage of this more. The other issue could be with the windows themes (play with the handicap themes). How to check your system DPI
I think that the problem is in displaying textboxes in computers with diferent Windows themes.
With Classic windows controls it compute space in different way than when themes are turned on on computer.
Couple things to try, make sure the AutoSize property is set to false on the Panel and the Textboxes. Also, make sure the PreferredSize is also set.
I was having a similar problem, and found this link:
C# WinForms messed up control positions?
where changing my main form's AutoScaleMode attribute from Font to None or Inherit solved the problem (NB: changing to Dpi did not solve it).

Categories

Resources