I have a form with a simple ContextMenuStrip:
Application is created in VS2022, SDK7, WinForms, with defining PerMonitorV2 Dpi in csproj file.
I have 2 displays (Primary: 100%, other: 175%).
If I launch the app on the primary screen, it works as intended:
But if I move this window to the 175% screen:
As you can see, context menu's font is stayed at the original size, i.e. it didn't scaled up to 175%.
Now, if I launch the app on the secondary (175%) screen:
Labels are scaled, but the tickmark is not.
If I move this window back to the primary (100%):
ContextMenu's size stays the original, ie. it's not scaling down back to 100%.
Can I somehow overcome on this problem?
Related
I have a WPF application that I want permanently maximised.
The application starts off maximised and that's fine.
I have set the ResizeMode="NoResize" and while this does prevent the window from being resized (by dragging the edges of the window), I find I can drag the title bar down, and the window will resize to a "Restore" state - i.e. partially filling the screen. At this point the window can't be resized (as I'd expect) or maximised once again (even if I drag the title bar back to the top of the screen)
Is there a setting that will just not allow the "restore" functionality and force the Window to always be maximised?
Edit
I've discovered this is actually a window setting, and if I turn off "Arrange windows automatically by dragging them to the corners of the screen" in Settings / System / Multitasking it prevents this (I also needed to remove the ResizeMode="NoResize" funnily enough otherwise dragging the title bar just drags the entire maximised window down).
However, I can still "Restore" it by double-clicking on the title bar. I can maximise once again by doing it again, but I don't want the user to be able to restore the window at all.
Strangely enough, doing it this way ResizeMode="NoResize" lets me restore a maximised window, but not maximise a restored normal window... I'd be happy with the other way around...
I've developed a WPF application as an AppBar using vb.net, it's docked to the bottom edge of the screen and remains topmost as expected.
Other applications such as notepad when maximized/opened only expand to the top edge of the AppBar(expected). However when another application such as notepad is resized it can be dragged down behind the AppBar.
How do I prevent Other applications from moving behind the AppBar/prevent them moving into that section of screen that the AppBar occupies when they are not maximized?
Images 1 : the reserved space for the app bar and the VS window maximising to the edge of this reserved space, no further.
Image 2 : What I want to prevent, A resized window such as the chrome window being able to move into the reserved space for the AppBar.
I would happily provide a screenshot of this, however the problem is the captured image, is much larger than my actual desktop.
I am completely frustrated with this as I have tried using BitBlt with the desktop hdc AND the new "Graphics" commands.
My actual desktop resolution is 1920x1080 - 1080p .
BitBlt and "Graphics" both return that my resolution is 1536x864 # 96 DPI.
A form (WinForm), Maximized, borderless, and irrelevant of scaling mode the form is set to, also shows 1536x864 # 96 DPI.
Now the image that is captured, is like it is being done from 1920x1080, but clipping the region 1536x864 as the screenshot.
If I do PrintScreen directly using Prtscn button, I get the entire image, but still it is about 1.5-2x larger than what I actually see.
What I am looking for -- is a resolution for how I can take a picture of what is on my screen in the scale/dpi/whatever is going on here that it visually looks like. I have written a screen capture program, and using a few different examples for the RubberBand form (overlay form to select a region of the screen by drawing a box), and as you can imagine, this scaling crap is causing those box captures to be offset, and the contents are zoomed.
This is very annoying -- even to explain, however I am positive that most of you are familiar with the terms I use, and also know what to expect from taking a screenshot, so my explanation above should be pretty clear as to what my problem is.
Example/Consideration
Imagine, taking a picture of a window that is 300x300, and getting the top left 150x150 of that zoomed to 300x300 completely skipping the remainder of the window. Resulting image is still 300x300, but it's not what you selected.
Now imagine, you grab a picture of your screen by the only dimensions you can get programmatically, and then put the image into a picturebox. Even though both your screen and the picturebox claim to be the same dimensions and dpi, the image in the picturebox requires scrolling even if the picturebox is maximized to fullscreen on a borderless with no borders / etc. -- again, the picture is zoomed, but how is it still reporting that it's the same size as the form XD (comparing Graphics or BitBlt dimensions with the actual form. also tried comparing picturebox contents, and still same effect)
This, is EXACTLY what the effect is that is happening. When I try to capture a region or segment of the screen. I am not sure why windows api/crl is lying about this seemingly trivial stuff, however there must be a way to accurately obtain screenshots/capture regions without this faux zoom effect -- across all resolutions.
Thank you Hans Passant for pointing me in the right direction.
To add "true" dpi scaling support to a winforms application, you can make it so by adding the following block to your manifest :
Project > Add New Item > Visual C# Items > Application Manifest File
One the file has been added, open it up and look for a line like
</asmv1:assembly>
Whatever the "asmv" number is, (in the example above it is 1), use that to format the code:
<asmv1:application>
<asmv1:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv1:windowsSettings>
</asmv1:application>
Paste the above code (changing the asmv1 to whatever version the manifest is), just above the final closing line for the ""
Also, make sure your forms are set to AutoScale to dpi (and all sub-elements).
I cannot not find any way to restore the Saved Window Position without seeing the Window jump from its initial default Position to the Restored Position. The problem is that the first time I get access to the Window its already visible to the user. Am I missing something or is there currently no way to do this?
Try adjusting OOB Settings, Width=1, Height=1
It is not ideal, but tolerable.
The window opens very small, then resizes correctly.
I also found that when restoring the window position, you have to set the Width and Height first, then Top and Left. Otherwise there appears to be a bug which sometimes resets the top or left.
I have a ChildWindow which contains a ExpressionMediaPlayer inside it. When I click on the ChildWindow Media Player Full screen button it swiches the whole application to FullScreen Mode.
Is there a way to avoid it. I am not quite sure if this scenario is going to fall under SL security restrictions.
When I drag the ChildWindow(the position of ChildWindow changes) and click on the fullscreen
now the ChildWindow also changes it's position.
For example if I have dragged the ChildWindow 50px from Top and pressed the Full Screen button of of mediaPlayer (it contains) the Child Window also appears 50 pixels below the Screen Top.
But I want My ChildWindow to be FullScreen without having any Gap from LEFT,TOP,RIGHT or below.
Any help will be greatly appreciated.
Thanks,
Subhen
Silverlight only uses one of its two windows. The first is the normal window embedded in the Host application such as IE (or in windowless mode it co-operates with the host to draw directly on one of the host's windows in a give rectangle). The other window is a Fullscreen one.
When in full screen mode it moves all its rendering of its stack of content to the full screen window. You can't get Silverlight to render only some controls on the Fullscreen window, its an all or nothing proposition.
Creating a "fullscreenable" ChildWindow would be an interesting exercise. Probably a new templated control based on Childwindow with a new "Fullscreen" visual state (in a new state group) that hides the chrome and causes the content grid to stretch with Auto Width and Height.