Ejemplo n.º 1
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == (int)ShellAPI.WM.SH_NOTIFY)
            {
                ShellAPI.SHNOTIFYSTRUCT shNotify =
                    (ShellAPI.SHNOTIFYSTRUCT)Marshal.PtrToStructure(m.WParam, typeof(ShellAPI.SHNOTIFYSTRUCT));
                if (this.OnEvent != null)
                {
                    PIDL pidl1 = (!PIDL.IsEmpty(shNotify.dwItem1)) ? new PIDL(shNotify.dwItem1, true) : null;
                    PIDL pidl2 = (!PIDL.IsEmpty(shNotify.dwItem2)) ? new PIDL(shNotify.dwItem2, true) : null;
                    OnEvent(this, new ShellChangeEventArgs(((ShellAPI.SHCNE)m.LParam), pidl1, pidl2));

                    if (pidl1 != null)
                    {
                        pidl1.Free();
                    }
                    if (pidl2 != null)
                    {
                        pidl2.Free();
                    }
                }
            }
        }