Relative coordinates of Controls

Relative coordinates of Controls

Postby nageswaragunupudi » Wed May 22, 2024 4:29 am

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  RUN
#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  RUN
#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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Relative coordinates of Controls

Postby Carles » Wed May 22, 2024 5:18 am

Rao,

Awesome, congratulations

C.
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1143
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Relative coordinates of Controls

Postby FiveWiDi » Wed May 22, 2024 6:27 am

Carles wrote:Rao,

Awesome, congratulations

C.


+1
:D
Un Saludo
Carlos G.

FiveWin 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1202
Joined: Mon Oct 10, 2005 2:38 pm

Re: Relative coordinates of Controls

Postby csincuir » Wed May 22, 2024 12:05 pm

Mr. Rao, +100
Excelente!
csincuir
 
Posts: 411
Joined: Sat Feb 03, 2007 6:36 am
Location: Guatemala

Re: Relative coordinates of Controls

Postby Marc Venken » Wed May 22, 2024 12:15 pm

+ 1
Very usefull !!
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1456
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Relative coordinates of Controls

Postby cmsoft » Wed May 22, 2024 12:16 pm

Excelente!!! Es una funcionalidad muy esperada y necesaria
Muchas gracias Mr. Rao
User avatar
cmsoft
 
Posts: 1293
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Relative coordinates of Controls

Postby leandro » Wed May 22, 2024 12:58 pm

Excelente Mr. Rao :D :D :D
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1688
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Relative coordinates of Controls

Postby Horizon » Wed May 22, 2024 1:29 pm

+1
Waiting other controls. :D
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Relative coordinates of Controls

Postby Armando » Wed May 22, 2024 2:43 pm

Mr. Rao:

Excelent job, as usual.

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3242
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Relative coordinates of Controls

Postby karinha » Wed May 22, 2024 3:54 pm

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  RUN

// 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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Relative coordinates of Controls

Postby nageswaragunupudi » Wed May 22, 2024 4:10 pm

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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Relative coordinates of Controls

Postby sysctrl2 » Fri May 24, 2024 4:19 pm

muy bueno
lo esperamos con ansias locas :roll: :lol: :D :oops: :cry:
Cesar Cortes Cruz
SysCtrl Software
Mexico

' Sin +- FWH es mejor "
User avatar
sysctrl2
 
Posts: 1032
Joined: Mon Feb 05, 2007 7:15 pm

Re: Relative coordinates of Controls

Postby TimStone » Fri May 24, 2024 10:22 pm

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 ).
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2950
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Relative coordinates of Controls

Postby nageswaragunupudi » Sat May 25, 2024 1:55 am

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  RUN
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  RUN
WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX

to the dialog definition.

The program:
Code: Select all  Expand view  RUN
#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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Relative coordinates of Controls

Postby TimStone » Tue May 28, 2024 9:56 pm

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.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2950
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 88 guests