Hi Keith,
sure I can post the code. ;) Here it is:

/** In my sending form **/
public const int WM_COPYDATA = 0x004A;

// this is the data to be send
[StructLayout(LayoutKind.Sequential)]
public struct CopyDataStruct {
  public string ID;
  public int Length;
  public string Data;
}

CopyDataStruct DataStruct = new CopyDataStruct();
DataStruct.ID = 1;
DataStruct.Data = "Sample Text";
DataStruct.Length = DataStruct.Data.Length;
IntPtr WHnd = FindWindow( null, "TestForm");
// that works fine
SendMessage( WHnd, WM_COPYDATA, this.Handle, DataStruct);

/** In my receiving form **/
protected override void WndProc (ref Message m) {
  switch (m.Msg) {
    case WindowMessaging.WM_COPYDATA:
      // Here is nothing happens!! A message with that command seems
      // never be arrived
      CopyDataStruct DataStruct = (CopyDataStruct) m.GetLParam (typeof
CopyDataStruct));
      string s = DataStruct.Data;
      break;
    default:
      base.WndProc(ref m);
      break;
  }
}

That's it! Hope you have an idea!
Curiously is if I send a message with my own message command I can handle
it!!
Thanks and Regards,
Jan

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to