Share

Win32++

Subscribe

Problems after upgrade from 6.5 to 6.61

  1. 2009-09-22 09:05:17 UTC

    Hi,

    First I'll say thanks for providing this framework. I needed to de-mfc some code and Win32++ has been a godsend. Sadly after updating to 6.61 from 6.5 I have had some trouble.

    One problem was easy to track down and fix. The destructor of CDialog no longer calls Destroy() so my code crashed when a CDialog object was destroyed without first closing the dialog. Not a big problem but I'm curious as to why you made that change.

    The second problem has me baffled. One dialog has a listview which was working fine in 6.5 (after I fixed the GetItemData() bug. Sorry about that unnecessary bug report.) but now clicking an item in the listview causes a crash.

    My code handles listview selection changes in the dialog's OnNotify(). Looking at dialog.h, I can see that the WM_NOTIFY block in DialogProcDefault() has been cut down and I *think* this may be the source of my problem but I have to admit that some of this stuff is a bit over my head.

    Nothing has changed other than the Win32++ version but now the calls to GetItemData() are returning a bad pointer where previously everything worked perfectly. Please could you explain why the WM_NOTIFY code was changed and what impact the changes have on how notifications from child controls, especially listview controls, should be handled?

    Thanks

  2. 2009-09-22 10:11:09 UTC

    ^^ Sorry, I meant TreeView not ListView ^^

  3. 2009-09-22 21:07:32 UTC

    Thanks for your message.

    Regarding Destroy() in CDialog's destructor: Yes you are quite correct. This problem was introduced in version 6.61 and was fixed a couple of days ago in the code I submitted via Tortoise SVN at SourceForge. You might like to use SVN to download the latest code.

    Regarding changes to CDialog's handling of WMNOTIFY: The older code wasn't causing a problem, but it was changed to bring it in line with the way CWnd handles WMNOTIFY. With the the change, there are more restrictions on when OnNotifyReflect is called. OnNotifyReflect would allow you to hand the notifications sent by the TreeView to be handled in your TreeView class.

    In your case it seems you are not using OnNotifyReflect. You handle the notifications directly in your Dialog's class instead (which is fine). It is difficult at this stage to see how the changes to the handling of WM_NOTIFY would affect the program in the way you describe.

    At the risk of stating the obvious, the pointer returned by GetItemData() could actually be bad if the variable/object it points to has dropped out of scope by the time the notification is dealt with. To keep the variable/object in scope it would need to be something like a member of your class, not a local variable within a function.

    Hope this helps, David

  4. 2009-09-28 15:48:07 UTC

    Hello David,

    I found the source of my problem and you're right that it has nothing to do with the handling of WM_NOTIFY. CTreeView::GetItemData() has a bug:

    On line line 205 of treeview.h:

    TreeViewGetItem( mhWnd, hItem );

    should be

    TreeViewGetItem( mhWnd, &tvi );

    Thanks again.

  5. 2009-09-29 04:22:56 UTC

    Thanks for pointing this out. I've incorporated this bug fix into the code available for download via SVN at SourceForge.

    Best regards, David

  6. 2009-09-30 20:26:31 UTC

    Thanks. Downloaded :¬)

< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.