FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Funcion para Agregar/Remover STYLES a un control in Run-Time
Posts: 84
Joined: Fri Oct 07, 2005 04:51 PM
Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Thu Jan 14, 2010 03:58 PM
#define GWL_STYLE -16


Aca les mando esta funcion, espero les sirva :-) :-) Es MUY util ehh :-)

Code (fw): Select all Collapse
//--------------------------------------------------------------------------------------------------//

FUNCTION ChangeStyleWindow( hoWnd, naStyle, nStyleType, lAdd )

   local aStyles:= {}, n, hWnd, nStyleReturn:= 0

   if ValType(hoWnd)$"O"
      hWnd:= hoWnd:hWnd
   else
      hWnd:= hoWnd
   endif

   if ValType(naStyle)$"N;A"
      if ValType(naStyle)$"N"
          aStyles:= { naStyle }
      else
          aStyles:= aClone( naStyle )
      endif
      aEval(aStyles, {|nStyle| nStyleReturn:= __ChangeStyleWindow( hWnd, nStyle, nStyleType, lAdd )  } )
   endif

return nStyleReturn

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

STATIC FUNCTION __ChangeStyleWindow( hWnd, nStyle, nStyleType, lAdd )

   local nOldStyle, lExistStyle
   local nStyleReturn:= 0

   DEFAULT nStyleType:= GWL_STYLE,;
           lAdd:= .T.

   if ValType(hWnd)$"N" .and. ValType(nStyle)$"N" .and. ValType(nStyleType)$"N" .and. ValType(lAdd)$"L"
      nOldStyle  := GetWindowLong( hWnd, nStyleType )
      lExistStyle:= lAnd( nStyle, nOldStyle )
      if lAdd .and. !lExistStyle
         SetWindowLong( hWnd, nStyleType, nOr( nOldStyle, nStyle ) )
      elseif !lAdd .and. lExistStyle
         SetWindowLong( hWnd, nStyleType, nAnd( nOldStyle, nNot(nStyle) ) )
      endif
      nStyleReturn:= GetWindowLong( hWnd, nStyleType )
   endif

RETURN nStyleReturn
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Thu Jan 14, 2010 11:16 PM

Hola Hernán! Que bueno de volver a verte y saludarte,

gracias! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 782
Joined: Wed Dec 19, 2007 07:50 AM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Fri Jan 15, 2010 02:35 AM
Hola Hernán:
Hernan Diego Ceccarelli wrote:Aca les mando esta funcion, espero les sirva :-) :-) Es MUY util ehh :-)

Que gusto tenerte nuevamente por acá, espero que nos visites con frecuencia :-) .

Gracias por la función.

Un abrazo con mis mejores deseos.
manuelmercado at prodigy dot net dot mx
Posts: 84
Joined: Fri Oct 07, 2005 04:51 PM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Fri Jan 15, 2010 07:02 PM

Gente linda, extraño todo esto de los foros y a uds. :) :D Me encanta ayudar a la gente con sus problemas :D
Voy a estar muy seguido por aca.
Les mando un abrazo grande a todos :D

Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Fri Jan 15, 2010 11:10 PM

Saludos Hernán,

Es un gusto verte por el foro nuevamente :D

Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 326
Joined: Sun Oct 09, 2005 05:22 PM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Fri Jan 15, 2010 11:15 PM

De igual manera te expreso mi aprecio Hernan.

Un Abrazo.

Posts: 845
Joined: Sun Oct 09, 2005 05:36 PM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Sat Jan 16, 2010 03:57 AM

un gusto tenerte por aca de nuevo master
saludos
paco

____________________

Paco
Posts: 330
Joined: Fri May 25, 2007 09:06 PM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Sat Jan 16, 2010 03:14 PM

saludos hernan::

algun ejemplo simple de como aplicar la funcion..

GRACIAS

Posts: 84
Joined: Fri Oct 07, 2005 04:51 PM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Mon Jan 25, 2010 02:49 PM
mantonio_08 wrote:saludos hernan::

algun ejemplo simple de como aplicar la funcion..

GRACIAS


Hola gracias a todos, pues es demasiado simple: Supongamos que tenemos un control que tenemos que QUITAR o AGREGAR EL TAB_STOP en tiempo de ejecucion, en funcion de una variable del aplicativo en cuestion.

ChangeStyleWindow( oGet, WS_TABSTOP, NIL, .T. ) // LO INCORPORA
ChangeStyleWindow( oGet, WS_TABSTOP, NIL, .F. ) // LO QUITA

Podria llamarse desde un ON CHANGE (bChange) o desde cualquier evento disparado por cualquier otro control, esto es un simple ejemplo, pero podemos manipular cualquier STYLE de window, sea define GWL_STYLE (-16) o GWL_EXSTYLE (-20)

Saludos :-)
Hernan
Posts: 1074
Joined: Fri Oct 07, 2005 01:56 PM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Mon Jan 25, 2010 03:59 PM

Muchas gracias por el aporte...

ahora se ve mas interesante

Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
Posts: 229
Joined: Sat Mar 18, 2006 03:42 PM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Tue Jan 26, 2010 12:55 AM

Que agradable sorpresa tenerte por aquí después de tanto tiempo. Recuerdo que gracias a tu invalorable ayuda me enbarqué en FW. Bienvenido de nuevo :D

Te saluda
Marcelo Jingo

Marcelo Jingo
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Tue Jan 26, 2010 02:20 AM

Hernan,

primeramente, un gusto verte por aqui y agradecer esta contribucion, esto lo estoy intentando hacer sin existo es el de cambiar la justificacion de un GET en tiempo de ejecucion, y no lo he podido hacer, tienes alguna idea??

saludos

Marcelo

Posts: 84
Joined: Fri Oct 07, 2005 04:51 PM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Tue Jan 26, 2010 03:27 PM
Marcelo Via Giglio wrote:Hernan,

primeramente, un gusto verte por aqui y agradecer esta contribucion, esto lo estoy intentando hacer sin existo es el de cambiar la justificacion de un GET en tiempo de ejecucion, y no lo he podido hacer, tienes alguna idea??

saludos

Marcelo


Marcelo,
Lamentablemente NO es posible, las APIs se reservan algunos styles internos EN TIEMPO DE EJECUCION y no pueden ser cambiados a posteriori dinamicamente. Los Edit Control son un caso. :-) Igualmente voy a investigar formas de violar dicho impedimento jejeje :-) Por el momento habria que destruirlo y crearlo en tiempo de ejecucion :-) con la alineacion que quieras.,


Edit Control Styles

To create an edit control using the CreateWindow or
CreateWindowEx function, specify the EDIT class, appropriate
window style constants, and a combination of the following edit
control styles. After the control has been created, these styles
cannot be modified, except as noted.


The ES_CENTER/ES_LEFT/ES_RIGHT were not noted as modifiable.
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: Funcion para Agregar/Remover STYLES a un control in Run-Time
Posted: Wed Jan 27, 2010 03:46 PM

Hernan,

gracias por la respuesta, con razon :D

saludos

Marcelo

Continue the discussion