tabnation

gui contral move with gui resize

Oct 1st, 2022
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. GuiSize:
  2. if !initSize {
  3. GuiControlGet, c1, Pos, codestring
  4. GuiControlGet, c2, Pos, Button1
  5. GuiControlGet, c3, Pos, Button2
  6. GuiControlGet, c4, Pos, Button3
  7. GuiControlGet, c5, Pos, Button4
  8. GuiControlGet, c6, Pos, Picture1
  9. GuiControlGet, c7, Pos, commandlookup
  10. GuiControlGet, c8, Pos, Search
  11. GuiControlGet, c9, Pos, GroupBox1
  12. GuiControlGet, c10, Pos, synhelp
  13. GuiControlGet, c11, Pos, numlines
  14. GuiControlGet, c12, Pos, Button5
  15.  
  16. initSize := { "gui" : {w:A_GuiWidth, h:A_GuiHeight}
  17. , "Edit1" : {x:c1X, y:c1Y, w:c1W, h:c1H}
  18. , "Button1": {x:c2X, y:c2Y, w:c2W, h:c2H}
  19. , "Button2": {x:c3X, y:c3Y, w:c3W, h:c3H}
  20. , "Button3": {x:c4X, y:c4Y, w:c4W, h:c4H}
  21. , "Button4": {x:c5X, y:c5Y, w:c5W, h:c5H}
  22. , "picture1": {x:c6X, y:c6Y, w:c6W, h:c6H}
  23. , "listbox1": {x:c7X, y:c7Y, w:c7W, h:c7H}
  24. , "Edit2" : {x:c8X, y:c8Y, w:c8W, h:c8H}
  25. , "GroupBox1" : {x:c9X, y:c9Y, w:c9W, h:c9H}
  26. , "synhelp" : {x:c10X, y:c10Y, w:c10W, h:c10H}
  27. , "Edit3" : {x:c11X, y:c11Y, w:c11W, h:c11H}
  28. , "Button5" : {x:c12X, y:c12Y, w:c12W, h:c12H}}
  29.  
  30. lastGuiW := A_GuiWidth
  31. lastGuiH := A_GuiHeight
  32. return
  33. }
  34.  
  35. if (A_EventInfo = 1) ; The window has been minimized.
  36. || (A_GuiWidth = lastGuiW && A_GuiHeight = lastGuiH) { ; The window has been restored (from minimized state)
  37. return
  38. }
  39.  
  40. changedW := A_GuiWidth - initSize.gui.w
  41. changedH := A_GuiHeight - initSize.gui.h
  42.  
  43. GuiControl, Move, codestring, % ("w" initSize.Edit1.w + changedW) . (" h" initSize.Edit1.h + changedH)
  44. GuiControl, Move, Button1 , % ("x" initSize.Button1.x + changedW) . ("y" initSize.Button1.y + changedH)
  45. GuiControl, Move, Button2 , % ("x" initSize.Button2.x + changedW) . ("y" initSize.Button2.y + changedH)
  46. GuiControl, Move, Button3 , % ("x" initSize.Button3.x + changedW) . ("y" initSize.Button3.y + changedH)
  47. GuiControl, Move, Button4 , % ("x" initSize.Button4.x + changedW) . ("y" initSize.Button4.y + changedH)
  48. GuiControl, Move, picture1 , % ("x" initSize.picture1.x + changedW) . ("y" initSize.picture1.y + changedH)
  49. GuiControl, Move, commandlookup , % (" h" initSize.listbox1.h + changedH) . ("x" initSize.listbox1.x + changedW)
  50. GuiControl, Move, Search , % ("x" initSize.edit2.x + changedW)
  51. GuiControl, Move, GroupBox1 , % ("y" initSize.GroupBox1.y + changedH) . ("w" initSize.GroupBox1.w + changedW)
  52. GuiControl, Move, synhelp , % ("y" initSize.synhelp.y + changedH) . ("w" initSize.synhelp.w + changedW)
  53. GuiControl, Move, numlines, % (" h" initSize.Edit3.h + changedH)
  54. GuiControl, Move, Button5 , % ("y" initSize.Button5.y + changedH)
  55.  
  56. lastGuiW := A_GuiWidth
  57. lastGuiH := A_GuiHeight
  58.  
  59. Return
  60.  
  61. saveguisize:
  62. IfWinActive AHK Playground %vmode%
  63. {
  64. gui, submit, nohide
  65. WinGetPos,x,y,w,h,a
  66. IniWrite, %x%, %inihome%, sizenpos, x
  67. IniWrite, %y%, %inihome%, sizenpos, y
  68. IniWrite, %w%, %inihome%, sizenpos, w
  69. IniWrite, %h%, %inihome%, sizenpos, h
  70. }
  71. Return
Advertisement
Add Comment
Please, Sign In to add comment