RE: CHeaderCtrl is abnormal when release compilation.

"Anna-Jayne Metcalfe" <[email protected]> Thu, 5 Jul 2012 22:12:05 +0100
Newsgroups gmane.comp.windows.wtl
Message-ID <!&!AAAAAAAAAAAYAAAAAAAAAFpZYOCpua1AsUU25lbUK8bCgAAAEAAAADyHevfn7EZAhYFKieS3sKEBAAAAAA==@annasplace.me.uk>
Hi Tody,

 

> I save one integer value in Column of ListCtrl via "SetItem";
> But I can't get the value via "GetItem" if the application is complied
using "Release" configuration.

> my test environment is vs2010 and vs2008.



I can't see anything specific to build configurations in your code (the
usual culprits are uninitialized variables or an ATLASSERT when you should
have used an ATLVERIFY).

 

I would however note that checking the result of an API call via a
comparison with TRUE is unlikely to work reliably, as BOOL returning Win32
API calls often return "nonzero" for success. If you need to compare against
anything, FALSE is a safer bet than TRUE, i.e.

m_ListCtrl.SubclassWindow(::GetDlgItem(m_hWnd, IDC_LIST1));
CHeaderCtrl header = m_ListCtrl.GetHeaderCtrl();
m_ListCtrl.InsertColumn(0, _T("Hello"), 0, 80);
HDITEM hd = {0};
int tt = 50;
BOOL ret;
hd.mask = HDI_FILTER;
hd.type = HDFT_ISNUMBER;
hd.pvFilter = &tt;
ret = header.SetItem(0, &hd);
if (ret == FALSE)                  // or if (!ret) ...
{
::MessageBox(m_hWnd, _T("wrong1"), NULL, 0);
}
HDITEM hh = {0};
int ss = 0;
hh.mask = HDI_FILTER;
hh.type = HDFT_ISNUMBER;
hh.pvFilter = &ss;
ret= header.GetItem(0, &hh); // return FALSE when release.
if (ret == FALSE)                  // or if (!ret) ...
{
::MessageBox(m_hWnd, _T("wrong2"), NULL, 0);
}
if (ss != tt)
{
::MessageBox(m_hWnd, _T("wrong3"), NULL, 0);
}

This becomes particularly important when you start using Boolean types (e.g.
VARIANT_BOOL) which have a different value for "TRUE".

 

 

Cheers,

 

Anna-Jayne Metcalfe

                 <http://www.riverblade.co.uk/> http://www.riverblade.co.uk





[Non-text portions of this message have been removed]



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/wtl/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/