可拉伸Edit输入窗口简单示例.ahk

; By 蜜獾哥

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
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。