How should text be handled in responsive design? - responsive-design

For websites and applications alike
Should you let text take a certain % of width?
Base it off the user's screen resolution?
Based on window width/height?


How to make .net winform application resolution friendly

I am trying to make my winforms application made with C#.Net, resolution friendly. I tried to do so in programming way by just adjusting a size of all control according to ratio of screen resolution. But it doesn't give perfect resolution in every forms.
I tried to do so in programming way by just adjusting a size of all control according to ratio of screen resolution.
I think you mix two things.
To adjust your form to the Windows DPI settings (making your controls smaller or larger), you don't need to do anything, this is performed automatically. Just change the DPI settings and check the effect.
To adapt your forms to the actual resolution just make it sure that your forms are either resizable (and the controls are docked) or the non-resizable dialogs will show at least some scrollbars if the resolution is too small. Anchors can be a pain especially if you have derived forms or user controls but you can always use docking.
You could also use certain resolution breakpoints where the size of the anchors change. For example at 1024x768 1600x900 1920x1080 the controls all change to a set size, inbetween they just take the closest resolution breakpoint to them (1200x900 would take 1024x768).
Often I've had problems trying to make them completely dynamic and I've been handling it like this. Upon resize just call a function that checks the current size and if needed resizes all the anchors.

Sizing Dialog Fonts — Using GetStockObject(SYSTEM_FONT)

I am an experienced developer who is new to WPF. I appreciate all the flexibility of WPF components, but this flexibility is causing me a little trouble.
Specifically, I want to create a dialog box. When I do this in C++/MFC or C#/Win Forms, my text boxes and the text box fonts are automatically the right size for system dialogs.
But in WPF, I have to hard code both the text box height and the font size. This apparently means:
I have to guess what font size will best match the user's system font settings for dialog boxes, and my fonts will not adjust to each users' system settings.
Even worse, I have to also guess at the best text box size for the current font. This has always been automatic on other platforms.
I'm just wondering how seasoned WPF developers are handling text box and font sizes within a dialog box.
In other words, I would like my text boxes to use the font returned by the Windows API calls GetStockObject(SYSTEM_FONT). Is this directly supported by WPF?
I'm having a hard time understanding your question, mainly because WPF works better than either MFC or Winforms for the scenarios you seem to be asking about.
I have to guess what font size will best match the user's system font settings for dialog boxes, and my fonts will not adjust to each users' system settings.
WPF uses device-independent metrics. In particular, WPF pixels are always 96 per nominal inch. Of course, depending on user settings, the actual size of a WPF "inch" may be more or less than an real inch. But those are the settings under control of the user, specifically designed to do such scaling.
One big advantage of WPF's model is that unlike Winforms, the relative layout of everything stays the same regardless of scaling. In Winforms, different things scale differently, causing line-breaks to happen in different places, text to be truncated, etc.
Even worse, I have to also guess at the best text box size for the current font. This has always been automatic on other platforms.
The WPF Window class has a SizeToContent property. If you set this to Both, the window will resize itself to exactly contain whatever content you put in it. Is this not what you want?
If the above does not address your specific scenario, please help us understand your scenario by providing a good, minimal, complete code example that shows clearly the problem you are having, with a precise explanation of what that code does and how that's different from what you want.
You can set the size of your Controls to "Auto" like this: <TextBlock Heigh="Auto" Text="Foobar"/>, the control's height will then adapt to the content.
This also work for any Height or Width properties on any controls.
Hope I helped ;)

Changing size of Notify Icon

As we know when we use notifyicon control in c# and place it in systemtray and it is displayed, windows overrides its size and make it 16*16 so can we somehow change its size? make it little bigger like system "date and time" display or like "input method type" in windows 8. I want to display certain text there.
Thanks in adv.
The system draws the icon, and it decides what size it is. For what it is worth, notification icons are the system's small icon size. So in fact you should not assume that they will be 16px icons. For font scalings larger than 100% the small icon size will be larger than 16px.
At the Win32 level, the application supplies an HICON, and the system draws that. If it needs to resize it, it will. You cannot custom draw in the notification area.
Imagine if applications could custom draw in the notification area? All it would take would be for a couple of applications to decide that they were so awesomely important that they had to custom draw large amounts of information. And then there'd be no room left for the rest of the taskbar.
So, the bottom line here is that you will need to find some other UI approach to solve your problem.

Keep form and controls proportion deployng a c# application for any screen size

I know this is an "already heard" problem: I have searched a lot but I did not find anything that cleared my mind.
I am developing a c# application with a GUI containing some controls like buttons (made with images) and text.
I developed it setting the main form size to 800x600 but now I need the application to work also on a 1920x1080 screen.
Two problems:
If I position a button near the top-right corner of the main form and set AnchorStyles to Top-Right, when I switch to the big screen, the button is (in proportion) much more close to top-left corner than in the little screen (because the anchor keeps the distance from the border). Is there a way to set a proportional distance from the border?
How can I scale the dimensions of the controls proportionally to the screen size? Shall I use AutoScaleMode like suggested here?
There is a way to add a capability to a form at design time - the ToolTip control does it, that makes properties available to every control on a form. These are called "Extender Providers"
You would want to look at the controls, and cache their sizes and fonts at design time, and the size of the form.
The provider would hang off the form.SizeChanged event at run time. When the size changes, you use the new and original (design time) sizes of the form to calculate and X and Y ratio. You then go through each control and use it's design time size and the ratios to determine its new size and font size. This can get flaky if you allow the user to select sizes that are not the same aspect ratio as your original.
Anyway, that is how it was done in Delphi, and everyone knows if you can do it in Delphi, you can do it in C# :)

Windows Forms: Auto Scale Application

I have a WinForms Application that was designed to support Full HD resolutions (so 1920x1080). Now this App is also supposed to run on a lower resolution: 1600x900.
Is there a way to let the application auto scale itself to fit the lower resolution? Like you would just downscale an image, basically resizing and relocating each control.
My current forms and panels have set their size to 1900x1080, so they just extend out of the screen on the lower resolution.
I have played around with AutoScaleModes and AutoSize, but the best I could get were Scrollbars so that you at least navigate through the forms. Is such a thing as downscaling an application even possible (retaining dimensions/ relative sizes and positions of the controls)?
Thanks in advance for any inputs on this!
If your main form starts in a maximized mode, it will adjust its size automagically.
But (and this is a huge "but" according to your question): the inner controls won't be scaled as you would see on a smartphone. WinForm is not "vector based" as WPF. If you have a fully loaded form in 1920x1080, when the main form is sized down, the controls won't fit and you will get scrollbars.
So the answer is: No.
The property you are looking for is called Dock, it's a property of the controls.
This basically tells the control how to fill the available space.
Creating a resolution independent application is not a simple logic. Everything in the window should be resize as per the selected resolution. Not only controls' size you have to change the font size also as per the changes. Here is the example how to create a resolution independent form using C# code. Another way is use DevExpress Tool. This tool provides Layout Countrol Container. You can place each control in separate layout item and assign the minimum and maximum size of control.