简体   繁体   中英

MFC's CTabCtrl::HitTest function returns “1” for any tab clicked

Hi (although greeting usually gets deleted),

I'm using the MFC's CTabCtrl control and try to determine which tab was clicked (to drag & drop it later). Should be quite easy I thought - anyway got stuck with the HitTest function which returns "1" for whichever tab is clicked.

As I started the project very recently, it's literaly just a handful of lines. The mentioned HitTest function is used in Tdi.cpp file in CHlavniOkno::CTdi::OnLButtonDown function (full source code at http://nestorovic.hyperlink.cz/cpp_mfc.zip ):

afx_msg void CHlavniOkno::CTdi::OnLButtonDown(UINT flagy,CPoint bod){
    if (::DragDetect(m_hWnd,bod)){
        TCHITTESTINFO hti={bod};
        if (int idZalozky=HitTest(&hti)>=0)
            parametryTazeneZalozky=new TParametryTazeneZalozky(this,idZalozky);
    }
    CTabCtrl::OnLButtonDown(flagy,bod);
}

I definitely must have omitted something tiny, as is almost always the case...

Thanks for your time by having a look at the problem.

Tomas

The statement int idZalozky=HitTest(&hti)>=0 is setting idZalozky to the result of the test HitTest(&hti)>=0 . As a boolean test this will always return either 0 or 1.

You probably want:

int idZalozky=HitTest(&hti);
if (idZalozky>=0)
{
...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM