Combobox scroll (function PopupBrowse())

Combobox scroll (function PopupBrowse())

Postby Richard Chidiak » Thu Dec 10, 2015 9: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
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Combobox scroll

Postby Antonio Linares » Fri Dec 11, 2015 8: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: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42076
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Combobox scroll

Postby Jack » 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
Jack
 
Posts: 288
Joined: Wed Jul 11, 2007 11:06 am

Re: Combobox scroll

Postby joseluisysturiz » Fri Dec 11, 2015 6: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!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: Combobox scroll

Postby Richard Chidiak » Sat Dec 12, 2015 4: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
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Combobox scroll

Postby horacio » Sun Dec 20, 2015 1: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
horacio
 
Posts: 1363
Joined: Wed Jun 21, 2006 12:39 am
Location: Capital Federal Argentina

Re: Combobox scroll

Postby Antonio Linares » Mon Dec 21, 2015 6:52 am

Horacio,

Aqui tienes una versión mejorada:

Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42076
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Combobox scroll (function PopupBrowse())

Postby horacio » Mon Dec 21, 2015 1: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
horacio
 
Posts: 1363
Joined: Wed Jun 21, 2006 12:39 am
Location: Capital Federal Argentina

Re: Combobox scroll (function PopupBrowse())

Postby Antonio Linares » Mon Dec 21, 2015 4:37 pm

Horacio,

Prueba esta versión mejorada, gracias

Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42076
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Combobox scroll (function PopupBrowse())

Postby horacio » Mon Dec 21, 2015 5: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: Select all  Expand view

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


Muchas Gracias

Saludos
horacio
 
Posts: 1363
Joined: Wed Jun 21, 2006 12:39 am
Location: Capital Federal Argentina

Re: Combobox scroll (function PopupBrowse())

Postby Antonio Linares » Mon Dec 21, 2015 5: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42076
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Combobox scroll (function PopupBrowse())

Postby pgfdz » Tue Dec 22, 2015 8:44 am

Hello
Try with this code
A greeting

Code: Select all  Expand view


#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
pgfdz
 
Posts: 145
Joined: Wed Nov 03, 2010 9:16 am

Re: Combobox scroll (function PopupBrowse())

Postby Antonio Linares » Tue Dec 22, 2015 9:08 am

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42076
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Combobox scroll (function PopupBrowse())

Postby Silvio.Falconi » 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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: Combobox scroll (function PopupBrowse())

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42076
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 117 guests