Browse Header and Left Button Sort

This forum is for posting of useful information
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4774
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Browse Header and Left Button Sort

#1 Post 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
The eXpress train is coming - and it has more cars.

Post Reply