找回密码  加入

AUTOIT CN

搜索
查看: 131|回复: 4

请教,窗口最大化后控件位置的问题

[复制链接]
发表于 2021-10-13 16:30:53 | 显示全部楼层 |阅读模式
  1. #include <ButtonConstants.au3>
  2. #include <EditConstants.au3>
  3. #include <GUIConstantsEx.au3>
  4. #include <GuiIPAddress.au3>
  5. #include <ListViewConstants.au3>
  6. #include <StaticConstants.au3>
  7. #include <TreeViewConstants.au3>
  8. #include <WindowsConstants.au3>
  9. #Region ### START Koda GUI section ### Form=
  10. $Form1 = GUICreate("Form1", 836, 650, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
  11. $TreeView1 = GUICtrlCreateTreeView(8, 8, 145, 489, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
  12. GUICtrlSetResizing($TreeView1, 2+32+64+256)
  13. $Input1 = GUICtrlCreateInput("Input1", 8, 504, 145, 21)
  14. GUICtrlSetResizing($Input1, 2+64+768)
  15. $IPAddress1 = _GUICtrlIpAddress_Create($Form1, 8, 531, 145, 21)
  16. GUICtrlSetResizing($IPAddress1, 2+64+768)
  17. _GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")
  18. $Button1 = GUICtrlCreateButton("Button1", 8, 557, 145, 25)
  19. GUICtrlSetResizing($Button1, 2+64+768)
  20. $Button2 = GUICtrlCreateButton("Button2", 8, 584, 145, 25)
  21. GUICtrlSetResizing($Button2, 2+64+768)
  22. $Group1 = GUICtrlCreateGroup("Group1", 160, 8, 473, 65)
  23. GUICtrlSetResizing($Group1, 2+32+512)
  24. $Label1 = GUICtrlCreateLabel("Label1", 184, 32, 68, 17)
  25. GUICtrlSetResizing($Label1, 2+32)
  26. $IPAddress2 = _GUICtrlIpAddress_Create($Form1, 384, 32, 130, 21)
  27. _GUICtrlIpAddress_Set($IPAddress2, "0.0.0.0")
  28. $Button3 = GUICtrlCreateButton("Button3", 536, 32, 75, 25)
  29. GUICtrlSetResizing($Button3, 32+512)
  30. GUICtrlCreateGroup("", -99, -99, 1, 1)
  31. $Group2 = GUICtrlCreateGroup("Group2", 160, 80, 473, 513)
  32. GUICtrlSetResizing($Group2, 2+32+64)
  33. $ListView1 = GUICtrlCreateListView("", 184, 112, 202, 302)
  34. GUICtrlSetResizing($ListView1, 2+32+64)
  35. $ListView2 = GUICtrlCreateListView("", 400, 112, 202, 302)
  36. GUICtrlSetResizing($ListView2,32+64)
  37. $Input2 = GUICtrlCreateInput("Input2", 184, 440, 201, 21)
  38. GUICtrlSetResizing($Input2, 2+64+512)
  39. $Input3 = GUICtrlCreateInput("Input3", 400, 440, 201, 21)
  40. GUICtrlSetResizing($Input3, 64+512)
  41. $Button4 = GUICtrlCreateButton("Button4", 184, 472, 203, 25)
  42. GUICtrlSetResizing($Button4, 2+64+512)
  43. $Button5 = GUICtrlCreateButton("Button5", 400, 472, 203, 25)
  44. GUICtrlSetResizing($Button5, 64+512)
  45. GUICtrlCreateGroup("", -99, -99, 1, 1)
  46. $Group3 = GUICtrlCreateGroup("Group3", 640, 16, 185, 577)
  47. GUICtrlSetResizing($Group3, 4+32+64)
  48. $TreeView2 = GUICtrlCreateTreeView(648, 32, 169, 473)
  49. GUICtrlSetResizing($TreeView2, 4+32+64)
  50. $Input4 = GUICtrlCreateInput("Input4", 648, 512, 169, 21)
  51. GUICtrlSetResizing($Input4, 4+64+512)
  52. $Button6 = GUICtrlCreateButton("Button6", 648, 544, 171, 25)
  53. GUICtrlSetResizing($Button6, 4+64+512)
  54. GUICtrlCreateGroup("", -99, -99, 1, 1)
  55. GUISetState(@SW_SHOW)
  56. #EndRegion ### END Koda GUI section ###

  57. While 1
  58.         $nMsg = GUIGetMsg()
  59.         Switch $nMsg
  60.                 Case $GUI_EVENT_CLOSE
  61.                         Exit

  62.         EndSwitch
  63. WEnd
复制代码
请教下窗口最大化后,IP控件位置如何调整。  右侧控件最大化后也需要保持放大,中间控件的相对位置如何调整。

发表于 2021-10-13 18:04:20 | 显示全部楼层
相对坐标,可根据窗口大小来设置吧。AFAN的正则工具是自适应的。
 楼主| 发表于 2021-10-13 18:58:17 | 显示全部楼层
862228699 发表于 2021-10-13 18:04
相对坐标,可根据窗口大小来设置吧。AFAN的正则工具是自适应的。

下了,看不懂大神的软件,  新手,不懂正则,
发表于 2021-10-14 10:46:29 | 显示全部楼层
可以注册Windows消息,当窗口大小发生改变时,调整IP控件的位置和大小
下面的例子调整了一个IP控件供参考:
  1. #include <ButtonConstants.au3>
  2. #include <EditConstants.au3>
  3. #include <GUIConstantsEx.au3>
  4. #include <GuiIPAddress.au3>
  5. #include <ListViewConstants.au3>
  6. #include <StaticConstants.au3>
  7. #include <TreeViewConstants.au3>
  8. #include <WindowsConstants.au3>

  9. #Region ### START Koda GUI section ### Form=
  10. $Form1 = GUICreate("Form1", 836, 650, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
  11. $TreeView1 = GUICtrlCreateTreeView(8, 8, 145, 489, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
  12. GUICtrlSetResizing($TreeView1, 2+32+64+256)
  13. $Input1 = GUICtrlCreateInput("Input1", 8, 504, 145, 21)
  14. GUICtrlSetResizing($Input1, 2+64+768)
  15. $IPAddress1 = _GUICtrlIpAddress_Create($Form1, 8, 531, 145, 21)
  16. GUICtrlSetResizing($IPAddress1, 2+64+768)
  17. _GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")
  18. $Button1 = GUICtrlCreateButton("Button1", 8, 557, 145, 25)
  19. GUICtrlSetResizing($Button1, 2+64+768)
  20. $Button2 = GUICtrlCreateButton("Button2", 8, 584, 145, 25)
  21. GUICtrlSetResizing($Button2, 2+64+768)
  22. $Group1 = GUICtrlCreateGroup("Group1", 160, 8, 473, 65)
  23. GUICtrlSetResizing($Group1, 2+32+512)
  24. $Label1 = GUICtrlCreateLabel("Label1", 184, 32, 68, 17)
  25. GUICtrlSetResizing($Label1, 2+32)
  26. $IPAddress2 = _GUICtrlIpAddress_Create($Form1, 384, 32, 130, 21)
  27. _GUICtrlIpAddress_Set($IPAddress2, "0.0.0.0")
  28. $Button3 = GUICtrlCreateButton("Button3", 536, 32, 75, 25)
  29. GUICtrlSetResizing($Button3, 32+512)
  30. GUICtrlCreateGroup("", -99, -99, 1, 1)
  31. $Group2 = GUICtrlCreateGroup("Group2", 160, 80, 473, 513)
  32. GUICtrlSetResizing($Group2, 2+32+64)
  33. $ListView1 = GUICtrlCreateListView("", 184, 112, 202, 302)
  34. GUICtrlSetResizing($ListView1, 2+32+64)
  35. $ListView2 = GUICtrlCreateListView("", 400, 112, 202, 302)
  36. GUICtrlSetResizing($ListView2,32+64)
  37. $Input2 = GUICtrlCreateInput("Input2", 184, 440, 201, 21)
  38. GUICtrlSetResizing($Input2, 2+64+512)
  39. $Input3 = GUICtrlCreateInput("Input3", 400, 440, 201, 21)
  40. GUICtrlSetResizing($Input3, 64+512)
  41. $Button4 = GUICtrlCreateButton("Button4", 184, 472, 203, 25)
  42. GUICtrlSetResizing($Button4, 2+64+512)
  43. $Button5 = GUICtrlCreateButton("Button5", 400, 472, 203, 25)
  44. GUICtrlSetResizing($Button5, 64+512)
  45. GUICtrlCreateGroup("", -99, -99, 1, 1)
  46. $Group3 = GUICtrlCreateGroup("Group3", 640, 16, 185, 577)
  47. GUICtrlSetResizing($Group3, 4+32+64)
  48. $TreeView2 = GUICtrlCreateTreeView(648, 32, 169, 473)
  49. GUICtrlSetResizing($TreeView2, 4+32+64)
  50. $Input4 = GUICtrlCreateInput("Input4", 648, 512, 169, 21)
  51. GUICtrlSetResizing($Input4, 4+64+512)
  52. $Button6 = GUICtrlCreateButton("Button6", 648, 544, 171, 25)
  53. GUICtrlSetResizing($Button6, 4+64+512)
  54. GUICtrlCreateGroup("", -99, -99, 1, 1)
  55. GUISetState(@SW_SHOW)
  56. #EndRegion ### END Koda GUI section ###

  57. GUIRegisterMsg($WM_SIZE, "WM_SIZE") ;注册Windows消息(调整窗口大小时发送此消息)

  58. While 1
  59.         $nMsg = GUIGetMsg()
  60.         Switch $nMsg
  61.                 Case $GUI_EVENT_CLOSE
  62.                         Exit

  63.         EndSwitch
  64. WEnd

  65. Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
  66.     #forceref $Msg, $wParam

  67.         Local $aPos
  68.         $aPos = WinGetPos($Form1) ;获取窗口的坐标位置和大小
  69.         ControlMove($Form1, "", $IPAddress1, Default, $aPos[3] - (650-531)) ;移动IP控件位置

  70.     Return $GUI_RUNDEFMSG
  71. EndFunc
复制代码


发表于 2021-10-15 22:03:37 | 显示全部楼层
opt GUIResizeMode
GUICtrlSetResizing
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|小黑屋|手机版|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2021-10-24 17:43 , Processed in 0.234377 second(s), 28 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表