MsgBox % SetResizeEditGui("可拉伸Edit输入窗口","在此输入任意内容,关闭窗口即提交结果",,,8,False)
/*
Title:窗口标题
Tip:Edit窗口提示文本
Option:窗口属性参数比如+Resize AlwaysOnTop等等,ower窗口编号可以关联父级窗口
Width:Edit控件宽度
Row:Edit行数
IsNumber:是否为仅限数字输入
ParentHwnd:关联上级窗口Hwnd,当上级窗口关闭时本窗口自动关闭
*/
SetResizeEditGui(Title:="",Tip:="",Option:="",Width:=350,Row:=1,IsNumber:=False,ParentHwnd:=0){
Static EditBox
SysGet, CXVSCROLL, 2
SysGet, SM_CYSIZE, 31
SysGet,SM_CYSIZEFRAME ,33
Gui, EGui:Destroy
IsNumber:=IsNumber?"Number":"",SubmitOk:=False
Option:=Option<>""?Option:"+Resize -MaximizeBox +LastFound -MinimizeBox AlwaysOnTop"
Gui, EGui: %Option% hWndhEGui
Gui, EGui:Font,s10 norm
Gui, EGui: add, Edit,x5 y5 w%Width% R%Row% %IsNumber% vEditBox hwndEBox WantTab +Wrap Lowercase,
if (Row>1&&Tip<>"")
GuiControl,EGui:,EditBox,% Tip
Else if (Row=1&&Tip<>"")
DllCall("user32\SendMessage", "ptr", EBox, "uint", EM_SETCUEBANNER:=0x1501, "int", true, "str", Tip, "int")
GuiControlGet,ebpos,EGui:Pos,EditBox
EditBoxWidth:=Row>1?ebposW+CXVSCROLL/A_ScreenDPI/96+10:ebposW+10,EditBoxHeight:=ebposH+10
Gui, EGui: Show,w%EditBoxWidth% h%EditBoxHeight%, % Title
Gui, EGui:+MinSize%EditBoxWidth%x%EditBoxHeight%
while !(SubmitOk){
if (!WinExist("ahk_id " ParentHwnd)&&ParentHwnd){
Gui, EGui:Destroy
Return
}Else{
continue
}
}
Gui, EGui: Submit, NoHide
Gui, EGui:Destroy
Return EditBox
EGuiGuiSize:
if A_Cursor In SizeNESW,SizeNS,SizeNWSE,SizeWE
{
ControlGetPos , X_Edit, Y_Edit, Width, Height, Edit1
GuiControl, EGui:move, Edit1,% "w" A_GuiWidth-10 " h" A_GuiHeight-10
}
Return
EGuiGuiClose:
SubmitOk:=True
Return
}
现成的可以替代丑陋的inputbox,当作接收变量用的输入窗口
感谢分享
这个东西好看
这不错的