Windows forms - inactive highlight color - c#

I have a ListView control with OwnerDraw = true.
Sometimes my control might not be focused, but have the items selected. Which color should I use to render the selection bar?
I couldn't find any guidelines for that, however, it seems that the ordinary ListView uses the SystemColors.Control color for that (see the picture).
Could I rely on that or would that be incorrect for some cases?

SystemColors.Control is the correct color to use. Unfortunately there is not a predefined Color in SystemColors for an inactive item that makes it obvious, but it is reliable.
The only time you cannot rely on SystemColors is when a user makes explicit changes to the theme color settings in Windows. However, you should not care about that because its an explicit user choice, and you should not interfere with user choices.
As for guidelines, the Windows UX Guidelines do not explicitly state the appropriate color to use for inactive items, but it does stress choosing colors consistant with the operating system that provide good contrast and easy readability.
In applications that I'm not too worried about the look and feel for, I use default system colors, but if I am theming my own application (eg. to look like Visual Studio for example), I avoid system colors altogether and use web colors instead.
Hope this helped.

Related

C# Winform: Remove the border from a standard button?

Is it possible to remove the border of a standard C# Button ? I know that I could set the FlatStyle property to Flat and customize the FlatAppearance property to hide the border but I would prefer to use the Standard property to ensure that the control appears under all operating systems like a default Button. Did you have any suggestions how I can solve this issue? I am working with a Windows Forms Application.
You could use an image and make it clickable, that is one way to avoid the borders, but there are several options. Good luck!
If you are using windows forms and trying to implement Flat UI, Material UI, Metro-Looking controls, you're in hell. It is has limited properties for customizations unless you know how to work with Graphics and Animation. You'll have to use imagebox or picture box and dynamically change its image on different events.
I'll suggest WPF or Windows Presentation Foundation for a more customizable User Interface.

Custom XAML styles for night mode

I have a XAML app (specifically a Windows 8 XAML app) that I want to add a night-reading mode for. This will be a setting a user can switch, and it will change the theme colors to be white on black, instead of my standard black on white.
My question is, how can I do this? I'd like to do it actively (meaning, the moment the user switches, I show the new version, and not have to make them restart them app).
I'm still fairly new to XAML, so I don't know if I'm overlooking something. Currently, I'm routing all my styles to go through staticresources in my themes file.
Thanks!
What you're looking for is a theme. Basically it's a set of globally available resources that you can swap out as a set. See here for an example.
Edit: I guess you can't change it without restarting: http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/f91a11d6-6e56-4978-8acd-21ae9f3c3a6e/

Change AutoScaleMode, or from a FlowLayoutPanel to a TableLayoutPanel?

The controls on my FlowLayoutPanel look perfect on my machine, but are all goofed up (that's a technical phrase for "misaligned") on another's machine. Mine is XP, his is Windows 7, but I don't know if that's the reason for the mismatch or whether its screen resolution or something else.
I did notice that the FlowLayoutPanel is extremely touchy/finnicky - even changing the BorderStyle at design time can cause the controls to rearrange so that they no longer align with each other.
I saw on a StackOverflow article a suggestion to change the (form's) AutoScaleMode property, but the poster didn't specify to what (or from what; I guess the default property value is "Font").
Would switching from FlowLayoutPanel to TableLayoutPanel provide a more consistent visual experience between DPI settings or whatever the issue is?
BTW: WPF is not an option for us at this time.

c# how can i make sure that my application will look the same on other systems?

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?

Changing default font in Windows messes up my Win Forms buttons

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.

Categories