FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Combobox scroll (function PopupBrowse())
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Combobox scroll (function PopupBrowse())
Posted: Thu Dec 10, 2015 09:46 AM

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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Combobox scroll
Posted: Fri Dec 11, 2015 08:35 AM
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 (fw): Select all Collapse
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
Posts: 300
Joined: Wed Jul 11, 2007 11:06 AM
Re: Combobox scroll
Posted: Fri Dec 11, 2015 10:51 AM

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

Thanks

Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: Combobox scroll
Posted: Fri Dec 11, 2015 06:28 PM
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!
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Combobox scroll
Posted: Sat Dec 12, 2015 04:59 AM

Antonio

Thanks

I will try and let you know,

Regards

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 1364
Joined: Wed Jun 21, 2006 12:39 AM
Re: Combobox scroll
Posted: Sun Dec 20, 2015 01:19 PM

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

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Combobox scroll
Posted: Mon Dec 21, 2015 06:52 AM
Horacio,

Aqui tienes una versi贸n mejorada:

Code (fw): Select all Collapse
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
Posts: 1364
Joined: Wed Jun 21, 2006 12:39 AM
Re: Combobox scroll (function PopupBrowse())
Posted: Mon Dec 21, 2015 01:29 PM

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

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Combobox scroll (function PopupBrowse())
Posted: Mon Dec 21, 2015 04:37 PM
Horacio,

Prueba esta versi贸n mejorada, gracias

Code (fw): Select all Collapse
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
Posts: 1364
Joined: Wed Jun 21, 2006 12:39 AM
Re: Combobox scroll (function PopupBrowse())
Posted: Mon Dec 21, 2015 05:21 PM
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 (fw): Select all Collapse
      oGet:oWnd:bMMoved   := { || oGet:Cargo := nil, oDlg:End() }


Muchas Gracias

Saludos
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Combobox scroll (function PopupBrowse())
Posted: Mon Dec 21, 2015 05:27 PM

Horacio,

Prueba a cambiar esa l铆nea por esta:

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 145
Joined: Wed Nov 03, 2010 09:16 AM
Re: Combobox scroll (function PopupBrowse())
Posted: Tue Dec 22, 2015 08:44 AM
Hello
Try with this code
A greeting

Code (fw): Select all Collapse
#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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Combobox scroll (function PopupBrowse())
Posted: Tue Dec 22, 2015 09:08 AM

function PopupBrowse() has been included in next FWH 15.11

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Combobox scroll (function PopupBrowse())
Posted: Tue Dec 22, 2015 11:55 AM

Antonio,
can you make a small sample to call popbrowse function please ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Combobox scroll (function PopupBrowse())
Posted: Tue Dec 22, 2015 12:05 PM

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