/lib/CControl.ahk

http://github.com/Skiouros/Macro · AutoHotKey · 585 lines · 390 code · 14 blank · 181 comment · 147 complexity · 3442b1143e626c15ce189e2ea37cfb41 MD5 · raw file

  1. /*
  2. Class: CControl
  3. Basic control class from which all controls extend.
  4. */
  5. Class CControl ;Never created directly
  6. {
  7. __New(Name, Options, Text, GUINum) ;Basic constructor for all controls. The control is created in CGUI.AddControl()
  8. {
  9. ;~ global CFont
  10. this.Insert("Name", Name)
  11. this.Insert("Options", Options)
  12. this.Insert("Content", Text)
  13. this.Insert("GUINum", GUINum) ;Store link to gui for GuiControl purposes (and possibly others later
  14. this.Insert("_", {}) ;Create proxy object to enable __Get and __Set calls for existing keys (like ClassNN which stores a cached value in the proxy)
  15. this.Insert("Font", new CFont(GUINum))
  16. this._.Insert("RegisteredEvents", {})
  17. }
  18. PostCreate()
  19. {
  20. this.Font._.hwnd := this.hwnd
  21. }
  22. /*
  23. Function: Show
  24. Shows the control if it was previously hidden.
  25. */
  26. Show()
  27. {
  28. ;~ global CGUI
  29. if(CGUI.GUIList[this.GUINum].IsDestroyed)
  30. return
  31. Control, Show,,,% "ahk_id " this.hwnd
  32. }
  33. /*
  34. Function: Hide
  35. Hides the control if it was previously visible.
  36. */
  37. Hide()
  38. {
  39. ;~ global CGUI
  40. if(CGUI.GUIList[this.GUINum].IsDestroyed)
  41. return
  42. Control, Hide,,,% "ahk_id " this.hwnd
  43. }
  44. /*
  45. Function: Enable
  46. Enables the control if it was previously diisabled.
  47. */
  48. Enable()
  49. {
  50. Control, Enable,,,% "ahk_id " this.hwnd
  51. }
  52. /*
  53. Function: Disable
  54. Disables the control if it was previously enabled.
  55. */
  56. Disable()
  57. {
  58. Control, Disable,,,% "ahk_id " this.hwnd
  59. }
  60. /*
  61. Function: Focus
  62. Sets the focus to this control.
  63. */
  64. Focus()
  65. {
  66. ;~ global CGUI
  67. if(CGUI.GUIList[this.GUINum].IsDestroyed)
  68. return
  69. ControlFocus,,% "ahk_id " this.hwnd
  70. }
  71. ;~ Font(Options, Font="")
  72. ;~ {
  73. ;~ global CGUI
  74. ;~ if(CGUI.GUIList[this.GUINum].IsDestroyed)
  75. ;~ return
  76. ;~ Gui, % this.GUINum ":Font", %Options%, %Font%
  77. ;~ GuiControl, % this.GUINum ":Font", % this.ClassNN
  78. ;~ Gui, % this.GUINum ":Font", % CGUI.GUIList[this.GUINum].Font.Options, % CGUI.GUIList[this.GUINum].Font.Font ;Restore current font
  79. ;~ }
  80. /*
  81. Validates the text value of this control by calling a <Control.Validate> event function which needs to return the validated (or same) value.
  82. This value is then used as text for the control if it differs.
  83. */
  84. Validate()
  85. {
  86. output := this.CallEvent("Validate", this.Text)
  87. if(output.Handled && output.Result != this.Text)
  88. this.Text := output.result
  89. }
  90. /*
  91. Function: RegisterEvent
  92. Assigns (or unassigns) a function to a specific event of this control so that the function will be called when the event occurs.
  93. This is normally not necessary because functions in the GUI class with the name ControlName_EventName()
  94. will be called automatically without needing to be registered. However this can be useful if you want to handle
  95. multiple events with a single function, e.g. for a group of radio controls. Right now only one registered function per event
  96. is supported, let me know if you need more.
  97. Parameters:
  98. Type - The event name for which the function should be registered. If a control normally calls "GUI.ControlName_TextChanged()", specify "TextChanged" here.
  99. FunctionName - The name of the function specified in the window class that is supposed to handle the event. Specify only the name of the function, skip the class.
  100. */
  101. RegisterEvent(Type, FunctionName)
  102. {
  103. ;~ global CGUI
  104. if(FunctionName)
  105. {
  106. ;Make sure function name is valid (or tell the developer about it)
  107. if(CGUI_Assert(IsFunc(this[FunctionName]), "Invalid function name passed to CControl.RegisterEvent()"), -2)
  108. this._.RegisteredEvents[Type] := FunctionName
  109. }
  110. else
  111. this._.RegisteredEvents.Remove(Type)
  112. }
  113. /*
  114. Calls an event with a specified name by looking up a possibly registered event handling function or calling the function with the default name.
  115. Returns an object with Handled and Result keys, where Handled indicates if the function was successfully called and Result is the return value of the function.
  116. */
  117. CallEvent(Name, Params*)
  118. {
  119. ;~ global CGUI
  120. if(CGUI.GUIList[this.GUINum].IsDestroyed)
  121. return
  122. if(this._.RegisteredEvents.HasKey(Name))
  123. {
  124. if(IsFunc(this[this._.RegisteredEvents[Name]]))
  125. return {Handled : true, Result : this[this._.RegisteredEvents[Name]](CGUI.GUIList[this.GUINum], Params*)}
  126. else if(IsFunc( `(CGUI.GUIList[this.GUINum])[this._.RegisteredEvents[Name]]))
  127. return {Handled : true, Result : `(CGUI.GUIList[this.GUINum])[this._.RegisteredEvents[Name]](Params*)}
  128. }
  129. else if(IsFunc(this[Name]))
  130. return {Handled : true, Result : this[Name](CGUI.GUIList[this.GUINum], Params*)}
  131. else if(IsFunc(`(CGUI.GUIList[this.GUINum])[this.Name "_" Name]))
  132. {
  133. OutputDebug % call this.Name "_" Name
  134. return {Handled : true, Result : `(CGUI.GUIList[this.GUINum])[this.Name "_" Name](Params*)}
  135. }
  136. else
  137. return {Handled : false}
  138. }
  139. /*
  140. Changes the state of controls assigned to an item of another control, making them (in)visible or (de)activating them.
  141. The parameters are the previously selected item object (containing a controls array of controls assigned to it and the new selected item object.
  142. */
  143. ProcessSubControlState(From, To)
  144. {
  145. ;~ global CGUI
  146. if(From != To && !CGUI.GUIList[this.GUINum].IsDestroyed)
  147. {
  148. if(From)
  149. for index, Control in From.Controls
  150. {
  151. if(Control._.UseEnabledState)
  152. Control.Disable()
  153. else
  154. Control.Hide()
  155. }
  156. for index, Control in To.Controls
  157. if(Control._.UseEnabledState)
  158. Control.Enable()
  159. else
  160. Control.Show()
  161. }
  162. }
  163. IsValidatableControlType()
  164. {
  165. return CGUI_IndexOf(["Edit", "ComboBox"], this.Type)
  166. }
  167. /*
  168. Variable: x
  169. x-Position of the control.
  170. Variable: y
  171. y-Position of the control.
  172. Variable: width
  173. Width of the control.
  174. Variable: height
  175. Height of the control.
  176. Variable: Position
  177. An object containing the x and y values. They can not be set separately through this object, only both at once.
  178. Variable: Size
  179. An object containing the width and height values. They can not be set separately through this object, only both at once.
  180. Variable: Text
  181. The text of the control. Some controls don't support this property.
  182. Variable: ClassNN
  183. The control class together with a number identify the control.
  184. Variable: Enabled
  185. Determines wether this control can be interacted with.
  186. Variable: Visible
  187. Determines wether this control is currently visible.
  188. Variable: Style
  189. The style of the control.
  190. Variable: ExStyle
  191. The extended style of the control.
  192. Variable: Focused
  193. True if the control currently has the focus. It's also possible to focus it by setting this value to true.
  194. Variable: Tooltip
  195. If a text is set for this value, this control will show a tooltip when the mouse hovers over it.
  196. Text and Picture controls require that you define a g-label for them to make this work.
  197. Variable: Menu
  198. If this variable contains an instance of <CMenu> and there is no ContextMenu() event handler for this control, this menu will be shown when the user right clicks on this control or presses the AppsKey while this control has focus.
  199. Variable: Left
  200. The control left-aligns its text. This is the default setting.
  201. Variable: Center
  202. The control center-aligns its text.
  203. Variable: Right
  204. The control right-aligns its text.
  205. Variable: TabStop
  206. If set to false, this control will not receive the focus when pressing tab to cycle through all controls.
  207. Variable: Wrap
  208. If enabled, the control will use word-wrapping for its text.
  209. Variable: HScroll
  210. Provides a horizontal scroll bar for this control if appropriate.
  211. Variable: VScroll
  212. Provides a vertical scroll bar for this control if appropriate.
  213. Variable: BackgroundTrans
  214. Uses a transparent background, which allows any control that lies behind a Text, Picture, or GroupBox control to show through.
  215. Variable: Background
  216. If disable, the control uses the standard background color rather than the one set by the CGUI.Color() function.
  217. Variable: Border
  218. Provides a thin-line border around the control.
  219. Variable: hParentControl
  220. If this control is a subcontrol of another control, this variable contains the window handle of the parent control.
  221. */
  222. __Get(Name, Params*)
  223. {
  224. if(this.__GetEx(Result, Name, Params*) )
  225. return Result
  226. }
  227. __GetEx(ByRef Result, Name, Params*)
  228. {
  229. ;~ global CGUI
  230. Handled := false
  231. if Name not in base,_,GUINum
  232. if(!CGUI.GUIList[this.GUINum].IsDestroyed)
  233. {
  234. DetectHidden := A_DetectHiddenWindows
  235. DetectHiddenWindows, On
  236. Handled := true
  237. if(Name = "Text")
  238. GuiControlGet, Result,% this.GuiNum ":", % this.ClassNN
  239. ;~ ControlGetText, Result,, % "ahk_id " this.hwnd
  240. else if(Name = "GUI")
  241. Result := CGUI.GUIList[this.GUINum]
  242. else if(Name = "x" || Name = "y" || Name = "width" || Name = "height")
  243. {
  244. ControlGetPos, x,y,width,height,,% "ahk_id " this.hwnd
  245. Result := %Name%
  246. }
  247. else if(Name = "Position")
  248. {
  249. ControlGetPos, x,y,,,,% "ahk_id " this.hwnd
  250. Result := {x:x, y:y}
  251. }
  252. else if(Name = "Size")
  253. {
  254. ControlGetPos,,,width,height,,% "ahk_id " this.hwnd
  255. Result := {width:width, height:height}
  256. }
  257. else if(Name = "ClassNN")
  258. {
  259. if(this._.ClassNN != "" && this.hwnd && WinExist("ahk_class " this._.ClassNN) = this.hwnd) ;Check for cached Result first
  260. return this._.ClassNN
  261. else
  262. {
  263. win := DllCall("GetParent", "PTR", this.hwnd, "PTR")
  264. WinGet ctrlList, ControlList, ahk_id %win%
  265. Loop Parse, ctrlList, `n
  266. {
  267. ControlGet hwnd, Hwnd, , %A_LoopField%, ahk_id %win%
  268. if(hwnd=this.hwnd)
  269. {
  270. Result := A_LoopField
  271. break
  272. }
  273. }
  274. this._.ClassNN := Result
  275. }
  276. }
  277. else if(Name = "Enabled")
  278. ControlGet, Result, Enabled,,,% "ahk_id " this.hwnd
  279. else if(Name = "Visible")
  280. ControlGet, Result, Visible,,,% "ahk_id " this.hwnd
  281. else if(Name = "Style")
  282. ControlGet, Result, Style,,,% "ahk_id " this.hwnd
  283. else if(Name = "ExStyle")
  284. ControlGet, Result, ExStyle,,,% "ahk_id " this.hwnd
  285. else if(Name = "Focused")
  286. {
  287. ControlGetFocus, Result, % "ahk_id " CGUI.GUIList[this.GUINum].hwnd
  288. ControlGet, Result, Hwnd,, %Result%, % "ahk_id " CGUI.GUIList[this.GUINum].hwnd
  289. Result := Result = this.hwnd
  290. }
  291. else if(key := {Left : "Left", Center : "Center", Right : "Right", TabStop : "TabStop", Wrap : "Wrap", HScroll : "HScroll", VScroll : "VScroll", BackgroundTrans : "BackgroundTrans", Background : "Background", Border : "Border"}[Name])
  292. GuiControl, % this.GUINum ":", (Result ? "+" : "-") key
  293. else if(Name = "Color")
  294. GuiControl, % this.GUINum ":", "+c" Result
  295. else if(this._.HasKey("ControlStyles") && Style := this._.ControlStyles[Name])
  296. {
  297. if(SubStr(Style, 1,1) = "-")
  298. {
  299. Negate := true
  300. Style := SubStr(Style, 2)
  301. }
  302. ControlGet, Result, Style,,,% "ahk_id " this.hwnd
  303. Result = Result & Style > 0
  304. if(Negate)
  305. Result := !Result
  306. }
  307. else if(this._.HasKey("ControlExStyles") && ExStyle := this._.ControlExStyles[Name])
  308. {
  309. if(SubStr(ExStyle, 1,1) = "-")
  310. {
  311. Negate := true
  312. ExStyle := SubStr(ExStyle, 2)
  313. }
  314. ControlGet, Result, ExStyle,,,% "ahk_id " this.hwnd
  315. Result = Result & ExStyle > 0
  316. if(Negate)
  317. Result := !Result
  318. }
  319. else if(Name = "Tooltip")
  320. Result := this._.Tooltip
  321. else
  322. Handled := false
  323. if(!DetectHidden)
  324. DetectHiddenWindows, Off
  325. }
  326. return Handled
  327. }
  328. __Set(Name, Value)
  329. {
  330. ;~ global CGUI
  331. if(Name != "_" && !CGUI.GUIList[this.GUINum].IsDestroyed)
  332. {
  333. DetectHidden := A_DetectHiddenWindows
  334. DetectHiddenWindows, On
  335. Handled := true
  336. if(Name = "Text")
  337. GuiControl, % this.GUINum ":",% this.ClassNN, %Value% ;Use GuiControl because of line endings
  338. else if(Name = "x" || Name = "y" || Name = "width" || Name = "height")
  339. ControlMove,, % (Name = "x" ? Value : ""),% (Name = "y" ? Value : ""),% (Name = "width" ? Value : ""),% (Name = "height" ? Value : ""),% "ahk_id " this.hwnd
  340. else if(Name = "Position")
  341. ControlMove,, % Value.x,% Value.y,,,% "ahk_id " this.hwnd
  342. else if(Name = "Size")
  343. ControlMove,, % Value.width,% Value.height,% "ahk_id " this.hwnd
  344. else if(Name = "Enabled" && Value)
  345. this.Enable()
  346. else if(Name = "Enabled" && !Value)
  347. this.Disable()
  348. else if(Name = "Visible" && Value)
  349. this.Show()
  350. else if(Name = "Visible" && !Value)
  351. this.Hide()
  352. else if(Name = "Style")
  353. Control, Style, %Value%,,,% "ahk_id " this.hwnd
  354. else if(Name = "ExStyle")
  355. Control, ExStyle, %Value%,,,% "ahk_id " this.hwnd
  356. else if(Name = "_") ;Prohibit setting the proxy object
  357. Handled := true
  358. else if(this._.HasKey("ControlStyles") && Style := this._.ControlStyles[Name]) ;Generic control styles which are only of boolean type can be handled simply by a list of name<->value assignments. Prepending "-" to a value in such a list inverts the behaviour here.
  359. {
  360. if(SubStr(Style, 1,1) = "-")
  361. {
  362. Value := !Value
  363. Style := SubStr(Style, 2)
  364. }
  365. Style := (Value ? "+" : "-") Style
  366. Control, Style, %Style%,, % "ahk_id " this.hwnd
  367. }
  368. else if(this._.HasKey("ControlExStyles") && ExStyle := this._.ControlExStyles[Name])
  369. {
  370. if(SubStr(ExStyle, 1,1) = "-")
  371. {
  372. Value := !Value
  373. ExStyle := SubStr(ExStyle, 2)
  374. }
  375. ExStyle := (Value ? "+" : "-") ExStyle
  376. Control, ExStyle, %ExStyle%,, % "ahk_id " this.hwnd
  377. }
  378. else if(Name = "Tooltip") ;Thanks art http://www.autohotkey.com/forum/viewtopic.php?p=452514#452514
  379. {
  380. TThwnd := CGUI.GUIList[this.GUINum]._.TThwnd
  381. Guihwnd := CGUI.GUIList[this.GUINum].hwnd
  382. Controlhwnd := [this.hwnd]
  383. if(this.type = "ComboBox") ;'ComboBox' = Drop-Down button + Edit
  384. {
  385. VarSetCapacity(CBBINFO, 52, 0)
  386. NumPut(52, CBBINFO,0, "UINT")
  387. result := DllCall("GetComboBoxInfo", "UInt", Controlhwnd[1], "PTR", &CBBINFO)
  388. Controlhwnd.Insert(Numget(CBBINFO,44))
  389. }
  390. else if(this.type = "ListView")
  391. Controlhwnd.Insert(DllCall("SendMessage", "UInt", Controlhwnd[1], "UInt", 0x101f, "PTR", 0, "PTR", 0))
  392. ; - 'Text' and 'Picture' Controls requires a g-label to be defined.
  393. if(!TThwnd){
  394. ; - 'ListView' = ListView + Header (Get hWnd of the 'Header' control using "ControlGet" command).
  395. TThwnd := CGUI.GUIList[this.GUINum]._.TThwnd := DllCall("CreateWindowEx","Uint",0,"Str","TOOLTIPS_CLASS32","Uint",0,"Uint",2147483648 | 3,"Uint",-2147483648
  396. ,"Uint",-2147483648,"Uint",-2147483648,"Uint",-2147483648,"Ptr",GuiHwnd,"Uint",0,"Uint",0,"Uint",0, "PTR")
  397. DllCall("uxtheme\SetWindowTheme","Ptr",TThwnd,"Ptr",0,"UintP",0) ; TTM_SETWINDOWTHEME
  398. }
  399. for index, chwnd in Controlhwnd
  400. {
  401. Varsetcapacity(TInfo,44,0), Numput(44,TInfo), Numput(1|16,TInfo,4), Numput(GuiHwnd,TInfo,8), Numput(chwnd,TInfo,12), Numput(&Value,TInfo,36)
  402. !this._.Tooltip ? (DllCall("SendMessage",Ptr,TThwnd,"Uint",1028,Ptr,0,Ptr,&TInfo,Ptr)) ; TTM_ADDTOOL = 1028 (used to add a tool, and assign it to a control)
  403. . (DllCall("SendMessage",Ptr,TThwnd,"Uint",1048,Ptr,0,Ptr,A_ScreenWidth)) ; TTM_SETMAXTIPWIDTH = 1048 (This one allows the use of multiline tooltips)
  404. DllCall("SendMessage",Ptr,TThwnd,"UInt",(A_IsUnicode ? 0x439 : 0x40c),Ptr,0,Ptr,&TInfo,Ptr) ; TTM_UPDATETIPTEXT (OLD_MSG=1036) (used to adjust the text of a tip)
  405. }
  406. }
  407. else
  408. Handled := false
  409. if(!DetectHidden)
  410. DetectHiddenWindows, Off
  411. if(Handled)
  412. return Value
  413. }
  414. }
  415. /*
  416. Event: Introduction
  417. To handle control events you need to create a function with this naming scheme in your window class: ControlName_EventName(params)
  418. The parameters depend on the event and there may not be params at all in some cases.
  419. Additionally it is required to create a label with this naming scheme: GUIName_ControlName
  420. GUIName is the name of the window class that extends CGUI. The label simply needs to call CGUI.HandleEvent().
  421. For better readability labels may be chained since they all execute the same code.
  422. Instead of using ControlName_EventName() you may also call <CControl.RegisterEvent> on a control instance to register a different event function name.
  423. Event: FocusEnter
  424. Invoked when the control receives keyboard focus. This event does not require that the control has a matching g-label since it is implemented through window messages.
  425. This event is not supported for all input-capable controls unfortunately.
  426. Event: FocusLeave
  427. Invoked when the control loses keyboard focus. This event does not require that the control has a matching g-label since it is implemented through window messages.
  428. This event is not supported for all input-capable controls unfortunately.
  429. Event: ContextMenu
  430. Invoked when the user right clicks on the control or presses the AppsKey while this control has focus. If this event is not handled a static context menu can be shown by setting the Menu variable of this control to an instance of <CMenu>.
  431. Event: Validate
  432. Invoked when the control is asked to validate its (textual) contents. This event is only valid for controls containing text, which are only Edit and ComboBox controls as of now.
  433. Parameters:
  434. Text - The current text of the control that should be validated. The function can return this value if it is valid or another valid value.
  435. */
  436. /*
  437. Class: CImageListManager
  438. This class is used internally to manage the ImageLists of ListView/TreeView/Tab controls. Does not need to be used directly.
  439. */
  440. Class CImageListManager
  441. {
  442. __New(GUINum, hwnd)
  443. {
  444. this.Insert("_", {})
  445. this._.GUINum := GUINum
  446. this._.hwnd := hwnd
  447. this._.IconList := {}
  448. }
  449. SetIcon(ID, PathOrhBitmap, IconNumber)
  450. {
  451. ;~ global CGUI
  452. GUI := CGUI.GUIList[this._.GUINum]
  453. Control := GUI.Controls[this._.hwnd]
  454. GUI, % this._.GUINum ":Default"
  455. if(Control.Type = "ListView")
  456. GUI, ListView, % Control.ClassNN
  457. else if(Control.Type = "TreeView")
  458. Gui, TreeView, % Control.ClassNN
  459. if(!this._.IconList.SmallIL_ID)
  460. {
  461. if(Control.Type = "ListView") ;Listview also has large icons
  462. {
  463. this._.IconList.LargeIL_ID := IL_Create(5,5,1)
  464. LV_SetImageList(this._.IconList.LargeIL_ID)
  465. }
  466. this._.IconList.SmallIL_ID := IL_Create(5,5,0)
  467. if(Control.Type = "ListView")
  468. LV_SetImageList(this._.IconList.SmallIL_ID)
  469. else if(Control.Type = "TreeView")
  470. {
  471. SendMessage, 0x1109, 0, this._.IconList.SmallIL_ID, % Control.ClassNN, % "ahk_id " GUI.hwnd ; 0x1109 is TVM_SETIMAGELIST
  472. if ErrorLevel ; The TreeView had a previous ImageList.
  473. IL_Destroy(ErrorLevel)
  474. }
  475. else if(Control.Type = "Tab")
  476. {
  477. SendMessage, 0x1303, 0, this._.IconList.SmallIL_ID, % Control.ClassNN, % "ahk_id " GUI.hwnd ; 0x1109 is TVM_SETIMAGELIST
  478. }
  479. }
  480. if(FileExist(PathorhBitmap))
  481. {
  482. Loop % this._.IconList.MaxIndex() ;IDs and paths and whatnot are identical in both lists so one is enough here
  483. if(this._.IconList[A_Index].Path = PathorhBitmap && this._.IconList[A_Index].IconNumber = IconNumber)
  484. {
  485. Icon := this._.IconList[A_Index]
  486. break
  487. }
  488. if(!Icon)
  489. {
  490. IID := IL_Add(this._.IconList.SmallIL_ID, PathorhBitmap, IconNumber, 1)
  491. if(Control.Type = "ListView")
  492. IID := IL_Add(this._.IconList.LargeIL_ID, PathorhBitmap, IconNumber, 1)
  493. this._.IconList.Insert(Icon := {Path : PathorhBitmap, IconNumber : IconNumber, ID : IID})
  494. }
  495. }
  496. else
  497. {
  498. Loop % this._.IconList.MaxIndex() ;IDs and paths and whatnot are identical in both lists so one is enough here
  499. if(this._.IconList[A_Index].Path = PathorhBitmap && this._.IconList[A_Index].IconNumber = IconNumber)
  500. {
  501. Icon := this._.IconList[A_Index]
  502. break
  503. }
  504. if(!Icon)
  505. {
  506. IID := DllCall("ImageList_ReplaceIcon", "Ptr", this._.IconList.SmallIL_ID, Int, -1, "Ptr", PathorhBitmap) + 1
  507. if(Control.Type = "ListView")
  508. IID := DllCall("ImageList_ReplaceIcon", "Ptr", this._.IconList.LargeIL_ID, Int, -1, "Ptr", PathorhBitmap) + 1
  509. this._.IconList.Insert(Icon := {Path : PathorhBitmap, IconNumber : 1, ID : IID})
  510. }
  511. }
  512. if(Control.Type = "ListView")
  513. LV_Modify(ID, "Icon" (Icon ? Icon.ID : -1))
  514. else if(Control.Type = "TreeView")
  515. TV_Modify(ID, "Icon" (Icon ? Icon.ID : -1))
  516. else if(Control.Type = "Tab")
  517. {
  518. VarSetCapacity(TCITEM, 20 + 2 * A_PtrSize, 0)
  519. NumPut(2, TCITEM, 0, "UInt") ;State mask TCIF_IMAGE
  520. NumPut(Icon.ID - 1, TCITEM, 16 + A_PtrSize, "UInt") ;ID of icon in image list
  521. SendMessage, 0x1306, ID-1, &TCITEM, % Control.ClassNN, % "ahk_id " GUI.hwnd ;TCM_SETITEM
  522. }
  523. }
  524. }
  525. }
  526. #include <CTextControl>
  527. #include <CEditControl>
  528. #include <CButtonControl>
  529. #include <CCheckboxControl>
  530. #include <CChoiceControl>
  531. #include <CListViewControl>
  532. #include <CPictureControl>
  533. #include <CGroupBoxControl>
  534. #include <CStatusBarControl>
  535. #include <CTreeViewControl>
  536. #include <CTabControl>
  537. #include <CProgressControl>
  538. #include <CSliderControl>
  539. #include <CHotkeyControl>
  540. #include <CActiveXControl>