Page 1 of 2

Relative coordinates of Controls

PostPosted: Wed May 22, 2024 4:29 am
by nageswaragunupudi
It is now possible to specify coordinates (i.e., nTop, nLeft, nWidth, nHeight ) of a control relative to the size of the parent window/dialog. If the parent window/dialog is resized, the controls also will be moved/resized depending on the way the relative coordinates are specified.

When the controls are resized, the fonts also are resized proportionately.

Sample:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oFont, aBtn[ 3 ]

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 500,400 PIXEL TRUEPIXEL RESIZABLE ;
      FONT oFont TITLE "Relative coordinaes"

   @ 40,40 BTNBMP aBtn[ 1 ] FILE "..\bitmaps\pngs\image8.png" ;
      SIZE -40,60 PIXEL OF oDlg 2007 CENTER GDIP

   @ 250,40 BTNBMP aBtn[ 2 ] FILE "..\bitmaps\pngs\2.png" ;
      SIZE 150,120 RELATIVE PIXEL OF oDlg 2007 GDIP

   @ -0.4,-0.5 BTNBMP aBtn[ 3 ] PROMPT "Note Book" FILE "..\bitmaps\pngs\image7.png" ;
      SIZE 0.35, 0.35 PIXEL OF oDlg 2007 GDIP

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil


Image

To start with, this feature is now implemented for TBtnBmp and is being extended to other controls

Sample.2:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oFont, oBrw, aBtn[ 3 ]

   USE CUSTOMER NEW SHARED

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 500,400 PIXEL TRUEPIXEL RESIZABLE ;
      FONT oFont TITLE "Relative coordinaes"

   @ 20,40 XBROWSE oBrw SIZE -40,-120 PIXEL OF oDlg ;
      DATASOURCE "CUSTOMER" AUTOCOLS CELL LINES NOBORDER
   oBrw:CreateFromCode()

   @ -80,40 BTNBMP aBtn[ 1 ] PROMPT "LEFT"    SIZE 100,40 PIXEL OF oDlg FLAT GDIP ;
      COLOR CLR_WHITE,CLR_GREEN

   @ -80,0.4 BTNBMP aBtn[ 1 ] PROMPT "CENTER" SIZE 100,40 PIXEL OF oDlg FLAT GDIP ;
      COLOR CLR_WHITE,CLR_GREEN

   @ -80,-140 BTNBMP aBtn[ 1 ] PROMPT "RIGHT" SIZE 100,40 PIXEL OF oDlg FLAT GDIP ;
      COLOR CLR_WHITE,CLR_GREEN

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil


Image

Re: Relative coordinates of Controls

PostPosted: Wed May 22, 2024 5:18 am
by Carles
Rao,

Awesome, congratulations

C.

Re: Relative coordinates of Controls

PostPosted: Wed May 22, 2024 6:27 am
by FiveWiDi
Carles wrote:Rao,

Awesome, congratulations

C.


+1
:D

Re: Relative coordinates of Controls

PostPosted: Wed May 22, 2024 12:05 pm
by csincuir
Mr. Rao, +100
Excelente!

Re: Relative coordinates of Controls

PostPosted: Wed May 22, 2024 12:15 pm
by Marc Venken
+ 1
Very usefull !!

Re: Relative coordinates of Controls

PostPosted: Wed May 22, 2024 12:16 pm
by cmsoft
Excelente!!! Es una funcionalidad muy esperada y necesaria
Muchas gracias Mr. Rao

Re: Relative coordinates of Controls

PostPosted: Wed May 22, 2024 12:58 pm
by leandro
Excelente Mr. Rao :D :D :D

Re: Relative coordinates of Controls

PostPosted: Wed May 22, 2024 1:29 pm
by Horizon
+1
Waiting other controls. :D

Re: Relative coordinates of Controls

PostPosted: Wed May 22, 2024 2:43 pm
by Armando
Mr. Rao:

Excelent job, as usual.

Regards

Re: Relative coordinates of Controls

PostPosted: Wed May 22, 2024 3:54 pm
by karinha
Master Rao, in Resolution: 1024 x 768, the buttons disappear.

Maestro Rao, en Resolución: 1024 x 768, los botones desaparecen.

Maestro Rao, ¿es posible controlar VÍA la resolución de pantalla (vídeo) elegida por el usuario?

Master Rao, is it possible to control VIA the screen resolution (video) chosen by the user?

Code: Select all  Expand view

// C:\FWH\SAMPLES\RAORESI2.PRG

#include "FiveWin.ch"
#include "common.ch"
#include "xbrowse.ch"

STATIC lMaximized := .T.   // Mister Rao, pls!

FUNCTION Main()

   LOCAL oDlg, oFont, oBrw, aBtn[ 3 ], nHMsg, oSaida
   LOCAL cMsgBar := 'Puedes cambiar de tamaño o maximizar...'

   USE CUSTOMER NEW SHARED

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 16

   DEFINE DIALOG oDlg SIZE 500, 400 PIXEL TRUEPIXEL RESIZABLE ;
      FONT oFont TITLE "Relative coordinaes"

   @ 20, 40 XBROWSE oBrw SIZE - 40, - 120 PIXEL OF oDlg ;
      DATASOURCE "CUSTOMER" AUTOCOLS CELL LINES NOBORDER

   oBrw:CreateFromCode()

   @ - 80, 40 BTNBMP aBtn[ 1 ] PROMPT "LEFT"    SIZE 100, 40 PIXEL OF oDlg  ;
      FLAT GDIP COLOR CLR_WHITE, CLR_GREEN

   @ - 80, 0.4 BTNBMP aBtn[ 1 ] PROMPT "CENTER" SIZE 100, 40 PIXEL OF oDlg  ;
      FLAT GDIP COLOR CLR_WHITE, CLR_GREEN

   @ - 80, - 140 BTNBMP aBtn[ 1 ] PROMPT "RIGHT" SIZE 100, 40 PIXEL OF oDlg ;
      FLAT GDIP COLOR CLR_WHITE, CLR_GREEN

   @  +600, 650 BTNBMP aBtn[ 1 ] PROMPT "BIEN!" SIZE 100, 40 PIXEL OF oDlg ;
      FLAT GDIP COLOR CLR_WHITE, CLR_GREEN

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( nHMsg := nSetMsgBar( oDlg, cMsgBar ), ;
                If( lMaximized, oDlg:Maximize(), ) )

   RELEASE FONT oFont

RETURN NIL

FUNCTION nSetMsgBar( oDlg, cMsgBar )

   SET MESSAGE OF oDlg  TO cMsgBar   NOINSET  CENTERED

RETURN 024 //nº a guardar en la variable  nHMsg

// FIN / END
 


Regards, saludos.

Re: Relative coordinates of Controls

PostPosted: Wed May 22, 2024 4:10 pm
by nageswaragunupudi
Master Rao, in Resolution: 1024 x 768, the buttons disappear.


This implementation will be released in the next version.
No point testing these samples with your existing version of FWH

Master Rao, is it possible to control VIA the screen resolution (video) chosen by the user?


Controls should be relative to the size of window/dialog.
Window/Dialog should be relative to the screen resolution. This will be implemented later.

Re: Relative coordinates of Controls

PostPosted: Fri May 24, 2024 4:19 pm
by sysctrl2
muy bueno
lo esperamos con ansias locas :roll: :lol: :D :oops: :cry:

Re: Relative coordinates of Controls

PostPosted: Fri May 24, 2024 10:22 pm
by TimStone
I have always used resources ( .rc file ) because I could never figure out how to get the proper @ coordinates on a dialog. Of course, with resources, resizing is not possible.

After all these years, I would REALLY APPRECIATE knowing how we can actually determine the proper @ x,y values for controls. I've asked before and never received an answer. Because my screens contain a lot of data, I must be quite precise with control placement.

I love what you are doing, but if I can never figure out how to accurately determine the @ x,y values, I will sadly not be able to use it.

( Another example of where documentation of FWH would be so helpful ).

Re: Relative coordinates of Controls

PostPosted: Sat May 25, 2024 1:55 am
by nageswaragunupudi
Of course, with resources, resizing is not possible.


No.
It is possible to have resizable dialogs with resources also.
Here is an example.

rc file:
Code: Select all  Expand view
TEST DIALOG 6, 15, 306, 227
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX
CAPTION "TXBrowse demo"
FONT 8, "MS Sans Serif"
{
 CONTROL "", 101, "TXBrowse", 0 | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP, 4, 5, 297, 202
}


Please see I added
Code: Select all  Expand view
WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX

to the dialog definition.

The program:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oBrw

   USE STATES

   DEFINE DIALOG oDlg RESOURCE "TEST"

   REDEFINE XBROWSE oBrw OF oDlg ID 101 ;
      DATASOURCE ALIAS() COLUMNS "CODE","NAME","CODE" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := 2
      :nRightMargin  := 30
      :nBottomMargin := 30
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil


Image

You can test this sample with the current or any older version of FWH.

We are now implementing auto-resize of controls for those created from source and not from resource.
Later we will extend this feature to resources also.
Finally, we will have this feature for dialogs created from source as well as resource.

Re: Relative coordinates of Controls

PostPosted: Tue May 28, 2024 9:56 pm
by TimStone
If I understand you correctly, currently this should work with a browse control. However, not any other controls ( ie. GET fields, buttons, etc ) when using an .rc file.

However, it is your intention to eventually make a dialog resize with ALL controls responding correctly within an .rc file.

That would be great.