Listbox multiselect. Cambio de estilo.

Post Reply
User avatar
Carles
Posts: 937
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona
Contact:

Listbox multiselect. Cambio de estilo.

Post by Carles »

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

https://modharbour.app
https://modharbour.app/compass
https://forum.modharbour.app
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Carles,

Prueba con:

SetWindowLong( oListBox:hWnd, GWL_STYLE, nStyle )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Carles
Posts: 937
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona
Contact:

Post by Carles »

Hola Antonio,

La idea parece buena, pero no funciona :( . Ejemplo:

Code: Select all

#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..."

https://modharbour.app
https://modharbour.app/compass
https://forum.modharbour.app
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Carles,

Por lo visto no permite cambiar ese estilo dinamicamente.

La solución es reconstruir el control:

Code: Select all

   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
User avatar
Carles
Posts: 937
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona
Contact:

Post by Carles »

Antonio,

Era la ultima solucion a realizar :-)

Gracias
Salutacions, saludos, regards

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

https://modharbour.app
https://modharbour.app/compass
https://forum.modharbour.app
Post Reply