Combobox scroll (function PopupBrowse())
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Combobox scroll (function PopupBrowse())
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,
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,
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Combobox scroll
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:
An example of use:
REDEFINE GET oGet VAR ... ;
ID ... OF oDlg ACTION PopupBrowse( aValues, oGet, bInit )
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
REDEFINE GET oGet VAR ... ;
ID ... OF oDlg ACTION PopupBrowse( aValues, oGet, bInit )
Re: Combobox scroll
What is this ACTION on a GET ?
I use VALID but never ACTION .
When is it execute ?
Thanks
I use VALID but never ACTION .
When is it execute ?
Thanks
- joseluisysturiz
- Posts: 2024
- Joined: Fri Jan 06, 2006 9:28 pm
- Location: Guatire - Caracas - Venezuela
- Contact:
Re: Combobox scroll
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...Jack wrote:What is this ACTION on a GET ?
I use VALID but never ACTION .
When is it execute ?
Thanks
@ x, y GET oGet VAR cVar.... ;
ACTION PopupBrowse( aValue, oGet, bInit )
Dios no está muerto...
Gracias a mi Dios ante todo!
Gracias a mi Dios ante todo!
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Re: Combobox scroll
Antonio
Thanks
I will try and let you know,
Regards
Richard
Thanks
I will try and let you know,
Regards
Richard
Re: Combobox scroll
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
Saludos
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Combobox scroll
Horacio,
Aqui tienes una versión mejorada:
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
Re: Combobox scroll (function PopupBrowse())
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
Saludos
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Combobox scroll (function PopupBrowse())
Horacio,
Prueba esta versión mejorada, gracias
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
Re: Combobox scroll (function PopupBrowse())
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
Muchas Gracias
Saludos
Code: Select all
oGet:oWnd:bMMoved := { || oGet:Cargo := nil, oDlg:End() }
Saludos
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Combobox scroll (function PopupBrowse())
Horacio,
Prueba a cambiar esa línea por esta:
oGet:oWnd:bMoved = { || oGet:Cargo := nil, oDlg:End() }
Prueba a cambiar esa línea por esta:
oGet:oWnd:bMoved = { || oGet:Cargo := nil, oDlg:End() }
Re: Combobox scroll (function PopupBrowse())
Hello
Try with this code
A greeting
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Combobox scroll (function PopupBrowse())
function PopupBrowse() has been included in next FWH 15.11
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: Combobox scroll (function PopupBrowse())
Antonio,
can you make a small sample to call popbrowse function please ?
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Combobox scroll (function PopupBrowse())
Silvio,
REDEFINE GET oGet VAR ... ;
ID ... OF oDlg ACTION PopupBrowse( aValues, oGet, bInit )
aValues can be an array or a recordset
REDEFINE GET oGet VAR ... ;
ID ... OF oDlg ACTION PopupBrowse( aValues, oGet, bInit )
aValues can be an array or a recordset