Hello everyone,
I have this application which filters keyboard and mouse input by subclassing the drawing window.
The application works fine under A2004 and A2008, however' when porting to A2012 it crashes with 'stack overflow' and erratically with other exceptions.
The application saves the original WNDPROC and the HWND and calls it when needed.
It uses documentBecameCurrent() notification to detect when a new drawing is loaded or when the user switches drawings.
As far I have been able to trace the problem, it seems that documentBecameCurrent() fires more than once and so the saved WNDPROC gets overwritten, thus creating a recursive infinite loop.
I tried to place guards and checks in the reactor against subclassing the same window twice, but it did not work.
So the question is: did AutoCAD's behavior change in regard to notification sequence or subclassing tollerance?
One more detail: the saved proc shows in the debugger as .....AcNavMsgDelegator::DwgWndProc (....... Is'nt this a starange name?
Any help or information will be much appreciated. I'm going crazy over this
I could post some code if needed.
Thanks,
alex
I don't think it's useful to focus on what changed between AutoCAD releases. Better to just make your code robust enough to deal with all eventualities. In your case, I'd use a WH_CBT windows hook to detect and subclass document windows.
Owen,
I'm using SetWindowLong() to point window message processing to my procedure, and it works fine.
The problem appears when switching between drawings.
You mean using WH_CBT hook in addition or instead?
I'm not sure how it can be used to detect Acad notifications.
What is AcNavMsgDelegator?
Thanks,
alex
Owen,
I thought I'll write a progress report:
I was reluctant to use a non familiar hook (WH_CBT) as you suggested, so I tried once more and found a - probably not general - solution.
It seems that at start Acad opens with an empty drawing (called Drawing1 ). When user opens another drawing, Acad closes the initial drawing. During this process, the initial drawing becomes Current (without becoming Active of course).
As my code watches for documentBecameCurrent notification, it subclassed the same window multiple times.
The solution was to check if the documnt is Active and subclass it in this case only.
Thank you for your suggestions,
alex