Como subir o bajar controles encimados

Como subir o bajar controles encimados

Postby quique » Fri May 30, 2008 3:55 am

¿como puedo cambiar el orden en la ventana de los controles?

Por ejemplo:
Code: Select all  Expand view
@ 1,1 say oSay1 prompt "UNO" of oWnd
@ 1,1 say oSay2 prompt "DOS" of oWnd

Lo que hace es mostrar "DOS", esto es oSay2 oculta a oSay1, lo que quiero es poder subir oSay1 y ocultar oSay2 y viceversa, no me funciona el ocultarlo, porque ese es un ejemplo, lo mas común es que queden traslapados, por ejemplo:
Code: Select all  Expand view
@ 1,1 say oSay1 prompt "UNO" of oWnd pixel
@ 5,15 say oSay2 prompt "DOS" of oWnd pixel

en este caso si oculto uno u otro no se ve la pequeña parte que muestra el de abajo
Saludos
Quique
User avatar
quique
 
Posts: 408
Joined: Sun Aug 13, 2006 5:38 am

Postby Antonio Linares » Fri May 30, 2008 11:18 am

Quique,

No es necesario que les cambies el orden (zorder), lo resuelves usando la cláusula SIZE:

@ 1,1 say oSay1 prompt "UNO" of oWnd SIZE 80, 15 // por ejemplo

Prueba a cambiar el valor 15 por otros valores hasta que consigas las dimensiones deseadas
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby quique » Fri May 30, 2008 3:00 pm

Antonio Linares wrote:Quique,

No es necesario que les cambies el orden (zorder), lo resuelves usando la cláusula SIZE:

@ 1,1 say oSay1 prompt "UNO" of oWnd SIZE 80, 15 // por ejemplo

Prueba a cambiar el valor 15 por otros valores hasta que consigas las dimensiones deseadas


Gracias Antonio, pero la idea no es cambiar el tamaño, simplemente que se vea el say que quiero ver, has de cuenta algo así
Code: Select all  Expand view
@ 1, 1 say oSay1 prompt "UNO" of oWnd pixel
@ 5,15 say oSay2 prompt "DOS" of oWnd pixel

oSay1:lWantClick := .t.
oSay2:lWantClick := .t.

oSay1:bLClicked := { || subir( oSay1 ) }
oSay2:bLClicked := { || subir( oSay2 ) }


De esta manera esté el que esté arriba no tapa al de abajo, pero puedo ver el que quiero ver sin modificar tamaño o posición, icluso, puedo tener mas say encimados y subir al que se le de click
Saludos
Quique
User avatar
quique
 
Posts: 408
Joined: Sun Aug 13, 2006 5:38 am

Postby quique » Tue Jun 03, 2008 1:02 am

Antonio Linares wrote:Quique,

No es necesario que les cambies el orden (zorder), lo resuelves usando la cláusula SIZE:

¿Como puedo cambiar el zorder? o aunque sea ¿como puedo hacer que el siguiente control que se cree se coloque hasta arriba?
Saludos
Quique
User avatar
quique
 
Posts: 408
Joined: Sun Aug 13, 2006 5:38 am

Postby Antonio Linares » Tue Jun 03, 2008 7:55 am

Quique,

Aqui tienes un ejemplo de como cambiar el zorder de los controles. Fijate que la clave está en llamar a la función SetWindowPos() con unos determinados parámetros. Te adjunto la documentación de ese parámetro:
Code: Select all  Expand view
#include "FiveWin.ch"

#define HWND_TOP           0
#define HWND_BOTTOM        1
#define HWND_TOPMOST      -1
#define HWND_NOTOPMOST    -2

static oWnd, oBmp, oSay, oBrush

function Main()

   DEFINE BRUSH oBrush STYLE 'TILED'

   DEFINE WINDOW oWnd

      @20, 30 BITMAP oBmp FILENAME '' SIZE 200, 200 PIXEL OF oWnd
                   oBmp:oBrush := oBrush

      @50, 10 SAY oSay PROMPT 'Hola mundo' SIZE 100, 16 PIXEL OF oWnd ;
                       COLOR CLR_YELLOW, CLR_RED DESIGN

      oSay:blDblClick := {|| Swap( oSay ) }
      oBmp:blDblClick := {|| Swap( oBmp ) }

   ACTIVATE WINDOW oWnd

return nil

function Swap( oCtrl )

    LOCAL nOption := Alert( 'Posicion', { 'Top', 'Bottom' } )
    LOCAL nWidth, nHeight

    oCtrl:CoorsUpdate()

    if oCtrl:ClassName() == 'TBITMAP'
       nWidth  := oCtrl:nRight - oCtrl:nLeft
       nHeight := oCtrl:nBottom - oCtrl:nTop
    else
       nWidth  := oCtrl:nWidth
       nHeight := oCtrl:nHeight
    endif

    do case
       case nOption == 1
                SetWindowPos( oCtrl:hWnd, HWND_TOP   , oCtrl:nTop, oCtrl:nLeft, nWidth, nHeight )

       case nOption == 2
                SetWindowPos( oCtrl:hWnd, HWND_BOTTOM, oCtrl:nTop, oCtrl:nLeft, nWidth, nHeight )
    endcase

    oCtrl:SetFocus()

return nil

hWndInsertAfter

Identifies the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values:

Value Meaning
HWND_BOTTOM Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, the window loses its topmost status and is placed at the bottom of all other windows.
HWND_NOTOPMOST Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.
HWND_TOP Places the window at the top of the Z order.
HWND_TOPMOST Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby quique » Tue Jun 03, 2008 5:14 pm

Gracias, funciona
Saludos
Quique
User avatar
quique
 
Posts: 408
Joined: Sun Aug 13, 2006 5:38 am

Re:

Postby AngelSalom » Fri Jan 08, 2021 5:35 pm

Antonio Linares wrote:Quique,

Aqui tienes un ejemplo de como cambiar el zorder de los controles. Fijate que la clave está en llamar a la función SetWindowPos() con unos determinados parámetros. Te adjunto la documentación de ese parámetro:
Code: Select all  Expand view

#include "FiveWin.ch"

#define HWND_TOP           0
#define HWND_BOTTOM        1
#define HWND_TOPMOST      -1
#define HWND_NOTOPMOST    -2

static oWnd, oBmp, oSay, oBrush

function Main()

   DEFINE BRUSH oBrush STYLE 'TILED'

   DEFINE WINDOW oWnd

      @20, 30 BITMAP oBmp FILENAME '' SIZE 200, 200 PIXEL OF oWnd
                   oBmp:oBrush := oBrush

      @50, 10 SAY oSay PROMPT 'Hola mundo' SIZE 100, 16 PIXEL OF oWnd ;
                       COLOR CLR_YELLOW, CLR_RED DESIGN

      oSay:blDblClick := {|| Swap( oSay ) }
      oBmp:blDblClick := {|| Swap( oBmp ) }

   ACTIVATE WINDOW oWnd

return nil

function Swap( oCtrl )

    LOCAL nOption := Alert( 'Posicion', { 'Top', 'Bottom' } )
    LOCAL nWidth, nHeight

    oCtrl:CoorsUpdate()

    if oCtrl:ClassName() == 'TBITMAP'
       nWidth  := oCtrl:nRight - oCtrl:nLeft
       nHeight := oCtrl:nBottom - oCtrl:nTop
    else
       nWidth  := oCtrl:nWidth
       nHeight := oCtrl:nHeight
    endif

    do case
       case nOption == 1
                SetWindowPos( oCtrl:hWnd, HWND_TOP   , oCtrl:nTop, oCtrl:nLeft, nWidth, nHeight )

       case nOption == 2
                SetWindowPos( oCtrl:hWnd, HWND_BOTTOM, oCtrl:nTop, oCtrl:nLeft, nWidth, nHeight )
    endcase

    oCtrl:SetFocus()

return nil
 



Hola! Estoy probando este código ya que necesito mostrar unos controles que solapen a los que hay "debajo", con el say funciona bien, pero si ponemos por ejemplo un botón, al repintarlo "solapa" encima del control que debería estar en la posición superior. ¿Alguna idea?


Image
Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
User avatar
AngelSalom
 
Posts: 708
Joined: Fri Oct 07, 2005 7:38 am
Location: Benicarló (Castellón ) - España

Re: Como subir o bajar controles encimados

Postby AngelSalom » Fri Jan 08, 2021 5:40 pm

Esto es lo que estoy realizando, la barra lateral es una simple BUTTONBAR a la que le cambio el tamaño y asigno captions al pulsar un botón.
Se puede observar claramente como el botón del diálogo "pringa" la buttonbar
* También he probado creando un TPanel en el que contener la buttonbar con idéntico resultado.

Image
Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
User avatar
AngelSalom
 
Posts: 708
Joined: Fri Oct 07, 2005 7:38 am
Location: Benicarló (Castellón ) - España

Re: Como subir o bajar controles encimados

Postby cnavarro » Sat Jan 09, 2021 11:33 am

Angel, envíame un ejemplo
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Como subir o bajar controles encimados

Postby AngelSalom » Sat Jan 09, 2021 12:09 pm

Enviado.
Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
User avatar
AngelSalom
 
Posts: 708
Joined: Fri Oct 07, 2005 7:38 am
Location: Benicarló (Castellón ) - España


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 76 guests