views:

212

answers:

3

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?

A: 

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.

SLaks
I did a get of the clientsize in both XP and Windows 7 and they both come back with the exact same result
novacara
Then we need more details. Can you at least post screenshots?
SLaks
I can't post screenshots but I don't think its a problem with size. If I mess with the location property of the panel I can get it to where I want it. For example one of the panels in XP is at 223,2 but in Windows 7 if I make it 223,8 it will line up correctly. But then of course, that would screw up XP. Its like its not interpreting where pixels start correctly.
novacara
I know its kind of vague...I'll try messing with it and post if I can come up with a solution. At least I have a better idea of what I'm looking for now.
novacara
A: 

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.

Kyralessa
I don't know if it HAS to be pixel-positioned or not, however my form is not resizable anyways.
novacara
+1  A: 

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.

novacara