FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Listbox multiselect. Cambio de estilo.
Posts: 1283
Joined: Fri Feb 10, 2006 02:34 PM
Listbox multiselect. Cambio de estilo.
Posted: Mon Nov 13, 2006 09:13 AM

Hola,

Es posible cambiar en tiempo de ejecucion el estilo de un listbox ? Deseo pasar de multiselect a normal.

En la clase se define nStyle := nOr( ..., If( lMulti, LBS_MULTIPLESEL, 0 )...)

Gracias

Salutacions, saludos, regards

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

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
HIX -> https://github.com/carles9000/hix
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Listbox multiselect. Cambio de estilo.
Posted: Mon Nov 13, 2006 09:45 AM

Carles,

Prueba con:

SetWindowLong( oListBox:hWnd, GWL_STYLE, nStyle )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1283
Joined: Fri Feb 10, 2006 02:34 PM
Listbox multiselect. Cambio de estilo.
Posted: Mon Nov 13, 2006 10:02 AM
Hola Antonio,

La idea parece buena, pero no funciona :-) . Ejemplo:

#include "fivewin.ch"

STATIC oWnd, oLbx

FUNCTION Main()

   LOCAL oBar
   LOCAL aItems := { 'Primero', 'Segundo', 'Tercero' }
   LOCAL cVar   := ''

   DEFINE WINDOW oWnd

      DEFINE BUTTONBAR oBar OF oWnd
      DEFINE BUTTON OF oBar ACTION   TestStyle()

      @50, 50 LISTBOX oLbx VAR cVar ITEMS aItems PIXEL SIZE 100, 100 OF oWnd

   ACTIVATE WINDOW oWnd

RETU .T.

/*
 * Window field offsets for GetWindowLong()
 */

#define GWL_WNDPROC         (-4)
#define GWL_HINSTANCE       (-6)
#define GWL_HWNDPARENT      (-8)
#define GWL_STYLE           (-16)
#define GWL_EXSTYLE         (-20)
#define GWL_USERDATA        (-21)
#define GWL_ID              (-12)

STATIC FUNCTION TestStyle()

 LOCAL nStyle := nOr( GetWindowLong( oLbx:hWnd, GWL_STYLE ), LBS_MULTIPLESEL )

 SetWindowLong( oLbx:hWnd, GWL_STYLE, nStyle )

RETU NIL


Alguna idea mas ?
Salutacions, saludos, regards

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

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
HIX -> https://github.com/carles9000/hix
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Listbox multiselect. Cambio de estilo.
Posted: Mon Nov 13, 2006 10:21 AM
Carles,

Por lo visto no permite cambiar ese estilo dinamicamente.

La solución es reconstruir el control:
   DEFINE BUTTON OF oBar ACTION ReBuild( oWnd, oLbx, aItems, @cVar ) 
   ...

function ReBuild( oWnd, oLbx, aItems, cVar )

   oLbx:End()

   @50, 50 LISTBOX oLbx VAR cVar ITEMS aItems PIXEL SIZE 100, 100 OF oWnd MULTISEL
   
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1283
Joined: Fri Feb 10, 2006 02:34 PM
Listbox multiselect. Cambio de estilo.
Posted: Mon Nov 13, 2006 10:38 AM

Antonio,

Era la ultima solucion a realizar :-)

Gracias

Salutacions, saludos, regards

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

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
HIX -> https://github.com/carles9000/hix

Continue the discussion