I have a VB6 application where a user selects an item from a list and then clicks a command button to access that item. The item is retrieved from a database by making a long database call. Prior to the call I set the Screen.MousePointer to vbHourglass. If the user clicks another item from a list and then clicks a command button to access the item, those mouse click messages are queued. If the user task switches to another Windows application, the queued messages process which generates another databse transaction that collides with the first.

Why does the act of task switching cause those queued messages to process? Can this be prevented?

I've tried using subclassing to re-route the messages and was able to get it to work in a simple VB project but had much trouble trying to get it to work in this mature VB app.