Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Exceptions in Listview's NM_DBLCLK lock Listview

Posted on 1997-12-25
4
Medium Priority
?
622 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 800 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

618 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