Solved

Exceptions in Listview's NM_DBLCLK lock Listview

Posted on 1997-12-25
4
590 Views
Last Modified: 2013-12-03
I have a listview. In the handler for it's NM_DBLCLK, I throw an exception, which is to be caught in the primary message loop of the application. The exception handler shows a dialog box and allows message loop to continue getting/dispatching message.

The problem is that after the dialog box is shown, the listview locks - the scroll bars of the list view work, but no clicking or keyboarding seems to work on it (and no, it's not disabled).

I use VC++ 5 (Service Pack 2) under WinNT/Win95 (explorer 3 or 4) with MFC.

My reasoning is that the listview is not exception safe (remember, C++ exceptions are also Win32 exceptions).

So - is there a workaround, or am I doing something wrong? (and I know that doing the try/catch inside the NM_DBLCLK will probably work, but I'll save that as a last resort, because I do want to handle all my exceptions in a central place)
0
Comment
Question by:giltayar
4 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1409696
I think the problem is that you must return a value when handling NM_DBCLICK since this message is sent in WM_NOTIFY form. Throwning an exeption causes leaving handler fuction without a retun value.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1409697
Also, C++ exceptions are *not* Win32 exceptions.  VC just has a mechanism to handle them in a similar fasion.
0
 

Author Comment

by:giltayar
ID: 1409698
galkin, the Win32 SDK specifically says that NM_DBLCLK's return value is ignored, but thanks anyway.

I think alexo has the right answer. But... It doesn't help (through no fault of his).

My question is: can I throw a *C++* exception so that it will be caught by both SEH handlers and C++ handlers? This way, the listview will catch the exception and probably rethrow it, and then I will catch it and handle it correctly.

I have wracked my brains (and searched the MSDN) in search of an answer, and have come up with none.

BTW, Alexo's answer should be given an A, but I got two answers at the same time, and the grading page asked me only about one of them.

0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 200 total points
ID: 1409699
WM_NOTIFY messages are sent by the list control. When you throw an exception, you are unwinding the stack for the control as well. You shouldn't throw C++ exceptions across messages. So what you would want to do is post yourself a message and then throw the exception during that message. This will allow the control to unwind its stack correctly first and then you can throw the exception.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now