Exemplo n.º 1
0
        protected override void WndProc(ref System.Windows.Forms.Message m)
        {
            const int WM_DRAWCLIPBOARD = 0x308;
            const int WM_CHANGECBCHAIN = 0x030D;

            switch (m.Msg)
            {
            case WM_DRAWCLIPBOARD:
                if (!firstTime)
                {
                    if (sh.IsDone())
                    {
                        sh.Speak(Clipboard.GetText());
                    }
                }
                WinAPI.SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);
                firstTime = false;
                break;

            case WM_CHANGECBCHAIN:
                if (m.WParam == nextClipboardViewer)
                {
                    nextClipboardViewer = m.LParam;
                }
                else
                {
                    WinAPI.SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);
                }
                break;

            default:
                base.WndProc(ref m);
                break;
            }
        }
Exemplo n.º 2
0
        protected override void WndProc(ref System.Windows.Forms.Message m)
        {
            const int WM_DRAWCLIPBOARD = 0x308;
            const int WM_CHANGECBCHAIN = 0x030D;

            switch (m.Msg)
            {
            case WM_DRAWCLIPBOARD:
                if (!firstTime)
                {
                    try
                    {
                        if (sh.IsDone())
                        {
                            sh.Speak(Clipboard.GetText());
                        }
                    }
                    catch (System.Runtime.InteropServices.COMException e)
                    {
                        MessageBox.Show("COM exception: " + e.StackTrace + ", " + e.Message + "\nInner exception: " + e.InnerException.StackTrace + " " + e.InnerException.Message);
                    }
                }
                WinAPI.SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);
                firstTime = false;
                break;

            case WM_CHANGECBCHAIN:
                if (m.WParam == nextClipboardViewer)
                {
                    nextClipboardViewer = m.LParam;
                }
                else
                {
                    WinAPI.SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);
                }
                break;

            default:
                base.WndProc(ref m);
                break;
            }
        }