 |
| 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
|
|
|
|

December 7th, 2005, 02:43 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

December 8th, 2005, 06:22 AM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

December 8th, 2005, 07:28 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

December 8th, 2005, 10:17 AM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

December 8th, 2005, 11:22 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Okay, let me see into it.
Regards
Ankur Verma
|
|

December 8th, 2005, 11:26 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

December 8th, 2005, 03:33 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

December 8th, 2005, 03:39 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

December 8th, 2005, 03:57 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

December 9th, 2005, 01:59 AM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |