Example #1
0
                private void OnString(Ddeml.MONHSZSTRUCT mon)
                    {
                        // Get the string from the hsz string handle.  
                        // TODO: For some reason this does not work correctly.
                        var psz = new StringBuilder(Ddeml.MAX_STRING_SIZE);
                        int length = Ddeml.DdeQueryString(_Context.InstanceId, mon.hsz, psz, psz.Capacity,
                            Ddeml.CP_WINANSI);
                        string str = psz.ToString();

                        var action = DdemlStringActivityType.CleanUp;
                        switch (mon.fsAction)
                            {
                                case Ddeml.MH_CLEANUP:
                                    action = DdemlStringActivityType.CleanUp;
                                    break;
                                case Ddeml.MH_CREATE:
                                    action = DdemlStringActivityType.Create;
                                    break;
                                case Ddeml.MH_DELETE:
                                    action = DdemlStringActivityType.Delete;
                                    break;
                                case Ddeml.MH_KEEP:
                                    action = DdemlStringActivityType.Keep;
                                    break;
                            }

                        var args = new DdemlStringActivityEventArgs(str, action, mon.hTask);

                        if (StringActivity != null)
                            StringActivity(this, args);
                    }
        private void OnString(Ddeml.MONHSZSTRUCT mon)
        {
            // Get the string from the hsz string handle.
            // TODO: For some reason this does not work correctly.
            var psz = new StringBuilder(Ddeml.MAX_STRING_SIZE);
            var length = Ddeml.DdeQueryString(_Context.InstanceId, mon.hsz, psz, psz.Capacity,
                Ddeml.CP_WINANSI);
            var str = psz.ToString();

            var action = mon.fsAction switch
            {
                Ddeml.MH_CLEANUP => DdemlStringActivityType.CleanUp,
                Ddeml.MH_CREATE => DdemlStringActivityType.Create,
                Ddeml.MH_DELETE => DdemlStringActivityType.Delete,
                Ddeml.MH_KEEP => DdemlStringActivityType.Keep,
                _ => DdemlStringActivityType.CleanUp
            };

            var args = new DdemlStringActivityEventArgs(str, action, mon.hTask);

            StringActivity?.Invoke(this, args);
        }
Example #3
0
 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;
 }