Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Control the AutoPlay feature Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
11-Sep-02
Category
Multimedia
Language
Delphi All Versions
Views
53
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: William Gerbert

Control the AutoPlay feature

Answer:

You know how to stop Windows' [CD-ROM] AutoPlay from occurring by holding SHIFT or 
by changing Windows settings. 

Here's how to detect whether an AutoPlay is about to occur from your application 
and then either allowing or stopping it. 

We're going to ask Windows to send us a message when the AutoPlay is about to 
occur. In order to catch this message, first of all we have to override our default 
Windows message handler -- "WndProc()." 

You can do this by inserting the following code in your form's (named "Form1" for 
example) public declarations section:


MsgID_QueryCancelAutoPlay: Word;

procedure WndProc(var Msg: TMessage); override;


Now, type in the following code in the "implementation" section (again, assuming 
that your form is named "Form1") to actually handle the Windows messages. As you 
can see, we're only interested in catching "QueryCancelAutoPlay" messages, so we'll 
let the default (or the inherited) "WndProc()" handle all other messages.


1   procedure TForm1.WndProc(var Msg: TMessage);
2   begin
3     if Msg.Msg = MsgID_QueryCancelAutoPlay then
4     begin
5       { set Msg.Result
6          to 1 to stop AutoPlay or
7          to 0 to continue with AutoPlay }
8       Msg.Result := 1;
9     end
10    else
11      inherited WndProc(Msg);
12  end;



Finally, we have to ask Windows to actually send a "QueryCancelAutoPlay" message to 
our message handler by inserting the following code in the "FormCreate()" event 
(click on your form, go to the "events" tab in the "Object Inspector" and double 
click on "Create"):


MsgID_QueryCancelAutoPlay := RegisterWindowMessage('QueryCancelAutoPlay');

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC