if not Assigned(frmWhFunc) then
frmWhFunc := TfrmWhFunc.Create(Application);
frmWhFunc.ParentWindow:= AppHnd;
frmWhFunc.Align := alClient;
frmWhFunc.BorderStyle:= bsNone;//该句导致键盘失效
frmWhFunc.Show;
修改如下:
if not Assigned(frmWhFunc) then
frmWhFunc := TfrmWhFunc.Create(Application);
frmWhFunc.ParentWindow:= AppHnd;
frmWhFunc.Align := alClient;
frmWhFunc.WindowState := wsMaximized;
SetWindowLong(frmWhFunc.Handle,GWL_STYLE,GetWindowLong(frmWhFunc.Handle,GWL_STYLE) and not (WS_CAPTION or WS_THICKFRAME));//其中WS_CAPTION和WS_THICKFRAME分别表示标题栏和边框
SetParent(frmWhFunc.Handle,AppHnd);//设置主从窗体
MoveWindow(frmWhFunc.Handle, 0,0, frmWhFunc.Width, frmWhFunc.Height, True);//移动窗体位置
frmWhFunc.Show;
AppHnd为exe传入的tab句柄
本文介绍了一种解决在Delphi中创建无边框窗口时键盘输入失效的问题的方法。通过调整窗口样式并使用SetParent和MoveWindow函数,确保了全屏无边框窗口能够正确接收键盘输入。
1万+

被折叠的 条评论
为什么被折叠?



