TListBox refinement

Post Reply
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

TListBox refinement

Post by Enrico Maria Giordano »

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

Code: Select all

#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

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
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

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
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

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
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

ok, added :)

Thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply