Combobox scroll (function PopupBrowse())

User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Combobox scroll (function PopupBrowse())

Post by Richard Chidiak »

Good morning

I have a combobox redefined from resource, dropdown list.

I need a horizontal scroll on this combobox in addition to the normal vertical scroll.

I have tried cbs-autohscroll style but without success, same with WS_HSCROLL .

Anyone has an idea on what style can display the horizontal scrollbar ?

Thanks for help,
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Combobox scroll

Post by Antonio Linares »

Richard,

Have you considered to use a GET and a XBrowse together ?

Here you have a function PopupBrowse() that behaves quite similar to a combobox, but you have all the xbrowse possibilities:

Code: Select all

function PopupBrowse( aValue, oGet, bInit )

   local oDlg, oBrw
   local aPoint := { oGet:nTop + oGet:nHeight, oGet:nLeft }

   if oGet:Cargo == nil
      aPoint = ClientToScreen( oGet:oWnd:hWnd, aPoint )

      DEFINE DIALOG oDlg OF oGet:oWnd STYLE WS_POPUP ;
         SIZE 500, 180

      ACTIVATE DIALOG oDlg NOWAIT ;
         ON INIT oDlg:SetPos( aPoint[ 1 ], aPoint[ 2 ] )

      @ 0, 0 XBROWSE oBrw ARRAY aValue AUTOSORT ;
         SIZE oDlg:nWidth, oDlg:nHeight OF oDlg PIXEL

      oBrw:CreateFromCode()

      Eval( bInit, oBrw )

      oBrw:PostMsg( WM_SETFOCUS )
      oBrw:bKeyDown = { | nKey | If( nKey == VK_RETURN, oDlg:End(),) }
      oBrw:bChange = { || oGet:VarPut( oBrw:aCols[ 1 ]:Value ), oGet:Refresh() }
      oBrw:bLButtonUp = { | nRow, nCol | If( nRow > oBrw:nHeaderHeight,;
                          ( Eval( oBrw:bChange ), oDlg:End(),;
                            oGet:oWnd:GoNextCtrl( oGet:hWnd ),;
                            oGet:Cargo := nil ),) }

      oBrw:Seek( oGet:GetText() )

      oGet:Cargo = oDlg
      oGet:bKeyDown = { | nKey | If( nKey == VK_DOWN, oBrw:GoDown(),),;
                                 If( nKey == VK_UP, oBrw:GoUp(),),;
                                 If( nKey == VK_RETURN, oDlg:End(),), 0 }

      oGet:oWnd:bLClicked = { || oDlg:End(), oGet:Cargo := nil }
      oGet:oWnd:bMouseWheel = { || oDlg:SetFocus() }
   else
      oGet:Cargo:End()
      oGet:Cargo = nil
   endif

return nil
 
An example of use:

REDEFINE GET oGet VAR ... ;
ID ... OF oDlg ACTION PopupBrowse( aValues, oGet, bInit )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Jack
Posts: 249
Joined: Wed Jul 11, 2007 11:06 am

Re: Combobox scroll

Post by Jack »

What is this ACTION on a GET ?
I use VALID but never ACTION .
When is it execute ?

Thanks
User avatar
joseluisysturiz
Posts: 2024
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela
Contact:

Re: Combobox scroll

Post by joseluisysturiz »

Jack wrote:What is this ACTION on a GET ?
I use VALID but never ACTION .
When is it execute ?

Thanks
Puedes usarlo con el VALID o ACTION, un pequeño boton que se crea a la derecha del GET y se ejecuta al hacer click alli, saludos...

@ x, y GET oGet VAR cVar.... ;
ACTION PopupBrowse( aValue, oGet, bInit )
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Re: Combobox scroll

Post by Richard Chidiak »

Antonio

Thanks

I will try and let you know,

Regards

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
horacio
Posts: 1270
Joined: Wed Jun 21, 2006 12:39 am
Location: Capital Federal Argentina

Re: Combobox scroll

Post by horacio »

Antonio, he probado tu solución y tengo el siguiente problema, cuando abro el combo y hago foco en otro control con el ratón, este no se cierra. Tampoco si presiono el ratón sobre la barra de título del dialogo que contiene el combo. Habrá alguna solución para esto ? Muchísimas gracias.

Saludos
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Combobox scroll

Post by Antonio Linares »

Horacio,

Aqui tienes una versión mejorada:

Code: Select all

function PopupBrowse( aValue, oGet, bInit )

   local oDlg, oBrw
   local aPoint := { oGet:nTop + oGet:nHeight, oGet:nLeft }

   if oGet:Cargo == nil
      aPoint = ClientToScreen( oGet:oWnd:hWnd, aPoint )

      DEFINE DIALOG oDlg OF oGet:oWnd STYLE WS_POPUP ;
         SIZE 500, 180

      ACTIVATE DIALOG oDlg NOWAIT ;
         ON INIT oDlg:SetPos( aPoint[ 1 ], aPoint[ 2 ] )

      @ 0, 0 XBROWSE oBrw ARRAY aValue AUTOSORT ;
         SIZE oDlg:nWidth, oDlg:nHeight OF oDlg PIXEL

      oBrw:CreateFromCode()

      Eval( bInit, oBrw )

      oBrw:PostMsg( WM_SETFOCUS )
      oBrw:bKeyDown = { | nKey | If( nKey == VK_RETURN, oDlg:End(), ) }
      oBrw:bChange = { || oGet:VarPut( oBrw:aCols[ 1 ]:Value ), oGet:Refresh() }
      oBrw:bLButtonUp = { | nRow, nCol | If( nRow > oBrw:nHeaderHeight,;
                          ( Eval( oBrw:bChange ), oDlg:End(),;
                            oGet:oWnd:GoNextCtrl( oGet:hWnd ),;
                            oGet:Cargo := nil ),) }
      oGet:bLostFocus = { || oGet:Cargo := nil, oDlg:End() }
      oGet:oWnd:bGotFocus = { || oGet:Cargo := nil, oDlg:End() } 

      oBrw:Seek( oGet:GetText() )

      oGet:Cargo = oDlg
      oGet:bKeyDown = { | nKey | If( nKey == VK_DOWN, oBrw:GoDown(),),;
                                 If( nKey == VK_UP, oBrw:GoUp(),),;
                                 If( nKey == VK_DELETE, ( oGet:VarPut(0), oGet:Refresh(), oDlg:End()),),;
                                 If( nKey == VK_RETURN, oDlg:End(),), 0 }

      oGet:oWnd:bLClicked = { || oDlg:End(), oGet:Cargo := nil }
      oGet:oWnd:bMouseWheel = { || oDlg:SetFocus() }
   else
      oGet:Cargo:End()
      oGet:Cargo = nil
   endif

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
horacio
Posts: 1270
Joined: Wed Jun 21, 2006 12:39 am
Location: Capital Federal Argentina

Re: Combobox scroll (function PopupBrowse())

Post by horacio »

Antonio, gracias por tu respuesta. He probado esta nueva versión. Ahora si cierra el combo si pico con el ratón en otro control. Solo faltaría que si muevo el dialogo que contiene el combo, este se cierre. Muchísimas gracias.

Saludos
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Combobox scroll (function PopupBrowse())

Post by Antonio Linares »

Horacio,

Prueba esta versión mejorada, gracias

Code: Select all

function PopupBrowse( aValue, oGet, bInit )

   local oDlg, oBrw
   local aPoint := { oGet:nTop + oGet:nHeight, oGet:nLeft }

   if oGet:Cargo == nil
      aPoint = ClientToScreen( oGet:oWnd:hWnd, aPoint )

      DEFINE DIALOG oDlg OF oGet:oWnd STYLE WS_POPUP ;
         SIZE 500, 180

      ACTIVATE DIALOG oDlg NOWAIT ;
         ON INIT oDlg:SetPos( aPoint[ 1 ], aPoint[ 2 ] )

      @ 0, 0 XBROWSE oBrw ARRAY aValue AUTOSORT ;
         SIZE oDlg:nWidth, oDlg:nHeight OF oDlg PIXEL

      oBrw:CreateFromCode()

      Eval( bInit, oBrw )

      oBrw:PostMsg( WM_SETFOCUS )
      oBrw:bKeyDown = { | nKey | If( nKey == VK_RETURN, oDlg:End(), ) }
      oBrw:bChange = { || oGet:VarPut( oBrw:aCols[ 1 ]:Value ), oGet:Refresh() }
      oBrw:bLButtonUp = { | nRow, nCol | If( nRow > oBrw:nHeaderHeight,;
                          ( Eval( oBrw:bChange ), oDlg:End(),;
                            oGet:oWnd:GoNextCtrl( oGet:hWnd ),;
                            oGet:Cargo := nil ),) }
      oGet:bLostFocus = { || oGet:Cargo := nil, oDlg:End() }
      oGet:oWnd:bGotFocus = { || oGet:Cargo := nil, oDlg:End() } 
      oGet:oWnd:bMMoved = { || oGet:Cargo := nil, oDlg:End() }

      oBrw:Seek( oGet:GetText() )

      oGet:Cargo = oDlg
      oGet:bKeyDown = { | nKey | If( nKey == VK_DOWN, oBrw:GoDown(),),;
                                 If( nKey == VK_UP, oBrw:GoUp(),),;
                                 If( nKey == VK_DELETE, ( oGet:VarPut(0), oGet:Refresh(), oDlg:End()),),;
                                 If( nKey == VK_RETURN, oDlg:End(),), 0 }

      oGet:oWnd:bLClicked = { || oDlg:End(), oGet:Cargo := nil }
      oGet:oWnd:bMouseWheel = { || oDlg:SetFocus() }
   else
      oGet:Cargo:End()
      oGet:Cargo = nil
   endif

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
horacio
Posts: 1270
Joined: Wed Jun 21, 2006 12:39 am
Location: Capital Federal Argentina

Re: Combobox scroll (function PopupBrowse())

Post by horacio »

Antonio, no funciona bien. Si muevo el ratón fuera del combo este se cierra. Tampoco trabaja la rueda del ratón cuando el mismo está abierto. La linea que hace fallar es

Code: Select all

      oGet:oWnd:bMMoved   := { || oGet:Cargo := nil, oDlg:End() }
 
Muchas Gracias

Saludos
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Combobox scroll (function PopupBrowse())

Post by Antonio Linares »

Horacio,

Prueba a cambiar esa línea por esta:

oGet:oWnd:bMoved = { || oGet:Cargo := nil, oDlg:End() }
regards, saludos

Antonio Linares
www.fivetechsoft.com
pgfdz
Posts: 145
Joined: Wed Nov 03, 2010 9:16 am

Re: Combobox scroll (function PopupBrowse())

Post by pgfdz »

Hello
Try with this code
A greeting

Code: Select all


#include "fivewin.ch"

function main()

local oWnd, oCbx
local cVar := "Hola"
local aItems := {"Hola","cara","de","bola"}


DEFINE WINDOW oWnd

   @ 10, 10 COMBOBOX oCbx VAR cVar ITEMS aItems SIZE 200, 300 PIXEL OF oWnd

ACTIVATE WINDOW oWnd ON INIT SetCbxHScroll( oCbx )

return nil




FUNCTION SetCbxHScroll( oCbx )

SumarEstilo( HWndComboList( oCbx:hWnd ), WS_HSCROLL )

return 0




#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"
#include "commctrl.h"



HB_FUNC( SUMARESTILO )
{
   HWND hWnd = (HWND) hb_parnl( 1 );
   DWORD dwStyle = GetWindowLong( hWnd, GWL_STYLE );
   dwStyle |= ((DWORD)hb_parnl(2));
   SetWindowLong( hWnd, GWL_STYLE, dwStyle );
}

BOOL SGetComboBoxInfo( HWND hWnd, PCOMBOBOXINFO pcbi )
{
   typedef BOOL (CALLBACK* LPFNDLLFUNC)( HWND, PCOMBOBOXINFO );
   HINSTANCE hLib;
   LPFNDLLFUNC GetComboBoxInfo;
   BOOL bRet = FALSE;

   hLib = LoadLibrary( "User32.dll" );
   if( hLib )
   {
       GetComboBoxInfo = ((LPFNDLLFUNC) GetProcAddress( hLib, "GetComboBoxInfo" ));
       bRet = (BOOL) GetComboBoxInfo( hWnd, pcbi );
       FreeLibrary( hLib );
   }
   return bRet;
}


// Obtener el HWND de la lista desplegable del combobox
HB_FUNC( HWNDCOMBOLIST )
{
   COMBOBOXINFO cbi      ;
   ZeroMemory( &cbi, sizeof( COMBOBOXINFO ) );
   cbi.cbSize = sizeof(COMBOBOXINFO);

   SGetComboBoxInfo( (HWND) hb_parnl( 1 ), &cbi );

   hb_retnl( (LONG)cbi.hwndList ) ;
}

#pragma ENDDUMP

 
Paco García
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Combobox scroll (function PopupBrowse())

Post by Antonio Linares »

function PopupBrowse() has been included in next FWH 15.11
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Combobox scroll (function PopupBrowse())

Post by Silvio.Falconi »

Antonio,
can you make a small sample to call popbrowse function please ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Combobox scroll (function PopupBrowse())

Post by Antonio Linares »

Silvio,

REDEFINE GET oGet VAR ... ;
ID ... OF oDlg ACTION PopupBrowse( aValues, oGet, bInit )

aValues can be an array or a recordset
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply