CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: HitTest

  1. #1
    Join Date
    Apr 1999
    Posts
    37

    HitTest

    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))
    {

    }
    }



  2. #2
    Guest

    Re: HitTest

    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
    }
    }


  3. #3
    Join Date
    Apr 1999
    Posts
    37

    Re: HitTest

    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.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured