Page 1 of 1

Browse Header and Left Button Sort

Posted: Fri Jun 03, 2016 6:08 am
by rdonnay
If you have been using the SORT bSort LEFTBUTTON clause to cause the browse column to sort on the left mouse button when clicked in the header, by now you know that this prevent the column from being resized. I have been working on a VFP conversion for a customer and they require column sorting to behave like other Windows applications, ie clicking the left mouse button in the header.

Here is a solution to that problem:

1. DO NOT use the LEFTBUTTON clause of DCBROWSECOL.
2. Use a custom handler. Source is shown below. Use DC_ReadGuiHandler() to make this the default for all browses.

Code: Select all

#include "appevent.ch"
FUNCTION Main()

DC_ReadGuiHandler({|a,b,c,d,e,f|MyCustomHandler(a,b,c,d,e,f)})

.. more code

RETURN nil

* --------

STATIC FUNCTION MyCustomHandler( nEvent, mp1, mp2, oXbp, oDlg, GetList )

IF nEvent == xbeM_LbDown .AND. oXbp:isDerivedFrom("DC_MultilineCellGroup")
  IF mp1[1] < oXbp:currentSize()[1]-20 .AND. mp1[1] > 20
    PostAppEvent(xbeM_RbDown,mp1,,oXbp)
    RETURN DCGUI_IGNORE
  ENDIF
ENDIF

RETURN DCGUI_NONE