|
-
September 30th, 2004, 07:45 PM
#1
CListCtrl Bug
Situation:
I am writing my own version of windows registry (regedit). I am able to load all registry keys (using RegEnumKey). I am also able to enumerate values of a given registry key (using RegEnumValue). Just like in the registry; name, type, and data are displayed to a listview (CListCtrl).
I store each data to a CString object. I do not have problem in getting data no matter how big the size is.
My problem is this, when the size of data is big (712 bytes for example), I got an assertion error when I am about to add it to the listview.
The error is in the following codes of afxcmn.inl
occurs when I place the code GetListCtrl().GetItemCount()
Code:
_AFXCMN_INLINE int CListCtrl::GetItemCount() const
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, LVM_GETITEMCOUNT, 0, 0L); }
when I remove the GetItemCount() and tried to insert the item at index 0, the the error is in the following code
Code:
_AFXCMN_INLINE int CListCtrl::InsertItem(int nItem, LPCTSTR lpszItem)
{ ASSERT(::IsWindow(m_hWnd)); return InsertItem(LVIF_TEXT, nItem, lpszItem, 0, 0, 0, 0); }
What could be the problem? It is very strange for me because I am able to add data to the listiview when the size is only about 90 bytes, higher than 90 causes the above assertion error.
If you have encountered this kind of bug and you have found the solution, please give me a hint. I would highly appreciate that. Thanks!
I am inviting you to join GreenZap. It is just like PAYPAL but it is more rewarding! You get $25 when you join (FREE to sign up) AND you get rewarded also when someone opened an account using your GreenZap promo code! GreenZap is launching June 1st.
Click here and PREREGISTER
Have a break. Visit JonelsPlace
-
September 30th, 2004, 08:50 PM
#2
Re: CListCtrl Bug
Additional:
When browsing the registry key:
My Computer\HKEY_CURRENT_USER\Control Panel\Appearance\Schemes
and calling GetListCtrl() m_hWnd of ListCtrl becomes NULL. Do you know why it happens?
Ok, let me tell you more. In accessing the above registry key, I get the maximum data size by using RegQueryInfoKey. The maximum data size is 712 bytes. I have a loop that iterates 712 times to convert the data to string format. As you may know, a data whose type is REG_BINARY or REG_DWORD etc cannot be added to the list because they are not in string format. So I write a function that will convert the data from its format to string format.
After the conversion (after 712 iterations), I then call the GetItemCount() method of CListCtrl so that I can add the data to correct position in the list. But in doing so, I get an assertion error because m_hWnd of CListCtrl becomes NULL. Note, this only happens when browsing My Computer\HKEY_CURRENT_USER\Control Panel\Appearance\Schemes There is no problem when browsing other registry key.
Anybody know why this happen?
I am inviting you to join GreenZap. It is just like PAYPAL but it is more rewarding! You get $25 when you join (FREE to sign up) AND you get rewarded also when someone opened an account using your GreenZap promo code! GreenZap is launching June 1st.
Click here and PREREGISTER
Have a break. Visit JonelsPlace
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|