Solved

Exceptions in Listview's NM_DBLCLK lock Listview

Posted on 1997-12-25
4
586 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
Comment Utility
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
Comment Utility
Also, C++ exceptions are *not* Win32 exceptions.  VC just has a mechanism to handle them in a similar fasion.
0
 

Author Comment

by:giltayar
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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