public static KeyBoardForm GetKeyBoardForm(TextBox textBox, string content, BtnCallBack btnCallBack) { try { var form = new KeyBoardForm(); //获得textBox控件显示的真实宽和高 var window = Window.GetWindow(textBox); var windowWidth = SystemParameters.PrimaryScreenWidth; var txtWidth = textBox.ActualWidth; var design_Width = 1920; var width = windowWidth * txtWidth / design_Width; width = width < 500 ? 500 : width; var windowHeight = SystemParameters.PrimaryScreenHeight; var txtHeight = textBox.ActualHeight; var design_Height = 1080; var height = windowHeight * txtHeight / design_Height; var point = textBox.TransformToAncestor(window).Transform(new Point(0, 0)); SetPosition(form, point.X, point.Y + height, width, 180); form.Show(); form.Activate(); form.Bind(textBox, content, btnCallBack); form.okBtn.Focus(); var hwnd = new System.Windows.Interop.WindowInteropHelper(form).Handle; WindowPosMananger.Instance.SetKeyBoardIntptr(hwnd); WindowPosMananger.Instance.SetIntPrt(hwnd, 1); return(form); } catch (Exception ex) { // Logger.WriteError(Log.KeyBoardForm, "获取键盘发生异常", ex); } return(null); }
public static KeyBoardForm GetKeyBoardForm(TextBox textBox, string content, BtnCallBack btnCallBack, double left, double top, double width, double height) { try { KeyBoardForm form = new KeyBoardForm(); SetPosition(form, left, top, width, height); form.Show(); form.Activate(); form.Bind(textBox, content, btnCallBack); form.okBtn.Focus(); IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(form).Handle; WindowPosMananger.Instance.SetKeyBoardIntptr(hwnd); return(form); } catch (Exception ex) { // Logger.WriteError(Log.KeyBoardForm, "获得键盘发生异常", ex); } return(null); }