I'd like to let forms and their controls to automatically adapt to various screentypes, screen sizes and resolutions (1024x768, 800x600, etc.). The goal is that a form occupies exactly the available screen space for a maximized window with all controls visible as it was designed for the original screen-size and -resolution. I.e. that it should shrink for smaller screens and enlarge for bigger ones.I tried out a method given here as answer to a similar question (which I cannot find any more here on EE). It took the original screen resolution and determined the actual screen resolution and calculated a factor (y / yOld) with which to size the form/control:
For Each iControl In Me.Controls
.Height = .Height * y / yOld
Although this works the result is not satisfyingly: From a higher resolution (1024x768) to a lower resolution (800x600) the form is only a bit too big (450 pixels, twips or what ever is the unit). From 1024x768 to 640x480 the form is much too big. From 1024x768 to 2048x1024 it is much too small. I did the experiments for 1024x768 to 800x600 on different machines. The 1024x768 was a normal 19" CRT whereas the 800x600 was the LCD-screen of my laptop. I guess that not taking the physical pixel size of the different screens into account is one of perhaps many reasons why this method doesn't work. I determined the GetDeviceCaps(hDCcaps, LOGPIXELSX) and
GetDeviceCaps(hDCcaps, LOGPIXELSY)only to find them to be the same on CRTs and LCDs. Only GetDeviceCaps(hDCcaps, VERTSIZE)and
GetDeviceCaps(hDCcaps, HORZSIZE) delievered different values for the different screen types and resolutions.
I'm sure that the task can be accomplished 'cause it is built in into Visual Basic. Any hint will be very much appreciated.