Click to See Complete Forum and Search --> : HitTest
tangzibo
April 21st, 1999, 04:17 AM
Hi
Why following codes are right in debug version and error in release version?
void CTreeCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
UINT uFlag;
HTREEITEM hItem = HitTest(point, &uFlag);
if( hItem && (TVHT_ONITEMLABEL & uFlag))
{
}
}
April 21st, 1999, 06:37 AM
Is your code an exact copy of what you posted? You don't do anything if hItem && (TVHT_ONITEMLABEL & uFlag) is TRUE?
If that is the case I guess you could get a compiler error in release mode (since { } might not be treated as a valid statement) while i debug mode some extra code is added which does not leave the if branch without statements.
You might try to add ; as the empty statement.
i.e.
void CTreeCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
UINT uFlag;
HTREEITEM hItem = HitTest(point, &uFlag);
if( hItem && (TVHT_ONITEMLABEL & uFlag))
{
; //Empty Statement
}
}
tangzibo
April 21st, 1999, 11:09 PM
The following is my exact code.
void CTigerTree::OnRButtonDown(UINT nFlags, CPoint point)
{
UINT uFlag;
// AfxMessageBox("11111");
HTREEITEM hItem = HitTest(point, &uFlag);
// AfxMessageBox("22222");
if( hItem && (TVHT_ONITEMLABEL & uFlag))
{
SelectItem( hItem);
CMainFrame* pMainFrm = (CMainFrame *)AfxGetMainWnd();
int level = pMainFrm->GetSelectItemLevel();
OnContextMenu( NULL, point, level);
}
}
In release version if right click in the blank, my application will be terminated, the error is "Unhandled exception in Tiger.exe(MFC42.dll):0xC0000005: Access Violation". If either of the two "AfxMessageBox" be used, it will OK. I think it's bug of VC6.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.