Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Bug in tree grid Collapse All
Subject Author Date
Offer Har Aug 21, 2009 - 8:41 AM

Dear Support,


I have a node with two children leafs, and I have my own derive cell type in both of the leafs.


I override OnClick of my cell, and I want to catch double-click, waiting for nRepCnt==2.


The problem is that if I click once on the first node, and then once on the second node, I get nRepCnt equals to 2, and I think there was a double-click, which there was not.


Please fix and let me know.


Thanks,


Ron.

Technical Support Aug 22, 2009 - 11:35 AM

We fixed this issue some time ago. The void CExtGridBaseWnd::OnLButtonDown() method should begin with the following code:

void CExtGridBaseWnd::OnLButtonDown(UINT nFlags, CPoint point) 
{
      ASSERT_VALID( this );

      if( m_eMTT != __EMTT_NOTHING )
      {
            SendMessage( WM_CANCELMODE );
            if( m_eMTT != __EMTT_NOTHING )
                  return;
      } // if( m_eMTT != __EMTT_NOTHING )
UINT nRepCnt = 1;
static clock_t g_nLastClock = 0;
static HWND g_hWndLastClick = NULL;
static CPoint g_ptLastClick(-32767,-32767);
CPoint ptLastClick = point;
      ClientToScreen( &ptLastClick );
clock_t nCurrClock = ::clock();
      if(         g_hWndLastClick == m_hWnd
            &&    g_ptLastClick == ptLastClick
            )
      {
            clock_t nDiff = (clock_t)::abs( nCurrClock - g_nLastClock );
            clock_t nDoubleClickTime = (clock_t)::GetDoubleClickTime();
            if( nDiff <= nDoubleClickTime )
                  nRepCnt = 2;
      }
      g_ptLastClick = ptLastClick;
      g_hWndLastClick = m_hWnd;
      g_nLastClock = nCurrClock;

HWND hWndOwn = m_hWnd, hWndFocus = ::GetFocus();
. . .
There is only one case when a double click can be generated not for the same cell which received the first click: this can happen when grid’s scrolling position changed between clicks. Is it your case?

Offer Har Aug 21, 2009 - 8:45 AM

I would like to add that I think I know where this bugs begins -


You remember the last click, and the HWND it was clicked in (g_hWndLastClick and g_nLastClock) but this does not work for cells, as they are not HWND entities, and as they are in the same grid, they have the same HWND...


Take a look at this code:


 

void CExtGridBaseWnd::OnLButtonDown(UINT nFlags, CPoint point) {     ASSERT_VALID( this );     if( m_eMTT != __EMTT_NOTHING )     {         SendMessage( WM_CANCELMODE );         if( m_eMTT != __EMTT_NOTHING )             return;     } // if( m_eMTT != __EMTT_NOTHING ) UINT nRepCnt = 1; static clock_t g_nLastClock = 0; static HWND g_hWndLastClick = NULL; clock_t nCurrClock = ::clock();     if( g_hWndLastClick == m_hWnd )     {         clock_t nDiff = (clock_t)::abs( nCurrClock - g_nLastClock );         clock_t nDoubleClickTime = (clock_t)::GetDoubleClickTime();         if( nDiff <= nDoubleClickTime )             nRepCnt = 2;     }

...


I put a break-point there and it is reached...


Please fix.


Thanks,


Ron.