How do you create a DPI-aware program?

Windows specific questions.
square1
Posts: 97
Joined: Nov 12, 2007 2:27

How do you create a DPI-aware program?

Postby square1 » Dec 27, 2012 23:45

Hi, have you had the problem of guis being displayed differently across various versions of Windows and what did you do about it?

I have been looking at
http://msdn.microsoft.com/en-us/library ... e_function

It seems that the setprocessdpiaware function is not supported in windows.bi. Are there any workarounds in FB other than having the user adjust the settings individually?

To disable DPI virtualization for a single application, right-click the name of the application executable file, click Properties, click the Compatibility tab, and then select the box labeled Disable display scaling on high DPI settings.


Thanks in advance
TESLACOIL
Posts: 1769
Joined: Jun 20, 2010 16:04
Location: UK
Contact:

Re: How do you create a DPI-aware program?

Postby TESLACOIL » Dec 28, 2012 2:01

The UI issue is much larger than any single technical aspect. Its not possible to control the 'end user environment'. You have to pitch in ballpark.

You might find this useful to watch
http://www.youtube.com/watch?v=XGxqY1KRlOA

Windows User Experience Interaction Guidelines ( UXGuide.pdf 50megs worth )
http://msdn.microsoft.com/en-us/library/aa511258.aspx

There are now 4 mainstream windows OS. XP and Win7 make up the bulk with Vista and Win8 covering the rest. Mac is another niche and then you have Linux. People use Desktops, Big laptops and Netbooks. There are a dozen common screen resolution's and four common aspect ratios. What works on a 24inch monitor isn't necessarily going to work on a 10inch net book screen. Actual physical size is another tangible slider that effects the end user experience.

You have to really sit down and figure out what you want your UI to achieve. What is your end user expecting ? and also what do they actually need ?

Is it a lean forward experience or a lean back experience ?

If you need to create a high quality UI then you need to have ready access to half a dozen different computers running different OS. There is no substitute for real world testing. If you plan to write quality software for a the diverse ecosystem that's out there you have to invest in the appropriate array of HW & SW for testing.

No easy outs that's for sure. researching tweaking testing researching tweaking testing....

You will no doubt find that creating a DPI aware program causes as many problems as it solves. Is DPI awareness a 'critically essential' feature ? If not then UI focused energies are probably best invested elsewhere.



In the words of Alvin Toffler " to what problem is DPI awareness the solution ? "
square1
Posts: 97
Joined: Nov 12, 2007 2:27

Re: How do you create a DPI-aware program?

Postby square1 » Dec 28, 2012 8:09

Thanks for your comments.

My situation is that I have got a simple gui where a number of settings can be adjusted in comboboxes, listboxes and trackbars. The users this is aimed at aren't particularly IT literate - I wouldn't expect them to find their way around the control panel or use the right mouse button much.

The gui doesn't need to look flash for every single configuration but the text shouldn't be scaled so that it is clipped and not visible anymore. All I would like to do is to prevent the OS scaling the screen text in high DPI settings, which I hoped could be achieved by declaring the app dpi aware.

According to MSDN:

To declare your application to be DPI-aware, add <dpiAware> to the application manifest. Here is an example of how to use the

<dpiAware> element in an application manifest.

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>



I am not familiar with application manifests at all, is this something that can be done with freebasic and are there any examples available?
TJF
Posts: 3601
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: How do you create a DPI-aware program?

Postby TJF » Dec 28, 2012 9:47

I use GTK+ toolkit for that purpose, on windows and on LINUX (single source).

Instaed of fixed positions GTK+ widgets are usually placed relative (as in QT toolkit). A window and all its context can grow or shrink to match the monitor size (or the users needs). When a window may get too small for all context you can use scrolled areas. The user can specify his settings for fonts, colors, styles, ... in a global file for all GTK+ UIs on his box.

GTK+ headers are available in FB (current fbc-0.24.0 includes GTK+ 2.24 and 3.4). Find examples in your folder

    ...\FreeBasic\examples\libraries\Gtk...
or search the forum for GTK.
TESLACOIL
Posts: 1769
Joined: Jun 20, 2010 16:04
Location: UK
Contact:

Re: How do you create a DPI-aware program?

Postby TESLACOIL » Dec 28, 2012 9:48

Perhaps if you just opt for a large fixed font & fixed sized window. You cant go wrong with that.

Create an 800x600 window or a 1024x768 window and you should be ok, then focus your efforts on friendly point and click layout.

Display resolution
http://en.wikipedia.org/wiki/Display_resolution

While its tempting to reach for a fancy technical solution if that's not whats required then its better to KISS (keep it simple stupid) An end user with low IT skills is often grateful when presented with large clear text and an uncluttered window. Its better to experiment in your own time than run experiments on your end users :-p...aint that a 21st century truth lol


Don't give an IT naive person a full screen interface, they will panic and feel loss of control. They will feel much safer if they can see their desktop in the background. ....dont take control of my desktop or take over all my screen acreage unless its 100% essential AND expected OR i explicitly ask you to do so.

Watch this ! How Real People Will Use Windows 8 The closing words priceless ! loool
http://www.youtube.com/watch?v=v4boTbv9_nU

square1 , because of your target audience i cant recommend using DPI aware over fixed windows and fonts, if the 'dpi thang' goes wrong they wont be able to fix it and as you are currently unfamiliar with 'all things dpi' the chances of it going wrong are greatly increased...all depends how much effort you are willing to invest & how important learning how to code DPI aware apps is to you.
Zippy
Posts: 1295
Joined: Feb 10, 2006 18:05

Re: How do you create a DPI-aware program?

Postby Zippy » Dec 28, 2012 20:52

@square1

I can show how to create the manifest and use it [compile it] from fb.
However I cannot test this nor can I help debug unless it's very simple.

=====

Replace each instance of myapp in all code/instructions below
with the file name (minus extension) of your final executable.

Create this file, name it myapp.rc [or prepend this to an existing .rc]
#define MANIFEST_RESOURCE_ID 1
MANIFEST_RESOURCE_ID RT_MANIFEST "myapp.exe.manifest"


Create this file, name it myapp.exe.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>


Both of the files above must be in the same dir as your .bas source.
Compile using (you may need explicit path to fbc, and your other switches):
fbc -s gui myapp.bas myapp.rc


=====

In theory the .rc and .manifest files, once compiled, do not need to
stay with the executable.

Perhaps a real Windows Expert will help you if you need further assistance.
I have only limited experience with manifests, none with dpi awareness.
square1
Posts: 97
Joined: Nov 12, 2007 2:27

Re: How do you create a DPI-aware program?

Postby square1 » Dec 29, 2012 12:06

Thanks for the replies, I'll give Zippy's suggestion a shot tomorrow and see how that goes. I don't really want to learn how to make a truly dpi aware program, but rather to declare it as such so that Windows 7 stops messing up the layout.

As a longer term solution, using GTK+ looks interesting, but I haven't had any success with the examples. They compile (Windows XP, FBC 0.24), but when I try to run them, a "missing component error" comes up, saying it can't find "(null).dll".
Any ideas what to do about that?

Cheers
TJF
Posts: 3601
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: How do you create a DPI-aware program?

Postby TJF » Dec 29, 2012 17:46

square1 wrote:They compile (Windows XP, FBC 0.24), but when I try to run them, a "missing component error" comes up, saying it can't find "(null).dll".
Any ideas what to do about that?

Post the output when executing the binary from a command line prompt. Which GTK+ version do you use?
dkl
Site Admin
Posts: 3212
Joined: Jul 28, 2005 14:45
Location: Germany

Re: How do you create a DPI-aware program?

Postby dkl » Dec 29, 2012 18:14

The GTK DLL import libraries included in FB 0.24 are broken, hence the (null).dll error. They must be removed/replaced unfortunately... (for example with those from the all-in-one bundle available from the gtk.org win32 download page)
TJF
Posts: 3601
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: How do you create a DPI-aware program?

Postby TJF » Dec 29, 2012 19:54

square1
Posts: 97
Joined: Nov 12, 2007 2:27

Re: How do you create a DPI-aware program?

Postby square1 » Jan 03, 2013 9:40

Well, the mainfest file didn't cause any problems, but didn't make any noticeable difference either. My solution was expanding the gui layout a bit and setting a true type font, that's good enough for me.

Thanks for your help and happy New Year

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 1 guest