Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 16th, 2005, 12:11 PM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default MDI application

I have developed a Windows Form MDI application that can be started by clicking on a file name with a specific extension in Windows Explorer. The MDI parent form is then started up. This form then starts a child form to process the clicked file name. But each time another file name is clicked, a new parent form is started up. How can I achieve that for each click on another file name the same parent form handles the child activation for the clicked file name ?

  #2 (permalink)  
Old November 17th, 2005, 09:32 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Coudlnt find anything in .Net regarding this. U probably will have to resort to the old techniques and
overide WinProc and catch WM_DDE_EXECUTE there to accomplish this.
Configure the registry for DDE commands accordingly.
This article and the links in it 'll help to u out in this regard
http://msdn.microsoft.com/library/de...s/fa_verbs.asp



Regards
Ankur Verma
  #3 (permalink)  
Old November 17th, 2005, 11:28 AM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot, Ankur. I will investigate your solution.

Regards
Walter Vanhimbeeck
  #4 (permalink)  
Old December 7th, 2005, 12:39 AM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Ankur,

I could not find the right information to understand the technique
of working with DDE and WM DDE EXECUTE that you proposed. Can you give more details of refer to some explanation with examples ?

Thanks in advance

Walter Vanhimbeeck

  #5 (permalink)  
Old December 7th, 2005, 05:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Okay, U are working in C# or VB.NET?
  #6 (permalink)  
Old December 7th, 2005, 05:54 AM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am working in C# within Visual Studio 2003

  #7 (permalink)  
Old December 7th, 2005, 10:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Well I worked on your problem for a while and I’ve been able to do pretty much all u wanted to do.

Just follow me.

This namespace is required so add it to your project.

Code:
using System.Runtime.InteropServices;
.
.
.
DDE message constants you will be using later

Code:
        private const int WM_DDE_INITIATE = 0x03E0;
        private const int WM_DDE_EXECUTE  = WM_DDE_INITIATE+8;

        .
        .
        .


U need to map SendMessage so establish DDE communication with the Shell

        
Code:
[DllImport("user32.dll")]
Code:
        public static extern int SendMessage(
            IntPtr h, int m, IntPtr Wp, int Lp);



I mentioned in my previous posts, you have to override WndProc.
so the WndProc..
        
Code:
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
Code:
        protected override void WndProc(ref Message m) 
        {
            // Listen for operating system messages.
            switch (m.Msg)
            {
                case WM_DDE_EXECUTE:

                    MessageBox.Show("WM_DDE_EXECUTE");
                    SendMessage(m.WParam,WM_DDE_ACK,this.Handle,0);

                    break;


                case WM_DDE_INITIATE:

                    MessageBox.Show("WM_DDE_INITIATE");
                    SendMessage(m.WParam,WM_DDE_ACK,this.Handle,0);

                    break;
            }
            base.WndProc(ref m);
        }



I can safely say that almost all your work is done.
Do update the forum with the completed solution once you are through with it.

Regards
Ankur Verma
  #8 (permalink)  
Old December 7th, 2005, 10:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Gosh...

For this to work you need to do some registery entries for your app.

In the registry, associate your application to the desired file type.
Like if you wanted to associate your application to txt file types so that your application could handle dde commands for txt files, your registry entries would look like-


HKEY_CLASSES_ROOT\txtfile\shell\open\command

(Default)
"G:\p2pQueries\2003\WindowsApplication1\bin\Debug\ WindowsApplication1.exe" /dde


HKEY_CLASSES_ROOT\txtfile\shell\open\ddeexec
(Default)
Open("%1")



Regards
Ankur Verma
  #9 (permalink)  
Old December 7th, 2005, 01:36 PM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Ankur,

Thanks a lot for this solution. But I have at least one main question, having only worked with Window Forms from within VS. Must I put this code in the parent Form of my application ?

Best regards,

Walter Vanhimbeeck

  #10 (permalink)  
Old December 7th, 2005, 02:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Ya.

Regards
Ankur Verma




Similar Threads
Thread Thread Starter Forum Replies Last Post
MDI application!!!!! angelboy C# 2005 0 February 23rd, 2007 12:36 PM
MDI application !!!!! angelboy C# 2005 0 February 7th, 2007 06:12 AM
MDI Application phillipjones1988 C# 2005 0 December 3rd, 2006 12:56 AM
MDI Application dayaananthanm VB How-To 1 August 24th, 2006 04:39 PM
MDI application wanted xerxes VB.NET 2002/2003 Basics 0 April 12th, 2006 12:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.