Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / March 2007

Tip: Looking for answers? Try searching our database.

Sending chars between VB6 and C#.NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Miro - 31 Mar 2007 08:06 GMT
Hello!

I'm using windows messages and the LParam parameter to send chars as ASCII
numbers from VB6 to C#. How can I retrieve the right int value from the
IntPtr in .NET?

My code:

protected override void WndProc(ref Message m)
{
 if (m.Msg == VB6_TO_CSHARP_MessageId.ToInt32())
 {
   int test = m.LParam.ToInt32();
   String test2 = m.GetLParam(typeof(int)).ToString();
   ...
 }
}

test is a long number (for instance 1234621) and test2 is usually "0". I've
dubugged the vb6 app to make sure the sent value is correct.
Mattias Sjögren - 31 Mar 2007 09:43 GMT
>I'm using windows messages and the LParam parameter to send chars as ASCII
>numbers from VB6 to C#. How can I retrieve the right int value from the
>IntPtr in .NET?

What does the SendMessage code on the VB6 side look like?

To pass data buffers between processes, you typically have to use the
WM_COPYDATA message.

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Miro - 31 Mar 2007 15:28 GMT
The code is as follows. Is it enough to change the MessageID to WM_COPYDATA
or do I have to create and send a COPYDATASTRUCT? I f you have some code I
would be grateful.

Public Function SendMessageToCSharp(theChar As Integer)
   Dim hwndTarget As Long
   Dim MessageId As Long

   If WindowMessagingInitialised = False Then
     InitWindowMessaging
   End If

   'Get TargetWindow handle from global Window Name
   hwndTarget = CSharp_WindowHandle

   'Get MessageId from API call to RegisterMessage
   MessageId = VB6_TO_CSharp_MessageId

   'If Window target exists, then SendMessage to target
   If hwndTarget <> 0 Then
       Call PostMessage(hwndTarget, MessageId, o, theChar)
   End If
 End Function

> >I'm using windows messages and the LParam parameter to send chars as ASCII
> >numbers from VB6 to C#. How can I retrieve the right int value from the
[quoted text clipped - 6 lines]
>
> Mattias

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.