Wrox Programmer Forums
|
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
 
Old December 7th, 2005, 02:43 PM
Friend of Wrox
 
Join Date: Jun 2003
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

Make those 'private const' things data members of your main form class.
The DLLImport part can follow the 'private const' stuff in your main form class declaration
and WndProc will be a member function of your main form class like other functions like
button click handlers, Main etc.

Regards,
Ankur
 
Old December 8th, 2005, 06:22 AM
Authorized User
 
Join Date: Nov 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Ankur,

I introduced the code in the main form of my application. The DDE messages are received and replied. But I think there is something missing: the Main method now gets /dde as command line argument instead of the file name that was clicked. If this was the intention, how should it proceed ?

Best regards,

Walter

 
Old December 8th, 2005, 07:28 AM
Friend of Wrox
 
Join Date: Jun 2003
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 you will not get the file name as command line argument, but you will have to get it out of the LParam that you get with WM_DDE_EXECUTE. Read about the data that you recieve with WM_DDE_EXECUTE message.

Regards
Ankur Verma
 
Old December 8th, 2005, 10:17 AM
Authorized User
 
Join Date: Nov 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Ankur,

Sorry to bother you again but nor the MSDN documentation nor the internet could not help me out to get a C# version on how to retrieve the command string from LParam. It is an ANSI or UNICODE null terminated string, which is probably easy to handle with a C++ library, but not obvious in C#. Do you have an idea ?

Best Regards,

Walter

 
Old December 8th, 2005, 11:22 AM
Friend of Wrox
 
Join Date: Jun 2003
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, let me see into it.

Regards
Ankur Verma
 
Old December 8th, 2005, 11:26 AM
Friend of Wrox
 
Join Date: Jun 2003
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 while i look at it, try those conversion techniques, try things like
Marshal class's function, and those of Covert class etc.
I'm trying myself. But do update the forum if you hit it first

Ankur
 
Old December 8th, 2005, 03:33 PM
Friend of Wrox
 
Join Date: Jun 2003
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

Logic took a back seat to luck today as the solution looks rather simple now that I’ve found it but took me a lot of hit and trial to find it. And they say .NET makes life easier. Maybe, 'cause whose life, they didn’t say.

Well, here's the solution

Define a structure

    struct TestStruct
    {
        [MarshalAs(UnmanagedType.LPTStr)]
        public String strDDECommand;
    }


In your WndProc use GetLParam of Message class to fill this structure


    case WM_DDE_EXECUTE:

        MessageBox.Show("WM_DDE_EXECUTE");


        TestStruct vss = new TestStruct();
        vss = TestStruct)m.GetLParam(vss.GetType());
        MessageBox.Show(vss.strDDECommand);
        SendMessage(m.WParam,WM_DDE_ACK,this.Handle,0);

        break;


On the hindsight I would say that if you look at it, tricky it is but not entirely illogical. But, with so many ways available to do everything in .NET, it’s all too natural to feel disoriented at times.

Your work, however, is done, Walter.
Amazing forum this is, I gotta say.
People get all their work done over here.
What do you say?....kidding.

It was an interesting problem.

Regards
Ankur
 
Old December 8th, 2005, 03:39 PM
Authorized User
 
Join Date: Nov 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Ankur,

Great and amazing what you did. For me this would be like looking for a needle in a haystack. But I missed the whole story of the "old techniques" that appears to be necessary to get something done under Windows that seems so obvious.
Thanks again, I 'll try your solution asap tomorrow.

Best Regards,

Walter

 
Old December 8th, 2005, 03:57 PM
Friend of Wrox
 
Join Date: Jun 2003
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 missed that story myself, (' chuckles ') or should I say
I miss the sweet version of the story 'cause in good old VC++
days, all this indeed used to be quite 'obviously' simple.

C#, however, has its advantages, and i think .NET will have
such capabilites in-built into its future versions.

Nice problem you brought here, though.
Thanks for your contribution to the forum.

Ankur
 
Old December 9th, 2005, 01:59 AM
Authorized User
 
Join Date: Nov 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Ankur,

Sorry to say I'm still not home. Thanks to your contribution I now have the command, from which I can substring the file name. So I tried to feed this file name to the constructor of my parent form. Therefore I declared the variable "TestStruct vss" as a private static of this form. However, when the main method is entered, the value of vss.strDDECommand is (re?)initialised to null. Any idea ?

Best Regards

Walter






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.