コード例 #1
0
 // 是否加载
 public bool UnLoad()
 {
     if (m_hWndChildClientProcNew != null)
     {
         GridNumberForm.SetWindowLong(m_hWndChildHandle, -4, m_hWndChildProcOld);
         GridNumberForm.SetWindowLong(m_hWndChildClientHandle, -4, m_hWndChildClientProcOld);
         return(false);
     }
     return(true);
 }
コード例 #2
0
        // 子窗口用户句柄
        public IntPtr WndMsgProcChildClient(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
        {
            IntPtr newPtr;

            try
            {
                IntPtr intPtr = GridNumberForm.CallWindowProc(m_hWndChildClientProcOld, hWnd, msg, wParam, lParam);
                if (msg <= 32)
                {
                    //2---窗口被销毁
                    if (msg == 2)
                    {
                        // GWL_WNDPROC// -4	// 为窗口设定一个新的处理函数。
                        GridNumberForm.SetWindowLong(m_hWndChildClientHandle, -4, m_hWndChildClientProcOld);
                        m_hWndChildClientProcNew = null;
                        base.Hide();
                    }
                }
                //512移动鼠标
                else if (msg != 512)
                {
                    switch (msg)
                    {
                    //519按下鼠标中键
                    case 519:
                        m_midButtonDown = true;
                        break;

                    //520释放鼠标中键
                    case 520:
                        m_midButtonDown = false;
                        //MessageBox.Show("释放中键!");
                        break;

                    //521双击鼠标中键
                    case 521:
                    //522中键转动(滚轮)
                    case 522:
                        DrawGridNumText(false);
                        break;
                    }
                }
                else if (m_midButtonDown)
                {
                    DrawGridNumText(false);
                }
                newPtr = intPtr;
            }
            catch (Exception)
            {
                newPtr = IntPtr.Zero;
            }
            return(newPtr);
        }
コード例 #3
0
 // 窗口关闭事件
 private void GridNumberForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (IntPtr.Zero != m_hWndChildClientProcOld)
     {
         // GWL_WNDPROC// -4	// 为窗口设定一个新的处理函数。
         GridNumberForm.SetWindowLong(m_hWndChildClientHandle, -4, m_hWndChildClientProcOld);
     }
     if (IntPtr.Zero != m_hWndChildProcOld)
     {
         GridNumberForm.SetWindowLong(m_hWndChildHandle, -4, m_hWndChildProcOld);
     }
     /*m_font.Dispose();*/
 }
コード例 #4
0
        // 刷新文档和视图
        public void RefreshDocAndView(UIDocument uiDoc)
        {
            if (uiDoc == null)
            {
                return;
            }
            m_uiDoc = uiDoc;
            if (m_GridNumShowMag == null)
            {
                m_GridNumShowMag = new ShowGridNumberManager(uiDoc);
            }
            else
            {
                m_GridNumShowMag.RefreshUIDocument(m_uiDoc);
            }
            IntPtr intPtr = IntPtr.Zero;

            try
            {
                //SendMessageWindows API宏,在WinUser.h中根据是否已定义Unicode被定义为SendMessageW或SendMessageA
                //,这两个函数将指定的消息发送到一个或多个窗口。此函数为指定的窗口调用窗口程序,直到窗口程序处理完消息再返回。
                //而和函数PostMessage不同,PostMessage是将一个消息寄送到一个线程的消息队列后就立即返回。
                //553u 应用程序将WM_MDIGETACTIVE消息发送到多文档界面(MDI)客户端窗口,以检索活动MDI子窗口的句柄。
                m_hWndChildHandle = (IntPtr)SendMessage(m_hMDIChildHandle, 553u, 0, 0);
                if (m_hWndChildProcNew == null)
                {
                    m_hWndChildProcNew = new GridNumberForm.NewWndProc(WndMsgProcChild);
                }
                m_hWndChildProcOld = GridNumberForm.SetWindowLong(m_hWndChildHandle, -4, m_hWndChildProcNew);
                //转换 String 类写入非托管内存
                intPtr = Marshal.StringToHGlobalAnsi("AfxFrameOrView");
                EnumChildWindows(m_hWndChildHandle, new CallBack(EnumMDIChildClient), intPtr);
                if (m_hWndChildClientProcNew == null)
                {
                    m_hWndChildClientProcNew = new GridNumberForm.NewWndProc(WndMsgProcChildClient);
                }
                //SetWindowLong该函数用来改变指定窗口的属性

                m_hWndChildClientProcOld = GridNumberForm.SetWindowLong(m_hWndChildClientHandle, -4, m_hWndChildClientProcNew);
            }
            catch (Exception)
            {
                m_appShowGrid.DrawGridNumber = false;
            }
            finally
            {
                //释放非托管的字符串
                Marshal.FreeHGlobal(intPtr);
            }
        }
コード例 #5
0
        //子窗口句柄
        public IntPtr WndMsgProcChild(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
        {
            IntPtr result;

            try
            {
                //CallWindowProc是将消息信息传送给指定的窗口过程的函数。
                IntPtr intPtr = GridNumberForm.CallWindowProc(m_hWndChildProcOld, hWnd, msg, wParam, lParam);
                //2---窗口被销毁
                if (msg != 2)
                {
                    //5---窗口改变大小
                    if (msg != 5)
                    {
                        switch (msg)
                        {
                        //532调整窗口大小
                        //534移动窗口,通过此消息应用程序可以监视窗口大小和位置也可以修改他们
                        case 532:
                        case 534:
                            DrawGridNumText(false);
                            break;
                        }
                    }
                    else
                    {
                        /*MessageBox.Show("窗口大小改变");*/
                        DrawGridNumText(false);
                    }
                }
                else
                {
                    GridNumberForm.SetWindowLong(m_hWndChildHandle, -4, m_hWndChildProcOld);
                    m_hWndChildProcNew = null;
                    base.Hide();
                }
                result = intPtr;
            }
            catch (Exception)
            {
                result = IntPtr.Zero;
            }
            return(result);
        }