TListBox refinement

TListBox refinement

Postby Enrico Maria Giordano » Mon Feb 06, 2006 8:44 am

The following sample shows that the Return key is not trapped by bKeyDown codeblock:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oLbx

    LOCAL cVar := ""

    DEFINE DIALOG oDlg

    @ 1, 1 LISTBOX oLbx VAR cVar ITEMS { "Bert", "Carl", "William" }

    oLbx:bKeyDown = { | nKey | MsgInfo( nKey ) }

    @ 3, 1 BUTTON "&Close" ACTION oDlg:End()

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


A possible solution is to add the following method to TListBox class:

Code: Select all  Expand view
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TListBox

   if nMsg == WM_GETDLGCODE .and. nWParam == VK_RETURN
      ::oWnd:nLastKey := VK_RETURN
      return Super:KeyDown( nWParam, nLParam )
   endif

return Super:HandleEvent( nMsg, nWParam, nLParam )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Mon Feb 06, 2006 9:27 pm

Enrico,

It is curious that if you put the listbox on a Window then the Enter key can be trapped with bKeydown. I have not figured out why this is.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » Mon Feb 06, 2006 10:42 pm

James Bott wrote:Enrico,

It is curious that if you put the listbox on a Window then the Enter key can be trapped with bKeydown. I have not figured out why this is.

James


I don't know either. :-(

By the way: you look great! :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Tue Feb 07, 2006 10:27 am

Enrico,

WM_GETDLGCODE doesn't supply any parameters. Is it an undocumented feature that the keystroke is provided ? Thanks,
regards, saludos

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

Postby Enrico Maria Giordano » Tue Feb 07, 2006 10:42 am

I don't know, sorry, but it works. :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Tue Feb 07, 2006 10:46 am

Enrico,

ok, added :)

Thanks!
regards, saludos

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

Postby Enrico Maria Giordano » Tue Feb 07, 2006 10:46 am

Thank you!

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

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