zoukankan      html  css  js  c++  java
  • winform中文本框,软键盘跟随

       private void textBox1_Click(object sender, EventArgs e)
            {
    
                //Control.MousePosition
                Point p = System.Windows.Forms.Cursor.Position;
                run(p.X - 250, p.Y + 30);
            }
            [DllImportAttribute("user32.dll", EntryPoint = "MoveWindow")]
            public static extern bool MoveWindow(System.IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
            /// <summary>
            /// 根据类名和窗口名获取句柄
            /// </summary>
            /// <param name="lpClassName"></param>
            /// <param name="lpWindowName"></param>
            /// <returns></returns>
            [DllImport("user32.dll")]
            public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    
    
            private static void run(int x, int y)
            {
                Process process = Process.Start("SoftBoard.exe");
                IntPtr windowHandle;
                do
                {
                    windowHandle = FindWindow(null, "MainWindow");
                } while (windowHandle == IntPtr.Zero);
                MoveWindow(windowHandle, x, y, 960, 380, true);
    
                
            }
    Process process = Process.Start("SoftBoard.exe");
                    process.WaitForInputIdle();
                    IntPtr str = process.MainWindowHandle;
                    MoveWindow(str, x, y, 515, 262, true);

    句柄有时候找不到,用循环比较靠谱

  • 相关阅读:
    web service基础知识
    saltstack高效运维
    vim与程序员
    主动学习与被动学习
    macos安装postman
    stm32——fmsc控制外部SRAM——小结
    关于头文件中的 static inline函数
    w25qxx的nor flash学习笔记
    C标准:C90、C99、C11_C/C++
    lubuntu16.04.6安装GMP库
  • 原文地址:https://www.cnblogs.com/gaocong/p/8966007.html
Copyright © 2011-2022 走看看