├── Class_Rebar.ahk ├── Examples ├── Rebar_Demo.ahk ├── Rebar_Mult.ahk └── SplitPanels.ahk ├── LICENSE └── README.md /Class_Rebar.ahk: -------------------------------------------------------------------------------- 1 | ;======================================================================================= 2 | ; 3 | ; Class Rebar 4 | ; 5 | ; Author: Pulover [Rodolfo U. Batista] 6 | ; AHK version: 1.1.23.01 7 | ; 8 | ; Class for AutoHotkey Rebar custom controls 9 | ;======================================================================================= 10 | ; 11 | ; This class provides intuitive methods to work with Rebar controls created via 12 | ; Gui, Add, Custom, ClassReBarWindow32. 13 | ; 14 | ;======================================================================================= 15 | ; 16 | ; Rebar Methods: 17 | ; DeleteBand(Band) 18 | ; GetBand(Band [, ID, Text, Size, Image, Background, Style, Child]) 19 | ; GetBandCount() 20 | ; GetBarHeight() 21 | ; GetLayout() 22 | ; GetRowCount() 23 | ; GetRowHeight(Band) 24 | ; IDToIndex(ID) 25 | ; InsertBand(hChild [, Position, Options, ID, Text, Size, Image, Background, MinHeight 26 | ; , MinWidth, IdealSize]) 27 | ; MaximizeBand(Band [, IdealWidth]) 28 | ; MinimizeBand(Band) 29 | ; ModifyBand(Band, Property, Value [, SetStyle]) 30 | ; MoveBand(Band, Target) 31 | ; OnNotify(Param [, MenuXPos, MenuYPos, ID) 32 | ; SetBandStyle(Band, Value) 33 | ; SetBandWidth(Band, Width) 34 | ; SetImageList(ImageList) 35 | ; SetMaxRows([Rows]) 36 | ; SetLayout(Layout) 37 | ; ShowBand(Band [, Show]) 38 | ; ToggleStyle(Style) 39 | ; 40 | ;======================================================================================= 41 | ; 42 | ; Useful Rebar Styles: Styles can be applied to Gui command options, e.g.: 43 | ; Gui, Add, Custom, ClassReBarWindow32 0x0800 0x0100 44 | ; 45 | ; RBS_BANDBORDERS := 0x0400 - Add a separator border between bands in different rows. 46 | ; RBS_DBLCLKTOGGLE := 0x8000 - Toggle maximize/minimize with double-click instead of single. 47 | ; RBS_FIXEDORDER := 0x0800 - Always displays bands in the same order. 48 | ; RBS_VARHEIGHT := 0x0200 - Allow bands to have different heights. 49 | ; CCS_NODIVIDER := 0x0040 - Removes the separator line above the rebar. 50 | ; CCS_NOPARENTALIGN := 0x0008 - Allows positioning and moving rebars. 51 | ; CCS_NORESIZE := 0x0004 - Allows resizing rebars. 52 | ; CCS_VERT := 0x0080 - Creates a vertical rebar. 53 | ; 54 | ;======================================================================================= 55 | Class Rebar extends Rebar.Private 56 | { 57 | ;======================================================================================= 58 | ; Method: Delete 59 | ; Description: Deletes a band from a rebar control. 60 | ; Parameters: 61 | ; Band: 1-based index of the band to be deleted. 62 | ; Return: TRUE if successful, FALSE if there was a problem. 63 | ;======================================================================================= 64 | DeleteBand(Band) 65 | { 66 | SendMessage, this.RB_DELETEBAND, Band-1, 0,, % "ahk_id " this.rbHwnd 67 | return (ErrorLevel = "FAIL") ? false : true 68 | } 69 | ;======================================================================================= 70 | ; Method: GetBand 71 | ; Description: Retrieves information from a rebar band. 72 | ; Parameters: 73 | ; Band: 1-based index of the band. 74 | ; ID: OutputVar to store the band's ID. 75 | ; Text: OutputVar to store the band's text. 76 | ; Size: OutputVar to store the band's size. 77 | ; Image: OutputVar to store the band's image index. 78 | ; Background: OutputVar to store a handle to the band's background bitmap. 79 | ; Style: OutputVar to store the band's style numeric value. 80 | ; Child: OutputVar to store a handle to the band's child control. 81 | ; Return: TRUE if successful, FALSE if there was a problem. 82 | ;======================================================================================= 83 | GetBand(Band, ByRef ID := "", ByRef Text := "", ByRef Size := "", ByRef Image := "" 84 | , ByRef Background := "", ByRef Style := "", ByRef Child := "") 85 | { 86 | Static cbSize := 48 + (8 * A_PtrSize) 87 | fMask := (IsByRef(Style) ? this.RBBIM_STYLE : 0) 88 | | (IsByRef(Text) ? this.RBBIM_TEXT : 0) 89 | | (IsByRef(Image) ? this.RBBIM_IMAGE : 0) 90 | | (IsByRef(Child) ? this.RBBIM_CHILD : 0) 91 | | (IsByRef(Size) ? this.RBBIM_SIZE : 0) 92 | | (IsByRef(Background) != "" ? this.RBBIM_BACKGROUND : 0) 93 | | (IsByRef(ID) ? this.RBBIM_ID : 0) 94 | , VarSetCapacity(rbBand, cbSize, 0) 95 | , NumPut(cbSize, rbBand, 0, "UInt"), NumPut(fMask, rbBand, 4, "UInt") 96 | , VarSetCapacity(bText, 64, 0) 97 | , NumPut(&bText, rbBand, 16 + A_PtrSize, "UPtr"), NumPut(64, rbBand, 16 + (A_PtrSize * 2), "UInt") 98 | 99 | SendMessage, this.RB_GETBANDINFO, Band-1, &rbBand,, % "ahk_id " this.rbHwnd 100 | Style := NumGet(&rbBand, 8, "UInt"), Text := StrGet(&bText) 101 | , Image := NumGet(&rbBand, 20 + (A_PtrSize * 2), "Int")+1 102 | , Child := NumGet(&rbBand, 24 + (A_PtrSize * 2), "UPtr") 103 | , Size := NumGet(&rbBand, 32 + (A_PtrSize * 3), "UInt") 104 | , Background := NumGet(&rbBand, 32 + (A_PtrSize * 4), "UPtr") 105 | , ID := NumGet(&rbBand, 32 + (A_PtrSize * 5), "UInt") 106 | return (ErrorLevel = "FAIL") ? false : true 107 | } 108 | ;======================================================================================= 109 | ; Method: GetBandCount 110 | ; Description: Retrieves the count of bands currently in the rebar control. 111 | ; Return: The number of bands in the rebar control. 112 | ;======================================================================================= 113 | GetBandCount() 114 | { 115 | SendMessage, this.RB_GETBANDCOUNT, 0, 0,, % "ahk_id " this.rbHwnd 116 | return ErrorLevel 117 | } 118 | ;======================================================================================= 119 | ; Method: GetBarHeight 120 | ; Description: Retrieves the height of the rebar control. 121 | ; Return: The height of the rebar control in pixels. 122 | ;======================================================================================= 123 | GetBarHeight() 124 | { 125 | SendMessage, this.RB_GETBARHEIGHT, 0, 0,, % "ahk_id " this.rbHwnd 126 | return ErrorLevel 127 | } 128 | ;======================================================================================= 129 | ; Method: GetLayout 130 | ; Description: Retrieves the current layout of bands in the rebar control. 131 | ; Return: A string containing information about the current bands. 132 | ; String format is: ID1,Size1,Style1|ID2,Size2,Style2|... 133 | ;======================================================================================= 134 | GetLayout() 135 | { 136 | Loop % this.GetBandCount() 137 | { 138 | this.GetBand(A_Index, ID, "", Size, "", "", Style) 139 | Layout .= ID "," Size "," Style "|" 140 | } 141 | return Layout 142 | } 143 | ;======================================================================================= 144 | ; Method: GetRowCount 145 | ; Description: Retrieves the number of rows of bands in a rebar control. 146 | ; Return: The number of rows in the rebar control. 147 | ;======================================================================================= 148 | GetRowCount() 149 | { 150 | SendMessage, this.RB_GETROWCOUNT, 0, 0,, % "ahk_id " this.rbHwnd 151 | return ErrorLevel 152 | } 153 | ;======================================================================================= 154 | ; Method: GetRowHeight 155 | ; Description: Retrieves the number of rows of bands in a rebar control. 156 | ; Parameters: 157 | ; Band: 1-based index of a band to retrieve the height from. 158 | ; Return: The height of the row from the corresponding band in pixels. 159 | ;======================================================================================= 160 | GetRowHeight(Band) 161 | { 162 | SendMessage, this.RB_GETROWHEIGHT, Band-1, 0,, % "ahk_id " this.rbHwnd 163 | return ErrorLevel 164 | } 165 | ;======================================================================================= 166 | ; Method: IDToIndex 167 | ; Description: Converts a band identifier to a band index in a rebar control. 168 | ; Parameters: 169 | ; ID: The application-defined identifier of the band in question. 170 | ; Return: The 1-based band index if successful, or 0 otherwise. 171 | ;======================================================================================= 172 | IDToIndex(ID) 173 | { 174 | SendMessage, this.RB_IDTOINDEX, ID, 0,, % "ahk_id " this.rbHwnd 175 | return ErrorLevel+1 176 | } 177 | ;======================================================================================= 178 | ; Method: InsertBand 179 | ; Description: Inserts a new band in a rebar control. 180 | ; Parameters: 181 | ; hChild: Handle to the control contained in the band, if any. 182 | ; Position: 1-based index of the location where the band will be inserted. 183 | ; If you set this parameter to 0, the control will add the 184 | ; new band at the last location. 185 | ; Options: Enter zero or more words, separated by space or tab, from the 186 | ; following list to set the band's initial styles: 187 | ; Break, FixedBmp, FixedSize, Hidden, HideTitle, NoGripper, 188 | ; NoVert, TopAlign, VariableHeight. 189 | ; The following styles are applied by default: ChildEdge, 190 | ; GripperAlways (can be disabled with NoGripper), UseChevron 191 | ; (only valid if IdealSize is set). 192 | ; ID: Integer value that the control uses to identify this band. 193 | ; This parameter is required to retrieve and set layouts. 194 | ; Text: The display text for the band. 195 | ; Size: Length of the band, in pixels. 196 | ; Image: 1-based index of any image that should be displayed in the band. 197 | ; SetImageList method must be called prior to this. 198 | ; Background: Path of a bitmap file that is used as the background for this band. 199 | ; MinHeight: Minimum height of the control, in pixels. 200 | ; MinWidth: Minimum width of the control, in pixels. 201 | ; IdealSize: Ideal width of the band, in pixels. If the band is maximized to 202 | ; the ideal width (see MaximizeBand method), the rebar control 203 | ; will attempt to make the band this width. 204 | ; Return: TRUE if successful, FALSE if there was a problem. 205 | ;======================================================================================= 206 | InsertBand(hChild, Position := 0, Options := "", ID := "", Text := "", Size := "", Image := 0, Background := "" 207 | , MinHeight := 23, MinWidth := 25, IdealSize := "") 208 | { 209 | Options := "ChildEdge GripperAlways UseChevron " Options 210 | , this.DefineBandStruct(rbBand, Options, ID, Text, Size, Image, Background 211 | , MinWidth, MinHeight, IdealSize, hChild) 212 | SendMessage, this.RB_INSERTBAND, Position-1, &rbBand,, % "ahk_id " this.rbHwnd 213 | return (ErrorLevel = "FAIL") ? false : true 214 | } 215 | ;======================================================================================= 216 | ; Method: MaximizeBand 217 | ; Description: Resizes a band to either its ideal or largest size. 218 | ; Parameters: 219 | ; Band: 1-based index of a band to be maximized. 220 | ; IdealWidth: If TRUE the ideal width of the band will be used to maximize 221 | ; Return: TRUE if successful, FALSE if there was a problem. 222 | ;======================================================================================= 223 | MaximizeBand(Band, IdealWidth := false) 224 | { 225 | SendMessage, this.RB_MAXIMIZEBAND, Band-1, IdealWidth,, % "ahk_id " this.rbHwnd 226 | return (ErrorLevel = "FAIL") ? false : true 227 | } 228 | ;======================================================================================= 229 | ; Method: MinimizeBand 230 | ; Description: Resizes a band to its smallest size. 231 | ; Parameters: 232 | ; Band: 1-based index of a band to be minimized. 233 | ; Return: TRUE if successful, FALSE if there was a problem. 234 | ;======================================================================================= 235 | MinimizeBand(Band) 236 | { 237 | SendMessage, this.RB_MINIMIZEBAND, Band-1, 0,, % "ahk_id " this.rbHwnd 238 | return (ErrorLevel = "FAIL") ? false : true 239 | } 240 | ;======================================================================================= 241 | ; Method: ModifyBand 242 | ; Description: Sets band parameters such as Text and Size. 243 | ; Parameters: 244 | ; Band: 1-based index of a band to be modified. 245 | ; Property: Enter one word from the following list to select the Property 246 | ; to be set: Style, ID, Text, Size, Image, Background, 247 | ; MinWidth, MinHeight, IdealSize, Child (handle of control). 248 | ; Value: The value to be set in the selected Property. 249 | ; If Property is Style you can enter named values as 250 | ; in the InsertBand options, or an integer value. 251 | ; SetStyle: Only valid if Property is Style. Determines whether to add or 252 | ; remove the styles. 253 | ; Return: TRUE if successful, FALSE if there was a problem. 254 | ;======================================================================================= 255 | ModifyBand(Band, Property, Value, SetStyle := true) 256 | { 257 | If (Property = "Style") 258 | { 259 | If Value is Integer 260 | Value := Value 261 | Else 262 | { 263 | Loop, Parse, Value, %A_Space%%A_Tab% 264 | { 265 | If (this[ "RBBS_" A_LoopField ]) 266 | rbStyle += this[ "RBBS_" A_LoopField ] 267 | } 268 | Value := rbStyle 269 | } 270 | this.GetBand(Band, "", "", "", "", "", bdStyle) 271 | If (SetStyle) 272 | Value |= bdStyle 273 | Else 274 | Value ^= bdStyle 275 | } 276 | If ((this[ "RBBIM_" Property ]) || (Property = "MinWidth") || (Property = "MinHeight")) 277 | %Property% := Value 278 | this.DefineBandStruct(rbBand, Style, ID, Text, Size, Image, Background 279 | , MinWidth, MinHeight, IdealSize, Child) 280 | SendMessage, this.RB_SETBANDINFO, Band-1, &rbBand,, % "ahk_id " this.rbHwnd 281 | return (ErrorLevel = "FAIL") ? false : true 282 | } 283 | ;======================================================================================= 284 | ; Method: MoveBand 285 | ; Description: Moves a band from one index to another. 286 | ; Parameters: 287 | ; Band: 1-based index of a band to be moved. 288 | ; Target: 1-based index of a the new band position. 289 | ; Return: TRUE if successful, FALSE if there was a problem. 290 | ;======================================================================================= 291 | MoveBand(Band, Target) 292 | { 293 | SendMessage, this.RB_MOVEBAND, Band-1, Target-1,, % "ahk_id " this.rbHwnd 294 | this.ShowBand(Band) 295 | return (ErrorLevel = "FAIL") ? false : true 296 | } 297 | ;======================================================================================= 298 | ; Method: OnNotify 299 | ; Description: Handles rebar notifications. 300 | ; This method should be called from the rebar's G-Label. 301 | ; If A_GuiEvent is "N", pass it A_EventInfo as the Param. 302 | ; You can also call it from a function monitoring the WM_NOTIFY 303 | ; message, pass it lParam as the Param. 304 | ; Currently this method is used to retrieve the position for 305 | ; a menu when the Chevron button is pushed and prevent a number 306 | ; of rows higher then the one set by SetMaxRows method. 307 | ; Parameters: 308 | ; Param: The lParam from WM_NOTIFY message. 309 | ; MenuXPos: OutputVar to store the horizontal position for a menu. 310 | ; MenuYPos: OutputVar to store the vertical position for a menu. 311 | ; ID: OutputVar to store the band's ID. 312 | ; Return: If the ChevronPushed notification is passed returns the index 313 | ; of the band it is from. 314 | ;======================================================================================= 315 | OnNotify(ByRef Param, ByRef MenuXPos := "", ByRef MenuYPos := "", ByRef ID := "") 316 | { 317 | nCode := NumGet(Param + (A_PtrSize * 2), 0, "Int"), rbHwnd := NumGet(Param + 0, 0, "UPtr") 318 | If (rbHwnd != this.rbHwnd) 319 | return "" 320 | If (nCode = this.RBN_CHEVRONPUSHED) 321 | { 322 | ControlGetPos, RBX, RBY,,,, % "ahk_id " this.rbHwnd 323 | ID := NumGet(Param + (4 + (A_PtrSize * 3)), 0, "Int") 324 | , MenuXPos := RBX + NumGet(Param + (A_PtrSize * 4 - 4), 12, "Int") 325 | , MenuYPos := RBY + NumGet(Param + (A_PtrSize * 4 - 4), 24, "Int") 326 | return NumGet(Param + (A_PtrSize * 3), 0, "Int") + 1 327 | } 328 | If ((nCode = this.RBN_HEIGHTCHANGE) && (this.MaxRows)) 329 | { 330 | Loop, % this.GetBandCount() 331 | { 332 | this.GetBand(A_Index, "", "", "", "", "", Style) 333 | If (Style & 0x0001) 334 | LastBrkBand := A_Index 335 | } 336 | If (this.GetRowCount() > this.MaxRows) 337 | this.ModifyBand(LastBrkBand, "Style", "Break", false) 338 | } 339 | return "" 340 | } 341 | ;======================================================================================= 342 | ; Method: SetBandStyle 343 | ; Description: Sets the style of a band. 344 | ; Parameters: 345 | ; Band: 1-based index of the band. 346 | ; Value: Named values as in the InsertBand options, or an integer value. 347 | ; Return: TRUE if successful, FALSE if there was a problem. 348 | ;======================================================================================= 349 | SetBandStyle(Band, Value) 350 | { 351 | this.DefineBandStruct(rbBand, Value) 352 | SendMessage, this.RB_SETBANDINFO, Band-1, &rbBand,, % "ahk_id " this.rbHwnd 353 | return (ErrorLevel = "FAIL") ? false : true 354 | } 355 | ;======================================================================================= 356 | ; Method: SetBandWidth 357 | ; Description: Sets the width for a docked band. 358 | ; Parameters: 359 | ; Band: 1-based index of the band. 360 | ; Width: New width in pixels. 361 | ; Return: TRUE if successful, FALSE if there was a problem. 362 | ;======================================================================================= 363 | SetBandWidth(Band, Width) 364 | { 365 | this.DefineBandStruct(rbBand, "", "", "", Width) 366 | SendMessage, this.RB_SETBANDINFO, Band-1, &rbBand,, % "ahk_id " this.rbHwnd 367 | return (ErrorLevel = "FAIL") ? false : true 368 | } 369 | ;======================================================================================= 370 | ; Method: SetImageList 371 | ; Description: Sets an ImageList to the rebar control. 372 | ; Parameters: 373 | ; ImageList: ImageList ID. 374 | ; Return: TRUE if successful, FALSE if there was a problem. 375 | ;======================================================================================= 376 | SetImageList(ImageList) 377 | { 378 | this.DefineBarStruct(rBarInfo, ImageList) 379 | SendMessage, this.RB_SETBARINFO, 0, &rBarInfo,, % "ahk_id " this.rbHwnd 380 | return (ErrorLevel = "FAIL") ? false : true 381 | } 382 | ;======================================================================================= 383 | ; Method: SetLayout 384 | ; Description: Sets a layout of bands in the rebar control. 385 | ; Parameters: 386 | ; Layout: A string containing information about the current bands. 387 | ; String format is: ID1,Size1,Style1|ID2,Size2,Style2|... 388 | ; Return: TRUE if a valid layout was passed, or FALSE otherwise. 389 | ;======================================================================================= 390 | SetLayout(Layout) 391 | { 392 | Loop, Parse, Layout, |, %A_Space% 393 | { 394 | StringSplit, Par, A_LoopField, `,, %A_Space% 395 | Index := this.IDToIndex(Par1), this.SetBandStyle(Index, Par3) 396 | , this.SetBandWidth(Index, Par2), this.MoveBand(Index, A_Index) 397 | } 398 | return Par0 ? true : false 399 | } 400 | ;======================================================================================= 401 | ; Method: SetMaxRows 402 | ; Description: Sets the maximum number of rows allowed in a rebar control. 403 | ; This method requires the OnNotify method to be implemented. 404 | ; Parameters: 405 | ; Rows: Number of maximum rows allowed. Set it to 0 to disable limit. 406 | ; Return: The number of rows previously allowed. 407 | ;======================================================================================= 408 | SetMaxRows(Rows := 0) 409 | { 410 | LastValue := this.MaxRows, this.MaxRows := Rows 411 | return LastValue 412 | } 413 | ;======================================================================================= 414 | ; Method: ShowBand 415 | ; Description: Shows or hides a given band in a rebar control. 416 | ; Parameters: 417 | ; Band: 1-based index of the band. 418 | ; Show: Set to TRUE to show the band or FALSE to hide it. 419 | ; Return: TRUE if successful, FALSE if there was a problem. 420 | ;======================================================================================= 421 | ShowBand(Band, Show := true) 422 | { 423 | SendMessage, this.RB_SHOWBAND, Band-1, %Show%,, % "ahk_id " this.rbHwnd 424 | return (ErrorLevel = "FAIL") ? false : true 425 | } 426 | ;======================================================================================= 427 | ; Method: ToggleStyle 428 | ; Description: Toggles rebar's style. 429 | ; Parameters: 430 | ; Style: Enter one or more words, separated by space or tab, from the 431 | ; following list to toggle toolbar's styles: 432 | ; AutoSize, BandBorders, DblClkToggle, FixedOrder, 433 | ; RegisterDropdown, VarHeight, VerticalGripper. 434 | ; You may also enter an integer value to define the style. 435 | ; Return: TRUE if a valid style is passed, or FALSE otherwise. 436 | ;======================================================================================= 437 | ToggleStyle(Style) 438 | { 439 | If Style is Integer 440 | rbStyle := Style 441 | Else 442 | { 443 | Loop, Parse, Style, %A_Space%%A_Tab% 444 | { 445 | If (this[ "RBS_" A_LoopField ] ) 446 | rbStyle += this[ "RBS_" A_LoopField ] 447 | } 448 | } 449 | If (rbStyle != "") 450 | { 451 | WinSet, Style, ^%rbStyle%, % "ahk_id " this.rbHwnd 452 | return true 453 | } 454 | Else 455 | return false 456 | } 457 | ;======================================================================================= 458 | ; Private Class This class is used internally. 459 | ;======================================================================================= 460 | Class Private 461 | { 462 | ;======================================================================================= 463 | ; Private Properties 464 | ;======================================================================================= 465 | ; Messages 466 | Static RB_DELETEBAND := 0x0402 467 | Static RB_GETBARINFO := 0x0403 468 | Static RB_SETBARINFO := 0x0404 469 | Static RB_GETBANDINFO := 0x0405 470 | Static RB_GETRECT := 0x0409 471 | Static RB_INSERTBAND := A_IsUnicode ? 0x040A : 0x0401 472 | Static RB_SETBANDINFO := A_IsUnicode ? 0x040B : 0x0406 473 | Static RB_GETBANDCOUNT := 0x040C 474 | Static RB_GETROWCOUNT := 0x040D 475 | Static RB_GETROWHEIGHT := 0x040E 476 | Static RB_IDTOINDEX := 0x0410 477 | Static RB_GETBARHEIGHT := 0x041B 478 | Static RB_GETBANDINFOW := 0x041C 479 | Static RB_GETBANDINFOA := 0x041D 480 | Static RB_MINIMIZEBAND := 0x041E 481 | Static RB_MAXIMIZEBAND := 0x041F 482 | Static RB_SHOWBAND := 0x0423 483 | Static RB_MOVEBAND := 0x0427 484 | Static RB_GETBANDMARGINS := 0x0428 485 | Static RB_SETEXTENDEDSTYLE := 0x0429 486 | Static RB_GETEXTENDEDSTYLE := 0x042A 487 | Static RB_SETBANDWIDTH := 0x042C 488 | ; Notifications 489 | Static RBN_AUTOBREAK := -853 490 | Static RBN_AUTOSIZE := -834 491 | Static RBN_BEGINDRAG := -835 492 | Static RBN_CHEVRONPUSHED := -841 493 | Static RBN_CHILDSIZE := -839 494 | Static RBN_DELETEDBAND := -838 495 | Static RBN_DELETINGBAND := -837 496 | Static RBN_ENDDRAG := -836 497 | Static RBN_GETOBJECT := -832 498 | Static RBN_HEIGHTCHANGE := -831 499 | Static RBN_LAYOUTCHANGED := -833 500 | Static RBN_MINMAX := -852 501 | Static RBN_SPLITTERDRAG := -842 502 | ; Styles 503 | Static RBS_AUTOSIZE := 0x2000 504 | Static RBS_BANDBORDERS := 0x0400 505 | Static RBS_DBLCLKTOGGLE := 0x8000 506 | Static RBS_FIXEDORDER := 0x0800 507 | Static RBS_REGISTERDROP := 0x1000 508 | Static RBS_TOOLTIPS := 0x0100 509 | Static RBS_VARHEIGHT := 0x0200 510 | Static RBS_VERTICALGRIPPER := 0x4000 ; // this always has the vertical gripper (default for horizontal mode) 511 | ; REBARBANDINFO fMask 512 | Static RBBIM_BACKGROUND := 0x0080 513 | Static RBBIM_CHEVRONLOCATION := 0x1000 ; >= Vista 514 | Static RBBIM_CHEVRONSTATE := 0x2000 ; >= Vista 515 | Static RBBIM_CHILD := 0x0010 516 | Static RBBIM_CHILDSIZE := 0x0020 517 | Static RBBIM_COLORS := 0x0002 518 | Static RBBIM_HEADERSIZE := 0x0800 ; // control the size of the header 519 | Static RBBIM_ID := 0x0100 520 | Static RBBIM_IDEALSIZE := 0x0200 521 | Static RBBIM_IMAGE := 0x0008 522 | Static RBBIM_LPARAM := 0x0400 523 | Static RBBIM_SIZE := 0x0040 524 | Static RBBIM_STYLE := 0x0001 525 | Static RBBIM_TEXT := 0x0004 526 | ; REBARBANDINFO fStyle 527 | Static RBBS_BREAK := 0x0001 ; // break to new line 528 | Static RBBS_CHILDEDGE := 0x0004 ; // edge around top & bottom of child window 529 | Static RBBS_FIXEDBMP := 0x0020 ; // bitmap doesn't move during band resize 530 | Static RBBS_FIXEDSIZE := 0x0002 ; // band can't be sized 531 | Static RBBS_GRIPPERALWAYS := 0x0080 ; // always show the gripper 532 | Static RBBS_HIDDEN := 0x0008 ; // don't show 533 | Static RBBS_HIDETITLE := 0x0400 ; // keep band title hidden 534 | Static RBBS_NOGRIPPER := 0x0100 ; // never show the gripper 535 | Static RBBS_NOVERT := 0x0010 ; // don't show when vertical 536 | Static RBBS_TOPALIGN := 0x0800 ; // keep band in top row 537 | Static RBBS_USECHEVRON := 0x0200 ; // display drop-down button for this band if it's sized smaller than ideal width 538 | Static RBBS_VARIABLEHEIGHT := 0x0040 ; // allow autosizing of this child vertically 539 | ;======================================================================================= 540 | ; Meta-Functions 541 | ; 542 | ; Properties: 543 | ; rbHwnd: Rebar's Hwnd. 544 | ; MaxRows: Maximum number of rows allowed. Initially set to "no limit". 545 | ;======================================================================================= 546 | __New(hRebar) 547 | { 548 | this.rbHwnd := hRebar 549 | , this.MaxRows := 0 550 | } 551 | ;======================================================================================= 552 | __Delete() 553 | { 554 | this.RemoveAt(1, this.Length()) 555 | , this.SetCapacity(0) 556 | , this.base := "" 557 | } 558 | ;======================================================================================= 559 | ; Private Methods 560 | ;======================================================================================= 561 | ; Method: DefineBandStruct 562 | ; Description: Creates a REBARBANDINFO structure. 563 | ;======================================================================================= 564 | DefineBandStruct(ByRef BandVar, Options := "", wID := "", ByRef lpText := "", cx := "", iImage := "", hbmBack := "" 565 | , cxMinChild := "", cyMinChild := "", cxIdeal := "", hwndChild := "") 566 | { 567 | Static cbSize := 48 + (8 * A_PtrSize) 568 | 569 | If Options is Integer 570 | fStyle := Options 571 | Else 572 | { 573 | Loop, Parse, Options, %A_Space%%A_Tab% 574 | { 575 | If (this[ "RBBS_" A_LoopField ]) 576 | fStyle += this[ "RBBS_" A_LoopField ] 577 | } 578 | } 579 | If (hbmBack) 580 | hbmBack := DllCall("LoadImage", "UPtr", 0, "Str", hbmBack, "UInt", 0, "UInt", 0, "UInt", 0, "UInt", 0x10) 581 | 582 | fMask := (Options != "" ? this.RBBIM_STYLE : 0) 583 | | (lpText != "" ? this.RBBIM_TEXT : 0) 584 | | (iImage ? this.RBBIM_IMAGE : 0) 585 | | (hwndChild ? this.RBBIM_CHILD | this.RBBIM_SIZE | this.RBBIM_IDEALSIZE : 0) 586 | | (cx ? this.RBBIM_SIZE : 0) 587 | | (hbmBack != "" ? this.RBBIM_BACKGROUND : 0) 588 | | (wID ? this.RBBIM_ID : 0) 589 | | (cxMinChild || cyMinChild ? this.RBBIM_CHILDSIZE : 0) 590 | | (cxIdeal ? this.RBBIM_IDEALSIZE : 0) 591 | 592 | VarSetCapacity(BandVar, cbSize, 0) 593 | , NumPut(cbSize, BandVar, 0, "UInt") 594 | , NumPut(fMask, BandVar, 4, "UInt") 595 | , NumPut(fStyle, BandVar, 8, "UInt") 596 | , NumPut(&lpText, BandVar, 16 + A_PtrSize, "UPtr") 597 | , NumPut(iImage-1, BandVar, 20 + (A_PtrSize * 2), "Int") 598 | , NumPut(hwndChild, BandVar, 24 + (A_PtrSize * 2), "UPtr") 599 | , NumPut(cxMinChild, BandVar, 24 + (A_PtrSize * 3), "UInt") 600 | , NumPut(cyMinChild, BandVar, 28 + (A_PtrSize * 3), "UInt") 601 | , NumPut(cx, BandVar, 32 + (A_PtrSize * 3), "UInt") 602 | , NumPut(hbmBack, BandVar, 32 + (A_PtrSize * 4), "UPtr") 603 | , NumPut(wID, BandVar, 32 + (A_PtrSize * 5), "UInt") 604 | , NumPut(cxIdeal, BandVar, 48 + (A_PtrSize * 5), "UInt") 605 | } 606 | ;======================================================================================= 607 | ; Method: DefineBarStruct 608 | ; Description: Creates a REBARINFO structure. 609 | ;======================================================================================= 610 | DefineBarStruct(ByRef BandVar, himl) 611 | { 612 | Static cbSize := 8 + A_PtrSize 613 | Static fMask := 0x0001 614 | 615 | VarSetCapacity(BandVar, cbSize, 0) 616 | , NumPut(cbSize, BandVar, 0, "UInt") 617 | , NumPut(fMask, BandVar, 4, "UInt") 618 | , NumPut(himl, BandVar, 8, "UPtr") 619 | } 620 | } 621 | } -------------------------------------------------------------------------------- /Examples/Rebar_Demo.ahk: -------------------------------------------------------------------------------- 1 | #NoEnv 2 | #SingleInstance, Force 3 | SetBatchLines, -1 4 | Process, Priority,, High 5 | #Include ..\Class_Rebar.ahk 6 | #Include ..\..\Class_Toolbar\Class_Toolbar.ahk ; https://github.com/Pulover/Class_Toolbar 7 | 8 | Gui, +Resize 9 | ; TBSTYLE_FLAT := 0x0800 Required to show separators as bars. 10 | ; TBSTYLE_TOOLTIPS := 0x0100 Required to show Tooltips. 11 | ; CCS_NODIVIDER := 0x0040 Removes separator line above controls. 12 | ; CCS_NOPARENTALIGN := 0x0008 Required tow allow positioning of toolbar. 13 | ; CCS_NORESIZE := 0x0004 Required tow allow resizing of toolbar. 14 | Gui, Add, Custom, ClassToolbarWindow32 hwndhToolbar x0 y0 h23 w500 0x0800 0x0100 0x0040 0x0008 0x0004 15 | ; RBS_VARHEIGHT := 0x0200 - Allow bands to have different heights. 16 | ; RBS_BANDBORDERS := 0x0400 - Add a separator border between bands in different rows. 17 | ; RBS_DBLCLKTOGGLE := 0x8000 - Toggle maximize/minimize with double-click instead of single. 18 | Gui, Add, Custom, ClassReBarWindow32 hwndhRebar 0x0200 0x0400 0x0040 0x8000 19 | Gui, Add, Combobox, hwndhCombo vFontFace gChangeFont, Arial||Verdana|Tahoma|Times New Roman 20 | Gui, Add, Edit, x5 y60 w280 r10 hwndhTextEdit, Some text sample. 21 | Gui, Add, Button, hwndhSave gSave, Save Layout 22 | Gui, Add, Button, hwndhLoad gLoad, Load Layout 23 | Gui, Show, h205 w400 x600 y300, [Class] Rebar - Demostration Script 24 | 25 | GoSub, DefineToolbar 26 | 27 | ; ========== Rebar ========== 28 | 29 | ; Get sizes from the controls that will be added to the bands. 30 | TB.Get("", "", "", tbBtnWidth, tbBtnHeight) 31 | NumButtons := TB.GetCount() 32 | tbWidth := NumButtons * tbBtnWidth 33 | GuiControlGet, rc, Pos, %hCombo% 34 | GuiControlGet, re, Pos, %hTextEdit% 35 | 36 | ; You can set a Bitmap file to be used as background. 37 | BG := "bg.bmp" 38 | 39 | ; Create an Image List for the rebar. 40 | IL := IL_Create(1, 1) 41 | IL_Add(IL, "shell32.dll", 74) 42 | IL_Add(IL, "shell32.dll", 76) 43 | 44 | ; Initialize class. 45 | RB := New Rebar(hRebar) 46 | 47 | ; Set an Image List. 48 | RB.SetImageList(IL) 49 | 50 | ; Add bands with hwnd's of controls to be inserted and their sizes/positions. 51 | RB.InsertBand(hToolbar, 0, "", 10, "", 100, 0, "", tbBtnHeight, 25, 100) 52 | RB.InsertBand(hCombo, 0, "", 20, "Font:", 200, 1, BG, rch, rcw, 75) 53 | RB.InsertBand(hTextEdit, 0, "Break", 30, "", 290, 0, "", reh, rew) ; "Break" sends the band to a new row. 54 | RB.InsertBand(hSave, 0, "Break", 40, "", 180) 55 | RB.InsertBand(hLoad, 0, "", 50, "", 180) 56 | 57 | ; Set a function to monitor the Chevron button notification. 58 | WM_NOTIFY := 0x4E 59 | OnMessage(WM_NOTIFY, "RB_Notify") 60 | return 61 | 62 | ; This function monitors rebar's notifications. Only required for the Chevron and SetMaxRows. 63 | RB_Notify(wParam, lParam) 64 | { 65 | Global RB ; Function (or at least the Handles) must be global. 66 | If (RB.OnNotify(lParam, MX, MY, BandID)) ; Handles notifications. 67 | ShowChevronMenu(BandID, MX, MY) ; If the ChevronPushed notification is caught 68 | ; it returns the returns the band's ID and coordinates to show a menu. 69 | } 70 | 71 | ShowChevronMenu(Band, X, Y) 72 | { 73 | Global TB 74 | HidBtns := TB.GetHiddenButtons() ; Retrives which buttons are hidden by the band. 75 | Loop, % HidBtns.MaxIndex() 76 | Menu, TestMenu, Add, % HidBtns[A_Index].Text, % HidBtns[A_Index].Label 77 | Menu, TestMenu, Show, %X%, %Y% 78 | Menu, TestMenu, DeleteAll 79 | } 80 | 81 | ; ========== Toolbar ========== 82 | ; http://www.autohotkey.com/board/topic/94750-class-toolbar-create-and-modify 83 | 84 | DefineToolbar: 85 | ILA := IL_Create(3, 2) 86 | IL_Add(ILA, "shell32.dll", 260) 87 | IL_Add(ILA, "shell32.dll", 135) 88 | IL_Add(ILA, "shell32.dll", 261) 89 | IL_Add(ILA, "shell32.dll", 72) 90 | 91 | TB := New Toolbar(hToolbar) 92 | TB.SetImageList(ILA) 93 | TB.Add("", "Cut=Cut:1", "Copy=Copy:2", "Paste=Paste:3", "Test=Run Tests on Band 2:4") 94 | TB.SetMaxTextRows(0) 95 | TB.SetExStyle(0x10) 96 | OnMessage(0x111, "TB_Messages") 97 | return 98 | 99 | TB_Messages(wParam, lParam) 100 | { 101 | Global 102 | TB.OnMessage(wParam) 103 | } 104 | 105 | ; ============================= 106 | 107 | ChangeFont: 108 | Gui, Submit, NoHide 109 | Gui, Font,, %FontFace% 110 | GuiControl, Font, %hTextEdit% 111 | return 112 | 113 | Save: 114 | Layout := RB.GetLayout() 115 | return 116 | 117 | Load: 118 | RB.SetLayout(Layout) 119 | return 120 | 121 | Test: 122 | RB.ModifyBand(2, "Text", "Select:") 123 | RB.ModifyBand(2, "Image", 2) 124 | RB.MaximizeBand(2, True) 125 | ; RB.MinimizeBand(2) 126 | RB.GetBand(2, ID, Text, Size, Image, Background, Style) 127 | GuiControl,, %hTextEdit%, % "Band 2 Info:" 128 | . "`n`tID: " ID 129 | . "`n`tText: " Text 130 | . "`n`tSize: " Size 131 | . "`n`tIcon: " Image 132 | . "`n`thBitmap: " Background 133 | . "`n`tStyle: " Style 134 | . "`n`nRebar Info:" 135 | . "`n`tBands: " RB.GetBandCount() 136 | . "`n`tRows: " RB.GetRowCount() 137 | . "`n`tBar Height: " RB.GetBarHeight() 138 | . "`n`tRow Height: " RB.GetRowHeight(2) 139 | return 140 | 141 | Cut: 142 | GuiControl, Focus, %hTextEdit% 143 | ControlSend,, {Control Down}{x}{Control Up}, ahk_id %hTextEdit% 144 | return 145 | 146 | Copy: 147 | GuiControl, Focus, %hTextEdit% 148 | ControlSend,, {Control Down}{c}{Control Up}, ahk_id %hTextEdit% 149 | return 150 | 151 | Paste: 152 | GuiControl, Focus, %hTextEdit% 153 | ControlSend,, {Control Down}{v}{Control Up}, ahk_id %hTextEdit% 154 | return 155 | 156 | GuiClose: 157 | ExitApp 158 | return 159 | 160 | GuiSize: 161 | RB.ShowBand(1) ; Updates band sizes when gui is resized. 162 | return 163 | -------------------------------------------------------------------------------- /Examples/Rebar_Mult.ahk: -------------------------------------------------------------------------------- 1 | #NoEnv 2 | #SingleInstance, Force 3 | #Include ..\Class_Rebar.ahk 4 | 5 | Gui, Child1:-Caption +hwndhChildWnd1 6 | Gui, Child1:Add, Edit, yp x+10 7 | Gui, Child1:Add, Updown, Range0-100 8 | Gui, Child1:Add, Button, yp-1 x+0 gApply, Apply 9 | 10 | Gui, Child2:-Caption +hwndhChildWnd2 11 | Gui, Child2:Add, Edit, yp x+10 12 | Gui, Child2:Add, Updown, Range0-100 13 | Gui, Child2:Add, Button, yp-1 x+0 gApply, Apply 14 | 15 | Gui, +Resize 16 | Gui, Add, Custom, ClassReBarWindow32 hwndhRebar -Theme 0x0200 0x0400 0x0040 0x8000 17 | Gui, Show, w300 h80, Multiple controls per band 18 | 19 | RB := New Rebar(hRebar) 20 | RB.InsertBand(hChildWnd1, 0, "", 111, "Maximum:") 21 | RB.InsertBand(hChildWnd2, 0, "Break", 112, "Minimum:") 22 | return 23 | 24 | Apply: 25 | MsgBox, %A_Gui% 26 | return 27 | 28 | GuiSize: 29 | RB.ShowBand(1) 30 | return 31 | 32 | GuiClose: 33 | ExitApp -------------------------------------------------------------------------------- /Examples/SplitPanels.ahk: -------------------------------------------------------------------------------- 1 | ; Example of Split Panels with resizable GUI and controls 2 | 3 | #NoEnv 4 | #SingleInstance Force 5 | #Include ..\Class_Rebar.ahk 6 | 7 | Gui, LeftPanel:+HwndhLeft -Caption 8 | Gui, LeftPanel:Add, DDL, vDList, Item1||Item2|Item3 9 | Gui, LeftPanel:Add, ListBox, r10 vListB, Item1|Item2|Item3 10 | 11 | Gui, RightPanel:+HwndhRight -Caption 12 | Gui, RightPanel:Add, Tab2, h160 w100 vTabC, Tab A|Tab B|Tab C 13 | 14 | Gui, +Resize 15 | Gui, Add, Custom, ClassReBarWindow32 hwndhSplitter vSplitWin w380 -Theme 0x0800 0x0040 0x8000 0x0008 16 | Gui, Show, h200 w400 17 | 18 | rbSplitter := New Rebar(hSplitter) 19 | rbSplitter.InsertBand(hLeft, 0, "NoGripper", 10, "", 150, 0, "", 170, 80, 10) 20 | rbSplitter.InsertBand(hRight, 0, "", 20, "", 150, 0, "", 170, 80, 10) 21 | rbSplitter.SetMaxRows(1) 22 | 23 | WM_NOTIFY := 0x4E 24 | OnMessage(WM_NOTIFY, "RB_Notify") 25 | return 26 | 27 | GuiClose: 28 | ExitApp 29 | 30 | GuiSize: 31 | rbSplitter.ModifyBand(1, "MinHeight", (A_GuiHeight - 15)) 32 | rbSplitter.ModifyBand(2, "MinHeight", (A_GuiHeight - 15)) 33 | GuiControl, Move, SplitWin, % "W" (A_GuiWidth - 10) "H" (A_GuiHeight - 10) 34 | return 35 | 36 | LeftPanelGuiSize: 37 | GuiControl, LeftPanel:Move, DList, % "W" (A_GuiWidth - 25) 38 | GuiControl, LeftPanel:Move, ListB, % "W" (A_GuiWidth - 25) "H" (A_GuiHeight - 40) 39 | return 40 | 41 | RightPanelGuiSize: 42 | GuiControl, RightPanel:Move, TabC, % "W" (A_GuiWidth - 25) "H" (A_GuiHeight - 20) 43 | return 44 | 45 | RB_Notify(wParam, lParam) 46 | { 47 | Global rbSplitter 48 | rbSplitter.OnNotify(lParam) 49 | } 50 | 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Class Rebar 2 | 3 | ## Class for AutoHotkey Rebar custom controls 4 | 5 | AHK version: 1.1.23.01 6 | 7 | This class provides intuitive methods to work with Rebar controls created via **Gui, Add, Custom, ClassReBarWindow32**. 8 | 9 | ## Rebar Methods 10 | * DeleteBand(Band) 11 | * GetBand(Band [, ID, Text, Size, Image, Background, Style, Child]) 12 | * GetBandCount() 13 | * GetBarHeight() 14 | * GetLayout() 15 | * GetRowCount() 16 | * GetRowHeight(Band) 17 | * IDToIndex(ID) 18 | * InsertBand(hChild [, Position, Options, ID, Text, Size, Image, Background, MinHeight, MinWidth, IdealSize]) 19 | * MaximizeBand(Band [, IdealWidth]) 20 | * MinimizeBand(Band) 21 | * ModifyBand(Band, Property, Value [, SetStyle]) 22 | * MoveBand(Band, Target) 23 | * OnNotify(Param [, MenuXPos, MenuYPos, ID) 24 | * SetBandStyle(Band, Value) 25 | * SetBandWidth(Band, Width) 26 | * SetImageList(ImageList) 27 | * SetMaxRows([Rows]) 28 | * SetLayout(Layout) 29 | * ShowBand(Band [, Show]) 30 | * ToggleStyle(Style) 31 | 32 | ## Useful Rebar Styles 33 | Styles can be applied to Gui command options, e.g.: Gui, Add, Custom, ClassReBarWindow32 0x0800 0x0100 34 | 35 | * RBS_BANDBORDERS := 0x0400 - Add a separator border between bands in different rows. 36 | * RBS_DBLCLKTOGGLE := 0x8000 - Toggle maximize/minimize with double-click instead of single. 37 | * RBS_FIXEDORDER := 0x0800 - Always displays bands in the same order. 38 | * RBS_VARHEIGHT := 0x0200 - Allow bands to have different heights. 39 | * CCS_NODIVIDER := 0x0040 - Removes the separator line above the rebar. 40 | * CCS_NOPARENTALIGN := 0x0008 - Allows positioning and moving rebars. 41 | * CCS_NORESIZE := 0x0004 - Allows resizing rebars. 42 | * CCS_VERT := 0x0080 - Creates a vertical rebar. 43 | 44 | - - - 45 | 46 | ## Delete() 47 | Deletes a band from a rebar control. 48 | 49 | ### Return 50 | TRUE if successful, FALSE if there was a problem. 51 | 52 | ### Parameters 53 | * **Band** - 1-based index of the band to be deleted. 54 | 55 | ## GetBand() 56 | Retrieves information from a rebar band. 57 | 58 | ### Return 59 | TRUE if successful, FALSE if there was a problem. 60 | 61 | ### Parameters 62 | * **Band** - 1-based index of the band. 63 | * **ID** - OutputVar to store the band's ID. 64 | * **Text** - OutputVar to store the band's text. 65 | * **Size** - OutputVar to store the band's size. 66 | * **Image** - OutputVar to store the band's image index. 67 | * **Background** - OutputVar to store a handle to the band's background bitmap. 68 | * **Style** - OutputVar to store the band's style numeric value. 69 | * **Child** - OutputVar to store a handle to the band's child control. 70 | 71 | ## GetBandCount() 72 | Retrieves the count of bands currently in the rebar control. 73 | 74 | ### Return 75 | The number of bands in the rebar control. 76 | 77 | ## GetBarHeight() 78 | Retrieves the height of the rebar control. 79 | 80 | ### Return 81 | The height of the rebar control in pixels. 82 | 83 | ## GetLayout() 84 | Retrieves the current layout of bands in the rebar control. 85 | 86 | ### Return 87 | A string containing information about the current bands. String format is: ID1,Size1,Style1|ID2,Size2,Style2|... 88 | 89 | ## GetRowCount() 90 | Retrieves the number of rows of bands in a rebar control. 91 | 92 | ### Return 93 | The number of rows in the rebar control. 94 | 95 | ## GetRowHeight() 96 | Retrieves the number of rows of bands in a rebar control. 97 | 98 | ### Return 99 | The height of the row from the corresponding band in pixels. 100 | 101 | ### Parameters 102 | * **Band** - 1-based index of a band to retrieve the height from. 103 | 104 | ## IDToIndex() 105 | Converts a band identifier to a band index in a rebar control. 106 | 107 | ### Return 108 | The 1-based band index if successful, or 0 otherwise. 109 | 110 | ### Parameters 111 | * **ID** - The application-defined identifier of the band in question. 112 | 113 | ## InsertBand() 114 | Inserts a new band in a rebar control. 115 | 116 | ### Return 117 | TRUE if successful, FALSE if there was a problem. 118 | 119 | ### Parameters 120 | * **hChild** - Handle to the control contained in the band, if any. 121 | * **Position** - 1-based index of the location where the band will be inserted. If you set this parameter to 0, the control will add the new band at the last location. 122 | * **Options** - Enter zero or more words, separated by space or tab, from the following list to set the band's initial styles: Break, FixedBmp, FixedSize, Hidden, HideTitle, NoGripper, NoVert, TopAlign, VariableHeight. The following styles are applied by default** - ChildEdge, GripperAlways (can be disabled with NoGripper), UseChevron (only valid if IdealSize is set). 123 | * **ID** - Integer value that the control uses to identify this band. This parameter is required to retrieve and set layouts. 124 | * **Text** - The display text for the band. 125 | * **Size** - Length of the band, in pixels. 126 | * **Image** - 1-based index of any image that should be displayed in the band. SetImageList method must be called prior to this. 127 | * **Background** - Path of a bitmap file that is used as the background for this band. 128 | * **MinHeight** - Minimum height of the control, in pixels. 129 | * **MinWidth** - Minimum width of the control, in pixels. 130 | * **IdealSize** - Ideal width of the band, in pixels. If the band is maximized to the ideal width (see MaximizeBand method), the rebar control will attempt to make the band this width. 131 | 132 | ## MaximizeBand() 133 | Resizes a band to either its ideal or largest size. 134 | 135 | ### Return 136 | TRUE if successful, FALSE if there was a problem. 137 | 138 | ### Parameters 139 | * **Band** - 1-based index of a band to be maximized. 140 | * **IdealWidth** - If TRUE the ideal width of the band will be used to maximize 141 | 142 | ## MinimizeBand() 143 | Resizes a band to its smallest size. 144 | 145 | ### Return 146 | TRUE if successful, FALSE if there was a problem. 147 | 148 | ### Parameters 149 | * **Band** - 1-based index of a band to be minimized. 150 | 151 | ## ModifyBand() 152 | Sets band parameters such as Text and Size. 153 | 154 | ### Return 155 | TRUE if successful, FALSE if there was a problem. 156 | 157 | ### Parameters 158 | * **Band** - 1-based index of a band to be modified. 159 | * **Property** - Enter one word from the following list to select the Property to be set** - Style, ID, Text, Size, Image, Background, MinWidth, MinHeight, IdealSize, Child (handle of control). 160 | * **Value** - The value to be set in the selected Property. If Property is Style you can enter named values as in the InsertBand options, or an integer value. 161 | * **SetStyle** - Only valid if Property is Style. Determines whether to add or remove the styles. 162 | 163 | ## MoveBand() 164 | Moves a band from one index to another. 165 | 166 | ### Return 167 | TRUE if successful, FALSE if there was a problem. 168 | 169 | ### Parameters 170 | * **Band** - 1-based index of a band to be moved. 171 | * **Target** - 1-based index of a the new band position. 172 | 173 | ## OnNotify() 174 | Handles rebar notifications. This method should be called from the rebar's G-Label. If A_GuiEvent is "N", pass it A_EventInfo as the Param. You can also call it from a function monitoring the WM_NOTIFY message, pass it lParam as the Param. Currently this method is used to retrieve the position for a menu when the Chevron button is pushed and prevent a number of rows higher then the one set by SetMaxRows method. 175 | 176 | ### Return 177 | If the ChevronPushed notification is passed returns the index of the band it is from. 178 | 179 | ### Parameters 180 | * **Param** - The lParam from WM_NOTIFY message. 181 | * **MenuXPos** - OutputVar to store the horizontal position for a menu. 182 | * **MenuYPos** - OutputVar to store the vertical position for a menu. 183 | * **ID** - OutputVar to store the band's ID. 184 | 185 | ## SetBandStyle() 186 | Sets the style of a band. 187 | 188 | ### Return 189 | TRUE if successful, FALSE if there was a problem. 190 | 191 | ### Parameters 192 | * **Band** - 1-based index of the band. 193 | * **Value** - Named values as in the InsertBand options, or an integer value. 194 | 195 | ## SetBandWidth() 196 | Sets the width for a docked band. 197 | 198 | ### Return 199 | TRUE if successful, FALSE if there was a problem. 200 | 201 | ### Parameters 202 | * **Band** - 1-based index of the band. 203 | * **Width** - New width in pixels. 204 | 205 | ## SetImageList() 206 | Sets an ImageList to the rebar control. 207 | 208 | ### Return 209 | TRUE if successful, FALSE if there was a problem. 210 | 211 | ### Parameters 212 | * **ImageList** - ImageList ID. 213 | 214 | ## SetLayout() 215 | Sets a layout of bands in the rebar control. 216 | 217 | ### Return 218 | TRUE if a valid layout was passed, or FALSE otherwise. 219 | 220 | ### Parameters 221 | * **Layout** - A string containing information about the current bands. String format is** - ID1,Size1,Style1|ID2,Size2,Style2|... 222 | 223 | ## SetMaxRows() 224 | Sets the maximum number of rows allowed in a rebar control. This method requires the OnNotify method to be implemented. 225 | 226 | ### Return 227 | The number of rows previously allowed. 228 | 229 | ### Parameters 230 | * **Rows** - Number of maximum rows allowed. Set it to 0 to disable limit. 231 | 232 | ## ShowBand() 233 | Shows or hides a given band in a rebar control. 234 | 235 | ### Return 236 | TRUE if successful, FALSE if there was a problem. 237 | 238 | ### Parameters 239 | * **Band** - 1-based index of the band. 240 | * **Show** - Set to TRUE to show the band or FALSE to hide it. 241 | 242 | ## ToggleStyle() 243 | Toggles rebar's style. 244 | 245 | ### Return 246 | TRUE if a valid style is passed, or FALSE otherwise. 247 | 248 | ### Parameters 249 | * **Style** - Enter one or more words, separated by space or tab, from the following list to toggle toolbar's styles** - AutoSize, BandBorders, DblClkToggle, FixedOrder, RegisterDropdown, VarHeight, VerticalGripper. You may also enter an integer value to define the style. 250 | 251 | --------------------------------------------------------------------------------