Form resizing

HMG en Español

Moderator: Rathinagiri

Post Reply
User avatar
vagblad
Posts: 160
Joined: Tue Jun 18, 2013 12:18 pm
DBs Used: MySQL,DBF
Location: Thessaloniki, Greece

Form resizing

Post by vagblad »

Hi all,

Nikos(quartz56) and myself have decided to redesign all of our forms to a more "modern" look. So we've made some picks about standard colors we are going to use and what kind of controls etc.

Anyway since we will be re-designing those we thought to ask opinions on how you guys tackle the problem of resizing for different screen resolutions. To see if someone has a better idea or method that we could also use in our forms. To start with i'll tell you a bit on how we've been doing it so far:

1st step: We design all of our forms in a standard resolution: for example 1920x1040(windows taskbar is 40 pixels tall), so the program's windows fill the entire screen except the windows' taskbar.
2nd step: We do a small calculation at the start of each program, depending on the resolution it was designed for. For example:

Code: Select all

Public appWidth  := 1920 //the width the form was designed for
Public appHeight := 1080 //the height the form was designed for
Public corWidth   := GetDesktopWidth() / appWidth
Public corHeight  := GetDesktopHeight() / appHeight
The above gives us a ratio that we use later in our controls(step 3). Let's just say we design a form for the 1920x1080 resolution. On a HD monitor of 1920x1080 resolution the corWidth and the corHeight would be 1. For sake of simplicity i am not calculating the height of the taskbar here. Now on a 1440x990 monitor the corWidth would be 0,75 and the corHeight would be 0,92.
3rd step: on each define of every control we multiply the row,col,width and height with the above ratios. For example:

Code: Select all

DEFINE LABEL LblOne
ROW 10 * corHeight
COL   20 * corWidth
WIDTH  1920 * corWidth
HEIGHT 40 * corHeight
VALUE WEB_MAINFRM[1]
FONTNAME mainFont
FONTSIZE mainFontSize
BACKCOLOR HeaderBackColor
FONTCOLOR HeaderFontColor
CENTERALIGN .T.
VCENTERALIGN .T.
END LABEL
So the above on a full HD monitor would give:
Row=10
Col=20
Width=1920
Height=40
the same values on a 1440x990(a lot of laptops have those)monitor would give:
Row=9.2
Col=15
Width=1440
Height=36.8

It works fine. The big problem is that those forms are not editable in the IDE(make the IDE crash) which takes away so much of our developing time because we have to do everything by typing the forms. (Because of my heavy Visual Studio background and Unreal Engine background - this irritates me very very much. When you've worked with drag n drop - autoresizing IDEs you really cant go back to what we have in harbour in general.)

So excuse my little rant, we would be very interested to know how you guys handle this problem or if you dont handle it all. Maybe someone has a better idea of doing this or we are missing something. Again thanks for all the help everyone has given us so far and we are open for a good discussion.
Vagelis Prodromidis
Email: vagblad@gmail.com, Skype: vagblad
User avatar
serge_girard
Posts: 3167
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Form resizing

Post by serge_girard »

Vagelis and Nikos,

I did the same (for some projects) and indeed the IDE doesn't work... But for me it absolutely no problem because I don't use it. Even never did (only once or twice)...

Many of my forms are very very complex and when integrated in my PRG is easier (for me) to edit etc.
Resizing remains still a major problem: some controls refuses to resize, screen freezes, programs hangs...
Very frustrating!
I think it is the cause of our old-Clipper-style Row/Col approach instead of browser-like floating controls...?

Serge
There's nothing you can do that can't be done...
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Form resizing

Post by AUGE_OHR »

try this

Code: Select all

#include "HMG.CH"
MEMVAR _HMG_SYSDATA
PROCEDURE MAIN()
LOCAL i, iMax
   IF !IsWindowDefined( EMail_1 )
      Load Window EMail_1

      msgdebug( GetControls( "EMail_1" ) )

      ON KEY ESCAPE OF EMail_1 ACTION EMail_1.Release
      CENTER WINDOW EMail_1
      Activate Window EMail_1
   ENDIF
RETURN

Code: Select all

FUNCTION GetControls( cForm )                   // like Childlist
LOCAL nHWnd     := GetFormHandle( cForm )
LOCAL aControls := {}                           // List of controls {ControlType, ControlName}
   AEVAL( _HMG_SYSDATA[ 4 ], { | hCtrWnd, nPos | IF( hCtrWnd == nHWnd,;
          AADD( aControls, { _HMG_SYSDATA[ 1, nPos ], _HMG_SYSDATA[ 2, nPos ] } ), Nil ) } )
RETURN aControls
you will get Array of all Controls of that Form.
now you can use Array for "resize" and "Zoom" if User use "Scale" <> 100 %

---

use GetControls() at INIT and "hold" Array (Field-wide STATIC) with "Original" Pos / Size
later when "resize" use "Original" and calculate new Pos / Size "Factor"

when have "bigger" Control your Font might be to small.
you can use same "Factor" on Font, Windows will use "nearest" matching
have fun
Jimmy
User avatar
serge_girard
Posts: 3167
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Form resizing

Post by serge_girard »

Thanks Jimmy, I will in a few days!

Serge
There's nothing you can do that can't be done...
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Form resizing

Post by AUGE_OHR »

hi,

here a Sample with *.FMG how to "resize"
FMGSIZE.ZIP
(2.77 KiB) Downloaded 101 times
it is "simple" and does not use "ControlType" ( if a special Control make Problem )
it will not "resize" Picture of IMAGE but IMAGE itself
DoInitEmail() and DoSizeEmail() are called from *.FMG so have a look at Events of Form

p.s. include MiniGUI Version ( #ifdef __HMG__ )
have fun
Jimmy
User avatar
vagblad
Posts: 160
Joined: Tue Jun 18, 2013 12:18 pm
DBs Used: MySQL,DBF
Location: Thessaloniki, Greece

Re: Form resizing

Post by vagblad »

Thanks both to Serge and Jimmy for your responses.

@Jimmy
Your example works perfectly. I integrated it already into a really small app we have and it works just fine. I will have to try it in our more complex apps and see how it does but i really like it. Thank you very much for this.

If i find anything out of the ordinary or if i make any improvement i will post it. Thank you once more.
Vagelis Prodromidis
Email: vagblad@gmail.com, Skype: vagblad
Post Reply