Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm doing a application like notepad++, but I don't know how to open file into a tabpage when click this file. I know open file when double click it but it runs a new application but into a new tabpage.
Welcome all!
Thank so much!
Posted
Comments
CS2011 21-May-11 10:08am    
Can tell us what you have tried till now ?

I think you want the double click in the file system to open a new tab page in the same app instance ? I think you need to use interprocess communication for your new instance to realise that one exists, pass to it the file to open, then close itself.
 
Share this answer
 
This solution is not very simple; I can only explain the idea here.

Best way to do it in .NET is to use remoting with a channel based on named pipes, using System.Runtime.Remoting.Channels.Ipc.IpcClientChannel and System.Runtime.Remoting.Channels.Ipc.IpcServerChannel. You will be able to use this IPC mechanism for dual purpose: to detect if the current application instance if the first or second one and also for passing file names from the command line of the second to the first instance.

Use remoting interface to communication between first instance of the application and a second one (and never allow for third one). Server part of the remoting interface will be performed by the first instance.

When an instance of your application is running, you need to detect if the another (first) instance is already running. This instance first assumes the first instance is already running and try to connect to it using System.Activator.GetObject. Exception of this operation will mean that the server part is not running, so the current instance is the first one. Then this instance should create the server object and initialize the editor application.

If connection to the server is successful, the instance of application should pass file names from its command line to the first instance. The server object should implement some interface with the method used to pass array of file names to the server object. The server part (with is the first instance) should try to load the files and activate the tab(s) with loaded files. The first instance of the application should also activate itself and show the main form or window on top.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900