Cancel Autoplay

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
Post Reply
Gian Lorenzetto
In need of some credit
In need of some credit
Posts: 3
Joined: Wed Oct 08, 2008 5:53 am
Location: Melbourne

Cancel Autoplay

Post by Gian Lorenzetto » Thu Aug 20, 2009 2:59 am

Hi all,

This is less of a question and more of a tip for people running Vista and XP (possibly older versions), so apologies if I've posted this in the wrong location!

To cancel the autoplay facility in Windows (tested in Vista, but I believe it also works in XP), you must first override the MSWWindowProc function in a class derived from wxWindow (a wxFrame is a good choice). You then register for the QueryCancelAutoplay message and handle it accordingly. For example:

Code: Select all

WXLRESULT MyFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
	static WXLRESULT ALLOW_AUOTRUN = 0;
	static WXLRESULT CANCEL_AUOTRUN = 1;

	static WXUINT QUERYCANCELAUTORUN_MESSAGE_ID = RegisterWindowMessage("QueryCancelAutoplay");

	if (message == QUERYCANCELAUTORUN_MESSAGE_ID)
	{
		return CANCEL_AUOTRUN;
	}

        // must propagate all other messages
	return wxFrame::MSWWindowProc(message, wParam, lParam);
}
One caveat, the window must be open (not hidden) to receive the event.

It's taken me quite a long time to find this, so hopefully it will save someone else a lot of google'ing!

Cheers,
Gian
It's 2 am .... do you know where your stack pointer is? (Unknown)

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Thu Aug 20, 2009 6:37 am

Good tip, I'll move it to the code dump section where code snippets come to life, and magic happens ;-)

Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

Gian Lorenzetto
In need of some credit
In need of some credit
Posts: 3
Joined: Wed Oct 08, 2008 5:53 am
Location: Melbourne

Post by Gian Lorenzetto » Thu Aug 20, 2009 6:54 am

Ah yes, the Code Dump section ... should be more aptly named really, very confusing ;)
It's 2 am .... do you know where your stack pointer is? (Unknown)

Post Reply