I have done a project in c# winforms. I want to set the resolution of the screen to 1680 x 1050,
when the application is run in any pc. How to do it ?
As the others already mentioned you shouldn't change the resolution automatically, cause the user set it to a specific resolution he likes (or his hardware works best on).
So instead of changing the resolution you should change your application. Use TableLayoutPanel, FlowLayoutPanel and / or SplitContainer. Set the Anchor and Dock properties of your Controls and think about setting the MinimumSize and MaximumSize of each control within your application.
This way your application can automatically scale between different resolutions and the user can take the one he likes.
Last but not least, your application should not only consider to take care about the resolution the user selected, it should also take care about the selected dpi settings. Which one you should care of are described in the Windows UX Guide (site 592).
I would advice you to not do these kind of things. The screen resolution is set by the user and this is something you shouldn't change automatically. It is just as bad as changing the color scheme, sound scheme or any other user based preferences without the user knowing anything about it, let alone wants to let your program to do. At least show a dialog and let the user choose what to do.
Having said that, here's an example on how to do this.
Well, he is not saying his application will be changing other systems' resolutions. You shouldn't change the screen resolution on other people's computers; however, it may be necessary for a user to change his own resolution through a separate utility (for different reasons). That is my case right now, so I had to write a simple utility in C# to accomplish that by using InteropServices. Call ChangeDisplaySettings. Here's the declaration:
[DllImport("user32.dll")]
public static extern int ChangeDisplaySettings(
ref DEVMODE devMode, int flags);
Related
On my workstation I have developed a WinForm application. With panels, buttons and dropdowns.
After that I applied the application to my laptop.
On my laptop the presentation of the application was not correct. The elements overlap and the buttons are warped.
Can you tell me how to handle this?
I apologize for my english. This text was written with Google translator.
It is a bit difficult to tell from the distance, but I guess the window uses a different size on the laptop and the controls' docking and anchoring are not configured to do what you want. I suggest this and this tutorial on how to configure the properties; this is preferrably done in the designer instead of code for a fixed layout.
I've seen this behavior running Windows with a "display size" setting greater than 100%. Try resetting this value in your display settings:
Make sure to develop your forms on a computer with the system DPI setting set to 100%. Visual Studio will automatically convert your form coordinates depending on this system setting (it's a bug according to me). A quick way to fix a form is to do the following:
Make sure the system DPI setting is set to 100%.
Move a button in the form one pixel to the left. Then move it back again.
Save. Compile. Run.
1.] Either use Anchor or Dock
2.] Or try to fix the minimum and maximum size of your form and disable maximize button
I have made a program within C# which i have now published from it but a problem occuyrs when i try to install it on different machines to mine. On my computer the program window size is fine but on other computers its sometimes too small and sometimes too big so the user can not properly look at the main screen of the program. I don't know what to do to change this problem, either within the computer settings or possibly in C# in the code of my project. Please Help,
Thanks,
Chris.
Use Dock and Anchor
It sounds like different users have different screen resolutions. Thats just part of developing software for a variety of users, with differing screen options. You should test your app is usable with different settings and possibly adjust font sizes, layout and dimensions accordingly.
If I'm guessing correctly the problem here isn't the screen resolution but that the actual program window changes size, either hiding parts of the program or showing too much? In that case you should take a look in your WPF editor (if you're using WPF, that is) and check the different Layout/Size options.
You need to use the Anchor properties and Dock properties of your controls (inside the form) to allow your program to be resized. If you can successfully resize it on your computer it should work on others too.
Part from that you may want to set the form to fixed size so that users can't resize it.
You can use the Screen class to get the bounds of the available screens, and from there you should be able to tell if your initial window size is too small and adjust it accordingly. You should probably take care to do this once on the initial launch of the application, just in case the user explicitly and intentionally moves/resizes the window so it doesn't completely cover the screen -- you wouldn't want to accidentally obliterate their changes the next time you run (assuming you even save window positions).
how do i make sure that the application iam developing will look the same on other windows-systems?
iam developing now on a windows7, with .net 3.5 framework .. (VS 2008)
as an example, i have a toolbar, that i changed its rendermode to system, it looks ok on my windows7, but when i run the application on windows xp, it is different, even the onmouseover backcolor is different. ..
is there a way to make the application looks like on every windows system (talking abt xp, vista and windows 7 only), lets say like exporting the settings of all the controls with the application !? or any trick to make sure it will be always the same ?
thankss in advance
Unless you render the window yourself you're going to always have slight differences between OS'es, they all have different ways of rendering your primitive controls like text boxes, panels, etc.
Also under windows the background color of a window/control is actually (by default) tied into the theme set in windows.
So allowing people to use their own themes is a plus. You really shouldn't force a style on people unless you're theming your own application.
You would have to you get a grab on all of the colours, fonts, transperancy, etc. and use them to override every controls' Paint event/method so that they may use your values.
The only way I see fit would be by writing yourself custom controls while handling these controls appearance throught the Paint() method so that the control may use what you give it. The pain!...
As SLaks commented, you shouldn't care about such details and let the defaut user preferences take over on the native OS, because some surprises may be encountered over time as if Windows doesn't find the font, for instance, it will replace it with its default, which could lead to horrible results. That is just one example. Need others?
Our clients have fat fingers, and so do we. We take touchscreen netbooks apart to insert them into our custom hardware, and I write a software interface that shows up on the touchscreen. The problem is that it has about a 3/4" bezel over the screen, which means hitting that little red "X" becomes a challenge, especially considering reduced capacitive ability on the edges and corners.
Is there a way to make this standard close button larger? Of course in the application I can always make really nice 80x80 buttons that are perfectly usable, but there seems to be no way to override the default frame of the form. We have tried enabling Large Fonts and all the built-in accessibility features, but nothing seems to make it large enough to hit successfully.
Simply adding a toolbar button is also not much of an option. We prefer to utilize the standard look and feel of a normal Windows application.
Alternatively, should we be looking at making some sort of "kiosk mode" where we simply go fullscreen and do nothing involving the taskbar or title bar? How difficult is this to accomplish, if so?
Well, since you're setting up the hardware, I presume you're able to configure preinstalled software, including Windows. Can't you just go into Display Settings and make the title bar larger, so that the close button grows accordingly?
See MS Article about distributing windows themes: http://support.microsoft.com/kb/310514
Getting a large close button is fairly easy to do. It is hidden well since Vista, in Win7 it is Control Panel + Personalization + Window Color, Advanced appearance settings, Item = Caption buttons, change the Size. You probably won't like this much though, you'll get a rather large caption bar, lots of waste screen real estate.
Tackling this from the other end: your request is unusual. Most anybody that sets up a touch screen app wants to know how to prevent the user from closing the window. Windows Forms makes it too easy to design a bunch of forms and switch between them. That isn't much of a user interface on a regular desktop, especially not here. You can design your forms as user controls as well and switch them in and out of the main window as the user navigates through the UI. Not unlike, say, Microsoft Outlook. You can even turn your existing form into a control. Set its TopLevel property to False, FormBorderStyle to None, Visible to true.
We have a collection of C# (.NET 2.0) applications that have custom dialog windows. When the user changes the default font size and resolution etc in Windows the edges of the form lose controls (they get pushed off the visible portion of the form) typically dropping off buttons from the bottom. This is problematic for us and will cause issues across other applications using the standard look-and-feel framework we are creating around these applications.
How would you make your entire application independent from windows font changes? How would you integrate this into multiple solutions?
Or better still how can one adapt the entire application to be able to adjust itself with the Windows appearance changes?
WinForms have the AutoScaleMode property, which can be set to either Font, DPI, Inherit, or None. The default is "Font" which, in my experience, doesn't always scale things right. You might try one of the other options (maybe "None" if you don't want your form to scale at all?)
As for making the entire application able to adjust itself, look into the "Inherit" option (you still need to set something other than "Inherit" on the parent or startup form of your application, though).
You could handle the SystemEvents.UserPreferenceChanged event in the Microsoft.Win32 namespace. The UserPreferenceChangedEventArgs parameter will have a Category of UserPreferenceCategory.Window when the system font changes. I think you'll then have to trigger a manual window layout and redraw in response to this event.