I have an issue with my C# application. It's about controls on borderless form. I've created a application that works like a logging system (shows in center of the screen, has 2 textboxes, 2 comboboxes, 2 pictureboxes, form StartPosition is CenterScreen). The application works fine on almost every system, 30 - 40 people are using it, but 3 of them has a problem, that makes the app useless.
The controls are totally moved and seems little bigger than they
should be, 2 of these controls are moved even outside the form - which
makes them inaccessible.
I've tried to set the compability mode and change the screen resolution. No luck.
All of these problematic machines has Windows 7 and default .NET 3.5.1, one has 4.0. The application was targeted for .NET 3.0 (I wanted to keep it free from dependencies on machines with Vista and newer).
I'm looking for a advice from those, who had experience with this kind of problem. I would like to keep the form borderless, its essential for its design, and keep the target framework if possible. What can i do to keep this in solid ?
I'm guessing you have problems with DPI. Try increasing it on your dev machine and I bet you will see same effect. I hadn't worked with winforms for a long time, but I think you can use this article to help you out.
Related
We have a huge project in WPF .NET 4.0 which should support Windows XP SP3 and above. (hence the use of .NET 4.0) It has no problems whatsoever on Windows 7 and 8/8.1. However we're experiencing major visual issues when running on Windows XP to the point that the application is unusable.
I searched a lot and came across some similar questions such as this one but none of the suggested solutions worked for us.
Here's an screen shot taken on Windows XP SP3:
The odd thing here is that there is clone of "28" TextBlock you see in the screen shot, to the left of it. They have everything in common except their name but the left one is not rendered properly!
And here is how it really looks like (taken on a Windows 8.1 test machine):
Some pages are even worse:
When I remove AllowsTransparency from the main window, it looks like this on XP: (Note that the title bar has no problems any more)
We're really stuck and have no clues about its cause. Any help would be appreciated.
It seems this problem is related to the graphic card. In another VM with a different graphics accelerator we didn't face any major problems. In the problematic test machine, we lowered hardware acceleration to the third level and the problem is gone.
Display Properties -> Settings -> Advanced -> Troubleshoot
Although there are still some small issues with some mouse over animations and we lost the benefits cursor accelerations bring to the table, it's acceptable for us since not much is expected from Windows XP.
I have a strange problem. I have designed a windows form application in c# and .net framework 3.5. In the runtime, the form and its controls are fine in all the computers except my laptop, where the controls are not in the correct positions.
If I design the form from scratch on my laptop with correct positioning it will result in an invalid shape for other computers.
My efforts:
If I run the windows in Safe Mode the form size and control positions
are correct.
I have uninstalled the Video Driver and used default windows version but the problem still persists.
I used different frameworks like 2.0 and 4.0, and different Visual Studios versions and they all have the same problems.
Actually all the .net framework product from all the companies indicate the same issue.
My computer Settings:
Laptop 1557 Studio DELL
Graphic ATI Radeon HD 4500
When the text size is artificially increased to 125% text and controls that are rather closely placed will wrap around the form and push everything down/over. If this is something you intend to support, you'll simply have to redesign your form to handle the different enlargement levels you care to support and test those enlarged text modes in your app until you're satisfied with their appearance. It's not something you can strictly control, since increased text size is an accessibility feature.
I assume it is due to a screen resolution differences. I believe that the actual location of the controls is identical in both cases, in one the screen is "larger" and therefor your controls appear in a different position on the screen.
try Designing forms to work on different resolutions and aspect ratios on Windows CE
Another thing you can (and should) do is work with WPF, which is the new way to build user interfaces for windows.
I've found a workaround just now.
In the display settings of Windows 7 I have changed the Text size from 125% to 100%. Everything is smaller but in accurate positions and sizes.
Still wondering how it works!!
I have a .Net application that was originally created in Visual Studio Professional 2005, using the .Net 2.0 framework.
Recently, I have opened the project in Visual C# Express 2010, made some minor changes, and built it using .Net framework 4.0.
Everything works like a charm except for one quite annoying part. When I am running the application on a HP EliteBook 8740w, with a 1920x1200 screen, a group of GUI controls get shuffled around, so that they land on top of eachother. This error does not show up when running on my Windows 7 64 bit workstation with external display of 1900x1080 resolution. Neither does it show when running on a Windows XP laptop with 1024x768 resolution.
I have tried to connect a 1600x1200 external display to the EliteBook, but the error shows up there also.
The controls that get messed up are a set of comboboxes, numericUpAndDowns, and labels, laid out in a table layout container, that in turn is placed on a tab page in a tab page control.
I have tried creating a new tab page control and table layout container from scratch, and then moving the comboboxes etc into the new table layout container, but the error prevails.
I would really appreciate some help in this matter, because I don't know what else to try. I am starting to suspect that there is something wrong with the graphics on the EliteBook, but, then again, everything else renders nicely on its screen.
Thanks,
Fredrik Israelsson
--- Edit ---
Thank you for your quick answers. Before I had a chance to look at them, I think I solved the problem by myself. Stumbled upon a thread about why Visual Studio automatically changes sizes of controls although one has set anchor and dock properties to None. One of the answers mentioned the AutoScaleMode property. I changed AutoScaleMode from Font to None on my main application Window, and no the GUI renders nicely on all my computers.
Thanks again!
/Fredrik Israelsson
I suspect that this is because the two machines have different DPI settings. This is always a pain with Windows Forms.
Here are a few links that might help.
http://msdn.microsoft.com/en-us/library/ms229605.aspx
http://www.sellsbrothers.com/writing/winformsAutoScaling.htm
It could be related to Hardware Acceleration. Is your application a WinForms or a WPF one?
I have faced really odd behaviors when using VS2010 on Win7 64 bit only because it was trying to use Hardware Acceleration when I built the app.
Improving Performance by Changing the Visual Experience
You might have a problem with Hardware Acceleration in VS2010. I had an issue with rendering applications built using WPF because of this.
Give it a try: http://blogs.msdn.com/b/zainnab/archive/2010/06/22/improving-performance-by-changing-the-visual-experience-vstipenv0017.aspx
And if that doesn't fix your issue, go to your video card settings (nvidia or amd catalyst) and do a "reset settings" on the computer where the app doesn't correctly paint itself. Then try again.
I have a windows forms app built with .NET 3.5 and a relatively old version of Infragistics controls. It turns out some of the forms/controls look quite poor when viewed in Windows7 and Medium or Large Fonts. What are my options to resolve this? I have some tens of forms and would like a short-term solution rather than a rewrite, as the app will be migrated to WPF or Silverlight in the medium term.
Is there a switch I can 'turn off' medium/large fonts for the app as an immediate fix?
What general principles need to be followed for winforms apps to render nicely with medium/large fonts turned on?
So far the main things I've found I needed to do are:
Change forms/controls so AutoScaleMode is set to Font
Change any forms with programmatic resizing so they're dependent on other controls' size or position, rather than hard-coded numbers that are right if fonts are set to normal size.
Other than that things mostly work as desired. Mostly. Still the odd odd thing to track down.
+1 on the AutoScaleMode suggestion.
I redesigned all the forms into TableLayoutPanels (it took ages) and got set all my Labels to AutoResize = True. TableLayouts take most of the pain away. Scaling and alignment are a breeze, although they are quite slow compared to say WPF.
I work on a large C# application (approximately 450,000 lines of code), we constantly have problems with desktop heap and GDI handle leaks. WPF solves these issues, but I don't know what is the best way to upgrade (I expect this is going to take a long time). The application has only a few forms but these can contain many different sets of user-controls which are determined programatically.
This is an internal company app so our release cycles are very short (typically 3 week release cycle).
Is there some gradual upgrade path or do we have to take the hit in one massive effort?
You can start by creating a WPF host.
Then you can use the <WindowsFormHost/> control to host your current application. Then, I suggest creating a library of your new controls in WPF. One at a time, you can create the controls (I suggest making them custom controls, not usercontrols). Within the style for each control, you can start with using the <ElementHost/> control to include the "old" windows forms control. Then you can take your time to refactor and recreate each control as complete WPF.
I think it will still take an initial effort to create your control wrappers and design a WPF host for the application. I am not sure the size of the application and or the complexity of the user controls, so I'm not sure how much effort that would be for you. Relatively speaking, it is significantly less effort and much faster to get you application up and running in WPF this way.
I wouldn't just do that and forget about it though, as you may run into issues with controls overlaying each other (Windows forms does not play well with WPF, especially with transparencies and other visuals)
Please update us on the status of this project, or provide more technical information if you would like more specific guidance. Thanks :)
Do you use a lot of User controls for the pieces? WPF can host winform controls, so you could piecewise bring in parts into the main form.
WPF allows you to embed windows forms user controls into a WPF application, which may help you make the transition in smaller steps.
Take a look at the WindowsFormsHost class in the WPF documentation.
I assume that you are not just looing for an ElementHost to put your vast Winforms app. That is anyway not a real porting to WPF.
Consider the answers on this Thread What are the bigger hurdles to overcome migrating from Winforms to WPF?, It will be very helpfull.
There is a very interesting white paper on migrating a .NET 2.0 winform application toward WPF, see Evolving toward a .NET 3.5 application
Paper abstract:
In this paper, I’m going to outline some of the thought processes, decisions and issues we had to face when evolving a Microsoft .NET application from 1.x/2.x to 3.x. I’ll look at how we helped our client to adopt the new technology, and yet still maintained a release schedule acceptable to the business.