C# disable aero snap for WPF window [duplicate] - c#

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
disable Aero Snap (wpf)
I have an application in C# WPF. I want the main window to have fixed size. To achieve this, I have set the height and max height, width and max width, to the same values. Everything looks fine, but I want also to disable Aero snap effect for this window only.
The solution to disable Aero snap from Windows Registry or Control Panel is excluded.
Setting the ResizeMode of the window to "NoResize" is also excluded, because in this way the window border dissapear too.
Do you have any working solution for this problem in C# ?
Thank you very much.

You can try to change the ResizeMode to NoResize only temporarily as explained in this answer.
Otherwise you can try this trick also but I haven't tried it myself.

I have finally found a solution, after 2 days of searching all over the Internet.
http://programminghacks.net/2009/10/19/download-snapping-sticky-magnetic-windows-for-wpf
Unfortunately it does not work with borderless windows.

Related

WPF Application Has Lost Windows 8 Style And Reverted to a XP Like Look

For no reason I can think of - there have been no code changes, My WPF application has stopped showing the window frame in the Windows 8 style and seems to have reverted to a Windows XP like style (weird grey border around the main window and grey, raised buttons for minimize,maximize and close in the top right corner.
If I try and resize the window you can see the Win8 style buttons trying to draw "underneath" before the grey button style draws over it. (that's the best I can describe it)
Does anyone know why this might be happening?

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.

Windowless WPF Application [duplicate]

This question already has answers here:
How to create a WPF Window without a border that can be resized via a grip only?
(5 answers)
Creating transparent background in WPF
(3 answers)
Closed 9 years ago.
I am hoping someone can point me in the right direction here. I am trying to turn my analog clock application into a windowless clock. I have searched google but I think my issue is I do not know the correct term for what I am trying to do.
My analog clock application is a circle that contains the clock hands. This is contained in a window like most other applications. I would like to remove the window and have only the clock show above the background. I would be able to bring up the close button maybe on mouse over. Or perhaps I could make the whole window transparent except for the clock and on mouse over I would be able to see the window and close it.
Anyone have any experience on this? Maybe some tips or a tutorial somewhere?
Thank you,
You can build your Window, and set the Background="Transparent" like so:
<Window ...
AllowsTransparency="True"
WindowStyle="None"
Background="Transparent" >
This gives you a window with a transparent background and no border.

How to remove the non client area of a WPF window without using AllowTransparency

I would like to remove the resizing border from my WPF custom window.
I already found that I have to handle the WM_NCCALCSIZE message and return 0.
That removes the border and aligns the window to the top left corner of the window.
The problem is that by doing so, the client area increases and the WPF root control doesn't.
That creates black edges on the left and bottom sides of the window that I would like to get rid of.
I'm using VS2010 C# Windows XP and would like this to work under both Windows XP and Windows 7.
Thanks in Advance.
EDIT:
I found out what is causing the black edges, they are the window behind.
Now it seems that the problem is with the root element of the window not occupying the whole window. When I set its margin to negative values it draws over the black area. Apparently the layout pass is ok and the desired size is the same as the window but the render size is different.
I also found out that the whole problem could be solved by removing WS_THICKFRAME from the window style. The problem with that is the resizing functionality that is enabled only when WS_THICKFRAME is used. I'm using WM_NCHITTEST to do the resizing and if the window knows it doesn't have a resizing border, it will shutdown its resizing functionality.
I would like to make the root element occupy the whole window to eliminate the black window background or alternatively enable the native resizing functionality without the thick frame.
Thanks.
I found the reason for that black area.
It appears that the code I was using that someone else made was causing the black area by somehow messing with the layout pass of the framework and therefore the correct size of the root element.
I handled the WM_NCCALCSIZE in another project and it worked like a charm.
After all of that, although I found the idle way to create a custom window with all of the original window functionality, I decided to use the standard window the Microsoft has to offer so that my program will have future compatibility with windows.
If someone would like the code or help with WPF window customization they can comment here and I will help so that at least all of my research won't go in vain.
Thanks for reading.

c# Program in Windows 7 moves Panels around

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.

Categories

Resources