Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-20-2006, 06:55 PM
Junior Member
 
Join Date: Feb 2006
Posts: 7
Default Open With

Hi

How do I let an application carry out a function on a file when it is opened with the application?

Bit hard to explain, so an example: I want MyApplication to read MyFile. So I right click MyFile and select 'open with' then choose MyApplication. MyApplication should then open and carry out a function on MyFile to read it.

I expect that this is in the manual, but I can't seem to find it. Help appreciated.

~Mark
Reply With Quote
  #2 (permalink)  
Old 05-22-2006, 11:47 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Open With

1. Use the Application.associate method to associate your file with your application. Then when you double click the file in the Windows Explorer, your application will be launched to open the file. In this case, the Windows explorer just passes the name of the file as a command line parameter to your application

2. Handle the command line parameter
Code:
var cmdItems = Application.cmdItems;
if (cmdItems.length > 0)
{
    var filename = cmdItems[0];
    Dialogs.msgBox(filename + " is opened!");
}
Reply With Quote
  #3 (permalink)  
Old 05-23-2006, 11:18 AM
Junior Member
 
Join Date: Feb 2006
Posts: 7
Default Re:Open With

Hi thanks for the help, that's what I was looking for.

But for some reason it still wont work:

Code:
Application.associate('.ccg', "Demo.type");
var cmdItems = Application.cmdItems;
if (cmdItems.length > 0)
{
    //cmdItems[0] is the name of the file
    Dialogs.msgBox(cmdItems[0]);
}
When I run the application the .ccg files stay associated with Notepad. Could the Demo.type part be incorrect? I was not sure what to put there.

Thanks,
Mark
Reply With Quote
  #4 (permalink)  
Old 05-24-2006, 01:51 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Open With

We have tested it and find that it works.
Code:
Application.associate(".ccg", "CCg.type");
var cmdItems = Application.cmdItems;
if (cmdItems.length > 0 && cmdItems[0] != "con")
{
    //cmdItems[0] is the name of the file
    Dialogs.msgBox(cmdItems[0]);
}
The second argument of the associate method is a unique type identifier of your file. If you want to add menu items into the right click menu in Windows explorer, you would have to add more registry entries. You may find some articles in Microsoft MSDN by searching with the keyword "Shell Extension".
Reply With Quote
  #5 (permalink)  
Old 05-24-2006, 05:54 PM
Junior Member
 
Join Date: Feb 2006
Posts: 7
Default Re:Open With

Thanks, works great
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:43 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.