/pygments/samples/demo/tooltip_demo.ahk

http://github.com/tinku99/ahklexers · AutoHotKey · 137 lines · 104 code · 23 blank · 10 comment · 18 complexity · e28df3bd501d2895be2ea8ebc38da9f4 MD5 · raw file

  1. ; #Include tooltip.ahk
  2. #NoEnv
  3. SendMode Input
  4. SetWorkingDir %A_ScriptDir%
  5. ; Demo Script by HotKeyIt
  6. ;-- Build GUI
  7. gui -MinimizeBox
  8. Gui +LastFound
  9. GuiHwnd:=WinExist()
  10. gui Add,Button,w150 hwndButton1_hWnd gButton1,Test Button 1
  11. Tip:="Button 1: Press me to change my tooltip"
  12. ToolTip(1,Tip,"","A" . Button1_hWnd . " P" . GuiHwnd)
  13. gui Add,Button,y+0 w150 hwndButton2_hWnd gButton2,Test Button 2
  14. Tip:="Button 2: Press me to turn off the tooltip for this button"
  15. ToolTip(2,Tip,"","A" . Button2_hWnd . " P" . GuiHwnd)
  16. gui Add,Button,y+0 w150 hwndButton3_hWnd gButton3,Test Button 3
  17. Tip=
  18. (ltrim
  19. A Multiline Test Tooltip
  20. 2nd line
  21. 3rd line
  22. 4th line.
  23. Press me to turn off all tooltips
  24. )
  25. ToolTip(3,Tip,"","A" . Button3_hWnd . " P" . GuiHwnd)
  26. gui Add,Checkbox,w150 hwndCheckbox_hWnd,Checkbox Control
  27. Tip:="Tooltip for the Checkbox control"
  28. ToolTip(4,Tip,"","A" . Checkbox_hWnd . " P" . GuiHwnd)
  29. gui Add,Radio,w150 hwndRadio_hWnd,Radio Control
  30. Tip:="Tooltip for the Radio control"
  31. ToolTip(5,Tip,"","A" . Radio_hWnd . " P" . GuiHwnd)
  32. gui Add,Edit,w150 hwndEdit_hWnd,Edit Control
  33. Tip:="Tooltip for the Edit control"
  34. ToolTip(6,Tip,"","A" . Edit_hWnd . " P" . GuiHwnd)
  35. gui Add,Text,w150 hwndText_hWnd gNull,Text Control
  36. Tip=
  37. (ltrim join`s
  38. Tooltip for the Text control.`nNote that the Tooltip for a Text control does
  39. not show unless a g-label for the control is defined.
  40. )
  41. ToolTip(7,Tip,"","A" . Text_hWnd . " P" . GuiHwnd)
  42. gui Add,Picture,w150 h100 hwndPicture_hWnd gNull,Picture.bmp
  43. Tip=
  44. (ltrim join`s
  45. Tooltip for the Picture control.`nNote that the Tooltip for a Picture
  46. control does not show unless a g-label for the control is defined.
  47. )
  48. ToolTip(9,Tip,"","A" . Picture_hWnd . " P" . GuiHwnd)
  49. gui Add,DropDownList,w150 r3 hwndDropDownList_hWnd,DropDownList Control||2|3
  50. Tip:="Tooltip for the DropDownList control"
  51. ToolTip(10,Tip,"","A" . DropDownList_hWnd . " P" . GuiHwnd)
  52. gui Add,ComboBox,w150 r3 hwndComboBox_hWnd,ComboBox Control||2|3
  53. ;-- A ComboBox is actually two controls: An Edit control and a Drop-down
  54. ; button. Note that handle returned for this control is for the
  55. ; drop-down button, not for the Edit control.
  56. Tip=
  57. (ltrim join`s
  58. Tooltip for the drop-down button piece of the ComboBox control.`nNote that
  59. this tip is different than the Edit piece of the control.
  60. )
  61. ToolTip(11,Tip,"","A" . ComboBox_hWnd . " P" . GuiHwnd)
  62. gui Add,ListBox,w150 r3 hwndListBox_hWnd,ListBox Control||2|3
  63. Tip:="Tooltip for the ListBox control"
  64. ToolTip(12,Tip,"","A" . ListBox_hWnd . " P" . GuiHwnd)
  65. gui Add,ListView,w150 h50 hwndListView_hWnd,ListView Control
  66. Tip=
  67. (ltrim join`s
  68. Tooltip for the ListView control.`nNote that this tip is different than
  69. the header piece of the control.
  70. )
  71. ToolTip(13,Tip,"","A" . ListView_hWnd . " P" . GuiHwnd)
  72. gui Add,DateTime,w150 hwndDateTime_hWnd ;,DateTime Control
  73. Tip:="Tooltip for the DateTime control"
  74. ToolTip(14,Tip,"","A" . DateTime_hWnd . " P" . GuiHwnd)
  75. gui Add,UpDown,hwndUpDown_hWnd Range 1-100,5
  76. Tip:="Tooltip for the UpDown control"
  77. ToolTip(20,Tip,"","A" . UpDown_hWnd . " P" . GuiHwnd)
  78. gui Show,,Tooltip Test
  79. ;-- Note: The following information cannot be collected until after the window
  80. ; has been rendered
  81. ;-- Get hWnd to the Edit control piece of the ComboBox
  82. ControlGet EditComboBox_hWnd,hWnd,,Edit2,Tooltip Test
  83. Tip=
  84. (ltrim join`s
  85. Tooltip for the Edit piece of the ComboBox control.`nNote that this tip is
  86. different than the drop-down button piece of this control.
  87. )
  88. ToolTip(11,Tip,"","A" . EditComboBox_hWnd . " P" . GuiHwnd)
  89. ;-- Get hWnd to the Edit control piece of the ComboBox
  90. ControlGet ListViewHeader_hWnd,hWnd,,SysHeader321,Tooltip Test
  91. Tip=
  92. (ltrim join`s
  93. Tooltip for the header of the ListView control.`nNote that this tip is
  94. different than the rest of the ListView control.
  95. )
  96. ToolTip(13,Tip,"","A" . ListViewHeader_hWnd . " P" . GuiHwnd)
  97. return
  98. Button1:
  99. ToolTip(1,"Button 1: New Text","","AButton1 P" . GuiHwnd)
  100. return
  101. Button2:
  102. ToolTip(2)
  103. return
  104. Button3:
  105. ToolTip()
  106. MsgBox 64,ToolTips Cleared,All Tooltips destroyed. %A_Space%
  107. return
  108. Null:
  109. return
  110. GUIClose:
  111. GUIescape:
  112. Gui,Destroy
  113. ExitApp
  114. Return