FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour redimensionar dialogos...
Posts: 845
Joined: Sun Oct 09, 2005 05:36 PM
redimensionar dialogos...
Posted: Wed Nov 16, 2005 02:13 AM

Hola foro,
se que en alguna ocasion se toco el temo, pero lo encontre..
Tengo dialogos dise帽ados para una resolucion de 800x600 pero si mi resolucion es mayo quiero que el dialogo se ajuste al tama帽o nuevo de resolucion incluyendo controles, sera posible?
gracias
Paco

____________________

Paco
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
redimensionar dialogos...
Posted: Wed Nov 16, 2005 08:15 AM
Paco,

En la clase TDialog en el m茅todo Initiate tienes este c贸digo que sirve para redimensionar un di谩logo. Se podr铆a generalizar, para usarlo como m茅todo y al tama帽o que se desease:
      #define SCALE_FACTOR 1.16668
      if ::lResize16 .and. ! Empty( ::cResName )
         ::nWidth = ::nWidth * SCALE_FACTOR
         hCtrl = GetWindow( ::hWnd, GW_CHILD )
         if hCtrl != 0
            do while ! lEnd
               aRect = GetCoors( hCtrl )
               SetWindowPos( hCtrl, 0, aRect[ 1 ], aRect[ 2 ] * SCALE_FACTOR,;
                             ( aRect[ 4 ] - aRect[ 2 ] ) * SCALE_FACTOR,;
                             aRect[ 3 ] - aRect[ 1 ], nOr( SWP_NOZORDER,;
                             SWP_NOREDRAW, SWP_NOACTIVATE ) )
               hCtrl = GetWindow( hCtrl, GW_HWNDNEXT )
               lEnd = ! ( ( hCtrl != 0 ) .and. ( GetParent( hCtrl ) == ::hWnd ) )
            end
         endif
      endif
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1445
Joined: Mon Oct 10, 2005 02:38 PM
Re: redimensionar dialogos...
Posted: Wed Nov 16, 2005 03:57 PM
Francisco Horta wrote:Hola foro,
se que en alguna ocasion se toco el temo, pero lo encontre..
Tengo dialogos dise帽ados para una resolucion de 800x600 pero si mi resolucion es mayo quiero que el dialogo se ajuste al tama帽o nuevo de resolucion incluyendo controles, sera posible?
gracias
Paco


Yo utilizo esta funci贸n:

/* ******************** */
#Include "FiveWin.ch"

/*
Los par谩metros recibidos son:
oWnd: Objeto/ventana/di谩logo/control a ser redimensionado.
nResolution: N煤mero que identifica que resoluci贸n ten铆a la pantalla en la cual
se dise帽贸 el objeto.
lRepaint: Indicador de si debe repintarse el objeto una vez redimensionado.

Esta funci贸n permitir谩 que una aplicaci贸n desarrolada en un PC con una resoluci贸n
de pantalla de por ejemplo 1024 x 768 (nResolution valdr铆a en este caso 3), se vea
redimensionada proporcionalmente en un PC con una resoluci贸n diferente, ya sea mayor
o menor.

A falta de perfeccionar el c贸digo, se comprueba solamente la variaci贸n de la anchura
de la resoluci贸n de la pantalla para aplicar la variaci贸n del tama帽o, aunque cuando
ello se realiza se hace tanto en la anchura como en la altura.

Esta funci贸n est谩 orientada a ser utilizada en el evento ON INIT del ACTIVATE
de las WINDOW y DIALOG con un valor fijo de lRepaint a .T. o sin 茅l.
Adem谩s tambi茅n puede utilizarse directamente sobre un control definido posteriormente
a la ACTIVACI脫N de su contenedor ya sea 茅ste WINDOW o DIALOG, con la salvedad que
lRepaint debe valer .T. para forzar su repintado.

Ejemplos de uso:

-* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -*
ACTIVATE oWnd ON INIT AutoResize( oWnd, 3 )

-* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -*

@ 185.50,8.00 TABS oTabs OF oWnd ITEMS "Tab1","Tab2","Venga a ordenarrrrr!!" ;
PIXEL COLORS CLR_BLUE,CLR_HCYAN SIZE 288.00,9.00 MESSAGE "Mensaje del Tabs"

AutoResize( oTabs, 3, .T. )

-* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -*
*/

FUNCTION AutResiz( oWnd, nResolution, lRepaint )

// Resoluci贸n de la pantalla en el momento de definir los controles.
Local nOriWidth, nOriHeight

// Resoluci贸n actual de la pantalla.
Local nWidth, nHeight

// Son la relaci贸n entre la resoluci贸n de pantalla y la resoluci贸n de dise帽o.
Local nFactorWitdh, nFactorHeight

Local nContador

DEFAULT lRepaint := .T.

nOriWidth := 0
nOriHeight := 0
nWidth := 0
nHeight := 0
nContador := 0

If nResolution = 1
nOriWidth := 640
nOriHeight := 480
ElseIf nResolution = 2
nOriWidth := 800
nOriHeight := 600
ElseIf nResolution = 3
nOriWidth := 1024
nOriHeight := 768
ElseIf nResolution = 4
nOriWidth := 1152
nOriHeight := 864
ElseIf nResolution = 5
nOriWidth := 1280
nOriHeight := 1024
ElseIf nResolution = 6
nOriWidth := 1600
nOriHeight := 1200
Else
ScrResolution( @nOriWidth, @nOriHeight )
Endif

ScrResolution( @nWidth, @nHeight )

/*
Traza( 1, "nOriWidth=", nOriWidth )
Traza( 1, "nOriHeight=", nOriHeight )

Traza( 1, "nWidth=", nWidth )
Traza( 1, "nHeight=", nHeight )
*/

//Traza( 1, "oWnd:ClassName()=", oWnd:ClassName() )

If nOriWidth != nWidth // .or. nOriHeight != nHeight

nFactorWitdh := nWidth / nOriWidth
nFactorHeight := nHeight / nOriHeight

//oWnd:CoorsUpdate()

If lRepaint
oWnd:Hide()
EndIf

If nFactorWitdh > 1 // .or. nFactorHeight >= 1

//Traza( 1, "Aumentando tama帽o." )

If oWnd:ClassName() == "kalimeroquetequiero"
ElseIf oWnd:ClassName() $ "/TJ02LISMN/TLISTBOX/"
/* Traza( 1, "oWnd:nTop=", oWnd:nTop )
Traza( 1, "oWnd:nLeft=", oWnd:nLeft )
Traza( 1, "oWnd:nWidth=", oWnd:nWidth )
Traza( 1, "oWnd:nHeight=", oWnd:nHeight )
*/
oWnd:Move( oWnd:nTop * nFactorHeight , ;
oWnd:nLeft * nFactorWitdh, ;
oWnd:nWidth * nFactorWitdh, ;
oWnd:nHeight , ;
.F. )
Else
oWnd:Move( oWnd:nTop * nFactorHeight , ;
oWnd:nLeft * nFactorWitdh, ;
oWnd:nWidth * nFactorWitdh, ;
oWnd:nHeight * nFactorHeight , ;
.F. )
EndIf
EndIf

If oWnd:ClassName() == "TFOLDER"
// Traza( 1, "ValType(oWnd:aDialogs)=", ValType(oWnd:aDialogs) )
If ValType( oWnd:aDialogs ) = "A"
For nContador := 1 To Len( oWnd:aDialogs )
AutResiz( oWnd:aDialogs[nContador], nResolution, .F. )
EndFor
EndIf
Else
// Traza( 1, "ValType(oWnd:aControls)=", ValType(oWnd:aControls) )
If ValType( oWnd:aControls ) = "A"
For nContador := 1 To Len( oWnd:aControls )
AutResiz( oWnd:aControls[nContador], nResolution, .F. )
EndFor
EndIf
EndIf

If nFactorWitdh < 1 // .or. nFactorHeight < 1

//Traza( 1, "Disminuyendo tama帽o." )

If oWnd:ClassName() == "kalimeroquetequiero"
ElseIf oWnd:ClassName() $ "/TJ02LISMN/TLISTBOX/"
/* Traza( 1, "oWnd:nTop=", oWnd:nTop )
Traza( 1, "oWnd:nLeft=", oWnd:nLeft )
Traza( 1, "oWnd:nWidth=", oWnd:nWidth )
Traza( 1, "oWnd:nHeight=", oWnd:nHeight )
*/

//Traza( 1, "oWnd:nRight=", oWnd:nRight )
//Traza( 1, "oWnd:nBottom=", oWnd:nBottom )

oWnd:Move( oWnd:nTop * nFactorHeight , ;
oWnd:nLeft * nFactorWitdh, ;
oWnd:nWidth * nFactorWitdh, ;
oWnd:nHeight , ;
.F. )
//oWnd:SetSize( oWnd:nWidth * nFactorWitdh, oWnd:nHeight * nFactorHeight, .T. )
/* Traza( 1, "oWnd:nTop=", oWnd:nTop )
Traza( 1, "oWnd:nLeft=", oWnd:nLeft )
Traza( 1, "oWnd:nWidth=", oWnd:nWidth )
Traza( 1, "oWnd:nHeight=", oWnd:nHeight )
*/
Else
oWnd:Move( oWnd:nTop * nFactorHeight , ;
oWnd:nLeft * nFactorWitdh, ;
oWnd:nWidth * nFactorWitdh, ;
oWnd:nHeight * nFactorHeight , ;
.F. )
EndIf
EndIf

If lRepaint
oWnd:Show()
EndIf

EndIf


/* ******************** */

Saludos
Carlos G.

Un Saludo

Carlos G.



FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home

Posts: 845
Joined: Sun Oct 09, 2005 05:36 PM
Re: redimensionar dialogos...
Posted: Thu Nov 17, 2005 04:21 PM

Hola Carlos,

me tira error ...

____________________

Paco
Posts: 8
Joined: Mon Oct 10, 2005 02:37 PM
Re: redimensionar dialogos...
Posted: Sat Nov 19, 2005 11:55 AM
Francisco Horta wrote:Hola Carlos,

me tira error ...


Si, pero cual?

Saludos
Carlos G.
Posts: 205
Joined: Fri Oct 07, 2005 05:07 PM
redimensionar dialogos...
Posted: Sat Nov 19, 2005 12:37 PM
Si te Sirve ahi te envio como lo hago

Llamas al CheckRes() en el on init del dialog, tambien esta para modificar el font del dialogo o controles... se puede tambien modificar el tsbrowse o la barra de mensages... contactame por el MSN :-), Ya tenemos avanzado algo el Punto de Venta

Static Function CheckRes( oDlg )
//---------------------------------------------------------------------------
   Local hWDsk := GetDeskTopWindow()
   Local ResXY := GetClientRect( hWDsk )
   Local aRectD :=  GetClientRect( oDlg:hWnd )
   Local nFor, oRow
   Local nFactorX := ResXY[ 3 ] / aRectD[ 3 ]
   Local nFactorY := ResXY[ 4 ] / aRectD[ 4 ]

   //modificando el dialog
   //PARA RECURSOS TODOS LOS CONTROLES TIENEN QUE ESTAR REDEFINDOS !! OJO !!
   oDlg:Move( 0, 0, ResXY[ 4 ], ResXY[ 3 ], .t. )

   // Redfiniendo Tama帽o de Fonts de Controles / Dialogs..
   oDlg:MSetFont( nFactorX, nFactorY )

   Return Nil


En el Move() del Dialog puedes hacer esto... yo en este caso he creado una clase TMDialog que hereda de TDialog. El move de los controles. tiene para mantener fijo la parte superior ( lFixTop ) o la parte izquierda ( lFixLeft )

#Include 'FiveWin.ch'

CLASS TMDialog From TDialog

   METHOD Move()
   METHOD ClassName()            INLINE 'TDIALOG'
   METHOD MSetFont()

ENDCLASS

//-----------------------------------------------------------------------------------------//
METHOD Move( nTop, nLeft, nWidth, nHeight, lRepaint ) CLASS TMDialog
   Local nFor
   Local aRectD :=  GetClientRect( ::hWnd )

   Super:Move( nTop, nLeft, nWidth, nHeight, lRepaint )

   For nFor := 1 To Len( ::aControls )
       MoveControl( ::aControls[ nFor ], aRectD[ 3 ], aRectD[ 4 ], nHeight, nWidth, .T. )
   EndFor
   Return nil


Static Function MoveControl( oCtrl, nBottomAnt, nRightAnt, nBottomNew, nRightNew, lProportional, lFixTop, lFixLeft )
   Local nTop   := oCtrl:nTop +  nBottomNew - nBottomAnt
   Local nLeft  := oCtrl:nLeft + nRightNew - nRightAnt
   Local nHeight:= 0
   Local nWidth := 0
   Local nFactorX := nBottomNew / nBottomAnt
   Local nFactorY := nRightNew / nRightAnt

   DEFAULT lProportional := .F., ;
           lFixTop := .F., ;
           lFixLeft:= .F.

   If lProportional
      nTop   := Int( oCtrl:nTop * nFactorX )
      nLeft  := Int( oCtrl:nLeft * nFactorY )
      nHeight:= INT( oCtrl:nHeight * nFactorX )
      nWidth := INT( oCtrl:nWidth * nFactorY )
   EndIf

   If lFixTop
      If lProportional //tenemos que modificar el Height //para ke seubique en la pos correcta
         nHeight += nTop - oCtrl:nTop
      EndIf
      nTop := oCtrl:nTop
   EndIf

   If lFixLeft
      If lProportional //tenemos que modificar el Width //para ke seubique en la pos correcta
         nWidth += nLeft - oCtrl:nLeft
      EndIf
      nLeft := oCtrl:nLeft
   EndIf

   If oCtrl:ClassName() == 'TBITMAP' .and. !oCtrl:lStretch
      nWidth := 0          // cuando el bitmap y no es ajustado
      nHeight:= 0          // lo dibujamos con sus mismas extesiones
   EndIf

   oCtrl:Move( nTop, nLeft, nWidth, nHeight )

   Return Nil

//-----------------------------------------------------------------------------------------//

METHOD MSetFont( nFactorX, nFactorY ) CLASS TMDialog
   Local nFor, oCtrl
   Local oFont := TFont():New( ::oFont:cFaceName, ;
                               Int( If( ::oFont:nWidth == Nil, 0, ::oFont:nWidth ) * nFactorY ), ;
                               Int( ::oFont:nHeight * nFactorX ), , ;
                               ::oFont:lBold, ;
                               ::oFont:nEscapement, ;
                               ::oFont:nOrientation, ;
                               ::oFont:nWeight, ;
                               ::oFont:lItalic, ;
                               ::oFont:lUnderline,;
                               ::oFont:lStrikeOut, ;
                               ::oFont:nCharSet, ;
                               ::oFont:nOutPrecision, ;
                               ::oFont:nClipPrecision,;
                               ::oFont:nQuality, , ;
                               ::oFont:nPitchFamily )


   ::SetFont( oFont )

   oFont:End()

   For nFor := 1 To Len( ::aControls )
       oCtrl := ::aControls[ nFor ]
       oFont := TFont():New( oCtrl:oFont:cFaceName, ;
                               Int( If( oCtrl:oFont:nWidth == Nil, 0, oCtrl:oFont:nWidth ) * nFactorY ), ;
                               Int( oCtrl:oFont:nHeight * nFactorX ), , ;
                               oCtrl:oFont:lBold, ;
                               oCtrl:oFont:nEscapement, ;
                               oCtrl:oFont:nOrientation, ;
                               oCtrl:oFont:nWeight, ;
                               oCtrl:oFont:lItalic, ;
                               oCtrl:oFont:lUnderline,;
                               oCtrl:oFont:lStrikeOut, ;
                               oCtrl:oFont:nCharSet, ;
                               oCtrl:oFont:nOutPrecision, ;
                               oCtrl:oFont:nClipPrecision,;
                               oCtrl:oFont:nQuality, , ;
                               oCtrl:oFont:nPitchFamily )

       oCtrl:SetFont( oFont )

       If oCtrl:ClassName() == 'TSBROWSE'
          oCtrl:ChangeFont( oFont )
       EndIf

       oFont:End()

   EndFor

   oFont := Nil

   Return Nil
Saludos/regards

RenOmaS



skype: americo.balboa
Posts: 711
Joined: Thu Oct 06, 2005 09:57 PM
redimensionar dialogos...
Posted: Wed Jul 12, 2006 04:37 PM
RenOmaS wrote:Ya tenemos avanzado algo el Punto de Venta


驴Teneis ya depurado el c贸digo?. Ser铆a interesante contar, en la propia clase Tdialogo, con la posibilidad de adaptar los dialogos y controles a la resolucion de la pantalla.
Un saludo



Manuel
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
redimensionar dialogos...
Posted: Wed Jul 12, 2006 06:02 PM

RenOmaS

Siempre sorprendi茅ndonos con buen c贸digo, estoy de acuerdo con Manuel de lo interesante que ser铆a contar con una clase de ese tipo.

Desde ya Gracias por el c贸digo que has volcado.

Saludos/Regards,

Jos茅 Murugosa

"Los errores en programaci贸n, siempre est谩n entre la silla, el teclado y la IA!!"
Posts: 205
Joined: Fri Oct 07, 2005 05:07 PM
redimensionar dialogos...
Posted: Thu Jul 13, 2006 07:54 PM

Pos ese es el mismo codigo..
Sigue funcionando..
pos la clase esta ahi TMDialog

Saludos

Saludos/regards

RenOmaS



skype: americo.balboa
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: redimensionar dialogos...
Posted: Sun Mar 26, 2023 03:14 PM

Renomas, tiens un ejemplo simples de uso de TMDialog?

Gracias.

Regards, saludos.

Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: redimensionar dialogos...
Posted: Sun Mar 26, 2023 04:23 PM
karinha wrote:Renomas, tiens un ejemplo simples de uso de TMDialog?

Gracias.

Regards, saludos.
+1
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06

Continue the discussion