MessageBox and the Foreground Window?

  • Thread starter Thread starter Carl Fenley
  • Start date Start date
C

Carl Fenley

I am trying to capture the Windows QueryCancelAutoPlay message that is sent
to the "foreground window" when an AutoRun enabled CD is inserted into a
drive.

Enabling and Disabling AutoRun
http://tinyurl.com/2m26

If my MainForm uses MessageBox.Show to prompt the end-user to insert a CD,
I'd like to know whether MainForm or my MessageBox is the "foreground
window". Any ideas?

Regards,

Carl
 
Carl Fenley said:
I am trying to capture the Windows QueryCancelAutoPlay message that is sent
to the "foreground window" when an AutoRun enabled CD is inserted into a
drive.

Enabling and Disabling AutoRun
http://tinyurl.com/2m26

If my MainForm uses MessageBox.Show to prompt the end-user to insert a CD,
I'd like to know whether MainForm or my MessageBox is the "foreground
window". Any ideas?

Regards,

Carl

I think I just found out the answer is that the MessageBox is the
"foreground window" rather than the Form that instantiated it. If anyone
disagrees with that, please respond in this thread.

Regards,

Carl
 
Dennis said:
Do you have a code fragment that you could share that shows how to disable
AutoRun?
--

I derived my solution from Duncan Mackenzie's sample, which can be found
about half way down the following page:

http://www.duncanmackenzie.net/Samples/default.aspx

Download the ZIP file and run it. Instead of disabling Autorun, you will
see that it "intercepts" the QueryCancelAutoPlay message and handles it. Be
aware that Duncan has added some necessary code to the "Windows Form
Designer generated code" region.

Regards,

Carl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top