07 Apr 2014

54523

0

The Sisyphean Bug -- part 2

Over this past week, I continued fixing many small bugs, logic errors and such. Eventually I got to a point where I couldn’t deny the truth anymore.

One of the lessons you are taught when learning to be an engineer (including software programming), and one that some people find hard to accept, is that you should always try to reuse existing processes and components, instead of reinventing your own. Because of that, I tried very hard to let the toolbars manage their own hot-tracking and only intercept hot-tracking events when strictly necessary. But over these past weeks, I noticed that the toolbars made certain assumptions regarding hot-tracking changes, and all my failed attempts at fixing bugs were always traced back to the same place: TBN_HOTITEMCHANGE.

I asked myself to stop and think. I didn’t want to ignore the existing hot-tracking code, so I tried to think of how to make it work right instead. My conclusion was that, although implementing the tracking of the hot item through ignoring the existing system is a waste of existing resources, I had already wasted too much time working around the limitations, when it would be relatively quick and simple to just do it manually. So I took the existing code, and I told it “no, you won’t ask the toolbar to change the hot item, and then update the internal info as a response to the hot item change. You will change the internal tracking info, tell the toolbar about the change, but completely ignore its wishes and draw the hot item only based on the internal tracking info that we already kept.”

This worked, but needed the menubar to be included in the focus manager capturing system, to be able to detect when the mouse left the toolbar. It all seemed to work well, so I went ahead and compiled versions ready for Windows 2003, and ReactOS. I tried ReactOS first, for fun. It worked there, mostly. Not perfectly well, but maybe I could blame the problems on ReactOS and not my code. But then, when I tested the executables in Win2003, I noticed the clicks didn’t get through, at all. The toolbar would receive the WM_LBUTTONDOWN/UP messages, but those messages wouldn’t result in the expected WM_COMMAND, and after trying to fix it over the weekend, I still have no idea why.

 

So this time, here is a sad kitten:

Discussion: https://www.reactos.org/forum/viewtopic.php?f=2&t=13203

This blog post represents the personal opinion of the author and is not representative of the position of the ReactOS Project.