DPI changes of WinForm in C# - c#

I have developed an application that controls couple of maxon motors in C#. My OS is Win 8.1. My program works properly. However, it has one strange behavior. When I press a specific button, the dpi (resolution) of the main form of the application highly increases and the size of the window decreases. So before pressing this button I have a windows with same dpi of other windows, and after pressing this button, I have a high resolution/small windows. I figured it out that the piece of code making this happened is:
Device.Init();
which is related to one of the maxon dlls. Does anyone know how I can remove this effect? Is there anyway to set resolution in Visual Studio?

Related

Windows Forms app looks different from Visual Studio designer view [duplicate]

This question already has answers here:
How to configure an app to run correctly on a machine with a high DPI setting (e.g. 150%)?
(6 answers)
Closed 4 years ago.
I am trying to create a Windows Forms app using Visual Studio 2017. The app should be run on a 1024x768 touchscreen eventually, that is why I am trying to make all forms in size 1024x768 and without a form border. The problem is that when I launch the app the buttons seem to shift slightly and this makes them fall partially off the screen. The text also seems to be displayed in reduced quality and/or another size. You can look at the images below as an illustration of what I mean.
This is what the form looks like in the designer view in Visual Studio. The text is clear, everything fits the screen and all text fits in the buttons
Designer view of the form:
This second picture shows the form when I actually launch the app. The text quality is reduced, the 'Add From' text does not fit inside the button anymore and the bottom two buttons are partially off the form.
View of the form when app is launched :
My form is set to AutoScaleMode: Font, AutoSize: False.
Are these form parameters wrong or is it something in my Visual Studio settings? I have no clue what I could do to fix this.
Thanks in advance.
The resolution differences looks like a DPI issue. Windows Forms doesn't scale well to a DPI other than 100%. Check your monitor settings.
In Windows 10, this is labelled "Change the size of text, apps, and other items" in Display Settings.

Cycle through open windows in C# using ALT+TAB/ESC and have the current window in focus and forced to be maximized (if already minimized to taskbar)?

I am writing a small application to automatically rotate through open windows on Windows 7/8.1/10 PC's. I have written the majority of the code and it is working well except I cannot figure out or find out what key presses to use to cycle through open applications.
I have tried SendKeys.Send("%{Tab 2}"); but this seems to only actually press the TAB button once as it keeps switching between the same two windows (even though more are open).
I have tried SendKeys.Send("%+{Esc}"); but this doesn't maximize windows that are minimized to the taskbar. It will effectively cycle through each open windows and bring them into focus (as evident by watching the white semi-transparent overlay on the taskbar item) but it won't show them on screen - I'm assuming because they started minimized. Only the maximized ones will show on screen when it's their turn.
Can anyone please assist? I'm sure it's a simple fix of maximizing the window it cycles to but I'm unsure how to implement this.
I haven't included the code of the entire application as I don't think it is relevant. If you do require it please let me know and I will add it.
Many thanks.

how to prevent controls from resizing when resolution changes..?

IDE: Visual Studio 2010, C#.net 4.0 winforms application
My project is build on 1366x768 screen resolution and running fine on it, this application rich of of winforms and user controls and custom controls.
Problem #1:
How to handle, When I run the same application on smaller resolution for eg. (1200x800) The right part of application is not visible on that screen.
Problem #2:
How to handle, when I run the same application on bigger resolution screen for eg. 1920x1080, the controls are stretching non proportionally,
for problem 2, please tell me how to prevent controls from stretching and changing its location, I have observed that the location and size of control is changed, which I don't want, can you suggest me how to handle this problem.
also provide me a generic solution for #1 and #2, I have searched that anchor and dock is one way to handle it but still I am not satisfied with those solutions because of having rich of controls on it.

Dialog and toolbox windows re-size themselves to full screen

I'm running a C# .Net program on a computer other than that I developed it on. It works fine, but when you open dialog or toolbox windows within it they always re-size themselves to full screen, which is really annoying as in the code I have set limits on the size and here they are being exceeded. This has never happened before on another PC. It also happens with some other programs, and even a pop-up dialog within Google Chrome.
I think this might be a registry setting but have no idea how to fix this. Has anyone else ever come across this?

Problem in Drag And Move Forms in .Net

I Write a Windows Application By C Sharp.
I Use a Picture in Background of my Form (MainForm) And I Use Many Picture in Buttons in This Form,And also I Use Some Panel And Label with Transparent Background Color.
My Forms,Panels And Buttons has flicker. I solve this problem by a method in this thread.
But Still when other Forms Start over this Form,my Forms hangs when I Drag and Move my Forms over this Form.How can I Solve this Problem to Move And Drags my Forms easily And Speed?
Edit::
My Forms Load Data From Access 2007 DataBase file.I Use Datasets,DataGridViews And Other Components to Load And show Data in My Forms.
You just made it less obvious that your form paints very slowly by using the techniques shown in my answer. The tricks don't speed it up, they merely make the ugliness less visible. But they fall flat when you have to paint your form from scratch, which happens when you move another window across it. The painting cannot keep up with the barrage of paint requests that are generated each time the overlapping form moves by one or more pixels.
An instant fix is to upgrade your operating system to Vista or Windows 7, windows don't overlap anymore with Aero enabled.

Categories

Resources