private void OnLink(Ddeml.MONLINKSTRUCT mon) { // Get the service name from the hszSvc string handle. var psz = new StringBuilder(Ddeml.MAX_STRING_SIZE); var length = Ddeml.DdeQueryString(_Context.InstanceId, mon.hszSvc, psz, psz.Capacity, Ddeml.CP_WINANSI); var service = psz.ToString(); // Get the topic name from the hszTopic string handle. psz = new StringBuilder(Ddeml.MAX_STRING_SIZE); length = Ddeml.DdeQueryString(_Context.InstanceId, mon.hszTopic, psz, psz.Capacity, Ddeml.CP_WINANSI); var topic = psz.ToString(); // Get the item name from the hszItem string handle. psz = new StringBuilder(Ddeml.MAX_STRING_SIZE); length = Ddeml.DdeQueryString(_Context.InstanceId, mon.hszItem, psz, psz.Capacity, Ddeml.CP_WINANSI); var item = psz.ToString(); var args = new DdemlLinkActivityEventArgs( service, topic, item, mon.wFmt, !mon.fNoData, mon.fEstablished, mon.fServer, mon.hConvClient, mon.hConvServer, mon.hTask); LinkActivity?.Invoke(this, args); }
public bool PreFilterTransaction(DdemlTransaction t) { if (t.uType == Ddeml.XTYP_MONITOR) { switch (t.dwData2.ToInt32()) { case Ddeml.MF_CALLBACKS: { // Get the MONCBSTRUCT object. int length = 0; IntPtr phData = Ddeml.DdeAccessData(t.hData, ref length); Ddeml.MONCBSTRUCT mon = (Ddeml.MONCBSTRUCT)Marshal.PtrToStructure(phData, typeof(Ddeml.MONCBSTRUCT)); Ddeml.DdeUnaccessData(t.hData); _Parent.OnCallback(mon); break; } case Ddeml.MF_CONV: { // Get the MONCONVSTRUCT object. int length = 0; IntPtr phData = Ddeml.DdeAccessData(t.hData, ref length); Ddeml.MONCONVSTRUCT mon = (Ddeml.MONCONVSTRUCT)Marshal.PtrToStructure(phData, typeof(Ddeml.MONCONVSTRUCT)); Ddeml.DdeUnaccessData(t.hData); _Parent.OnConversation(mon); break; } case Ddeml.MF_ERRORS: { // Get the MONERRSTRUCT object. int length = 0; IntPtr phData = Ddeml.DdeAccessData(t.hData, ref length); Ddeml.MONERRSTRUCT mon = (Ddeml.MONERRSTRUCT)Marshal.PtrToStructure(phData, typeof(Ddeml.MONERRSTRUCT)); Ddeml.DdeUnaccessData(t.hData); _Parent.OnError(mon); break; } case Ddeml.MF_HSZ_INFO: { // Get the MONHSZSTRUCT object. int length = 0; IntPtr phData = Ddeml.DdeAccessData(t.hData, ref length); Ddeml.MONHSZSTRUCT mon = (Ddeml.MONHSZSTRUCT)Marshal.PtrToStructure(phData, typeof(Ddeml.MONHSZSTRUCT)); Ddeml.DdeUnaccessData(t.hData); _Parent.OnString(mon); break; } case Ddeml.MF_LINKS: { // Get the MONLINKSTRUCT object. int length = 0; IntPtr phData = Ddeml.DdeAccessData(t.hData, ref length); Ddeml.MONLINKSTRUCT mon = (Ddeml.MONLINKSTRUCT)Marshal.PtrToStructure(phData, typeof(Ddeml.MONLINKSTRUCT)); Ddeml.DdeUnaccessData(t.hData); _Parent.OnLink(mon); break; } case Ddeml.MF_POSTMSGS: { // Get the MONMSGSTRUCT object. int length = 0; IntPtr phData = Ddeml.DdeAccessData(t.hData, ref length); Ddeml.MONMSGSTRUCT mon = (Ddeml.MONMSGSTRUCT)Marshal.PtrToStructure(phData, typeof(Ddeml.MONMSGSTRUCT)); Ddeml.DdeUnaccessData(t.hData); _Parent.OnPost(mon); break; } case Ddeml.MF_SENDMSGS: { // Get the MONMSGSTRUCT object. int length = 0; IntPtr phData = Ddeml.DdeAccessData(t.hData, ref length); Ddeml.MONMSGSTRUCT mon = (Ddeml.MONMSGSTRUCT)Marshal.PtrToStructure(phData, typeof(Ddeml.MONMSGSTRUCT)); Ddeml.DdeUnaccessData(t.hData); _Parent.OnSend(mon); break; } } } return true; }