Solved

Exceptions in Listview's NM_DBLCLK lock Listview

Posted on 1997-12-25
4
603 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

728 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