[Class] Rebar - Adjustable GUI controls (Updated 03/17/2016)

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Pulover
Posts: 612
Joined: 29 Sep 2013, 19:51
Location: Brazil
Contact:

[Class] Rebar - Adjustable GUI controls (Updated 03/17/2016)

04 Oct 2013, 07:31

This class attempts to provide intuitive methods to work with rebars created using Gui Custom controls.

A Rebar control acts as a container for child windows. It can contain one or more bands, and each band can have any combination of a gripper bar, a bitmap, a text label, and one child window. An application assigns a child window—typically another control— to a rebar control band. As you dynamically reposition a rebar control band, the rebar control manages the size and position of the child window assigned to that band. Also, an application can specify a background bitmap for a band, and the rebar control will display the band's child window over the bitmap. -- MSDN

Screenshot:
Image

Features:
  • Insert bands with any control.
  • Add text, image icon and background for each band.
  • Save and load layouts.
  • Retrieve and change information of bar and each band.
:arrow: Sources, documentation and examples on GitHub

Reference: Rebar (MSDN)
Last edited by Pulover on 17 Mar 2016, 06:19, edited 4 times in total.
Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
User avatar
Chef
Posts: 50
Joined: 14 Nov 2013, 13:01

Re: [Class] Rebar - Adjustable GUI controls

22 Nov 2013, 12:31

Very nice, time to rewrite few scripts Image
User avatar
Pulover
Posts: 612
Joined: 29 Sep 2013, 19:51
Location: Brazil
Contact:

Re: [Class] Rebar - Adjustable GUI controls

16 Mar 2016, 19:52

Update:
  • Updated class to new AHK Object methods.
Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
User avatar
CheshireCat
Posts: 11
Joined: 07 Mar 2016, 15:58

Re: [Class] Rebar - Adjustable GUI controls (Updated 03/17/2016)

03 Apr 2016, 19:43

Hi,
This is awesome. I have used the Rebar library by majkinetor previously but I think this one is more user friendly.
I have a few questions however. I am interested in using a Rebar mainly because it has a "splitter" or "separator". I've made a GUI that has a listbox on the left side of the window with a drop down box above it, and then a tab control on the right side. I can set two Rebar bands (as used in your Rebar_Multiple example on GitHub) with one band having a GUI with the dropdown list and listbox, and the second band with the tab control and any other controls, etc.
My question is how can I implement the "SetMaxRows()" method in order to limit the max rows to be only 1? ie: both bands being side by side without the ability to stack the bands above or below one another.

Any insight or assistance would be great.

Thank you.
User avatar
Pulover
Posts: 612
Joined: 29 Sep 2013, 19:51
Location: Brazil
Contact:

Re: [Class] Rebar - Adjustable GUI controls (Updated 03/17/2016)

03 Apr 2016, 22:13

Hello CheshireCat,
Thank you for the feedback, it's good to know that this class is being useful. :D

Well, SetMaxRows(1) seems to work. You just can't forget to implement OnNotify(). I have found your description interesting and thought I should include an example of split panels with resizable controls in the repo.

This is the new demo, it should help you get this splitter done. I've set a few styles to make it look good for this purpose.

Code: Select all

; Example of Split Panels with resizable GUI and controls

#NoEnv
#SingleInstance Force
#Include <Class_Rebar>

Gui, LeftPanel:+HwndhLeft -Caption
Gui, LeftPanel:Add, DDL, vDList, Item1||Item2|Item3
Gui, LeftPanel:Add, ListBox, r10 vListB, Item1|Item2|Item3

Gui, RightPanel:+HwndhRight -Caption
Gui, RightPanel:Add, Tab2, h160 w100 vTabC, Tab A|Tab B|Tab C

Gui, +Resize
Gui, Add, Custom, ClassReBarWindow32 hwndhSplitter vSplitWin w380 -Theme 0x0800 0x0040 0x8000 0x0008
Gui, Show, h200 w400

rbSplitter := New Rebar(hSplitter)
rbSplitter.InsertBand(hLeft, 0, "NoGripper", 10, "", 150, 0, "", 170, 80, 10)
rbSplitter.InsertBand(hRight, 0, "", 20, "", 150, 0, "", 170, 80, 10)
rbSplitter.SetMaxRows(1)

WM_NOTIFY := 0x4E
OnMessage(WM_NOTIFY, "RB_Notify")
return

GuiClose:
ExitApp

GuiSize:
rbSplitter.ModifyBand(1, "MinHeight", (A_GuiHeight - 15))
rbSplitter.ModifyBand(2, "MinHeight", (A_GuiHeight - 15))
GuiControl, Move, SplitWin, % "W" (A_GuiWidth - 10) "H" (A_GuiHeight - 10)
return

LeftPanelGuiSize:
GuiControl, LeftPanel:Move, DList, % "W" (A_GuiWidth - 25)
GuiControl, LeftPanel:Move, ListB, % "W" (A_GuiWidth - 25) "H" (A_GuiHeight - 40)
return

RightPanelGuiSize:
GuiControl, RightPanel:Move, TabC, % "W" (A_GuiWidth - 25) "H" (A_GuiHeight - 20)
return

RB_Notify(wParam, lParam)
{
    Global rbSplitter
    rbSplitter.OnNotify(lParam)
}

The only thing that doesn't work when I make controls resizable is the minWidth of the bands... Probably another bug in MS control.

Let me know if you have more doubts.
Last edited by Pulover on 04 Apr 2016, 00:15, edited 1 time in total.
Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)
User avatar
CheshireCat
Posts: 11
Joined: 07 Mar 2016, 15:58

Re: [Class] Rebar - Adjustable GUI controls (Updated 03/17/2016)

03 Apr 2016, 23:44

Ahhhh, wow, that's exactly what I had in mind. I thought it would be harder to code. As I start using it I'm sure I'll have more questions, but that was excellent.
Thank you so much for your prompt response and example. :)
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: [Class] Rebar - Adjustable GUI controls (Updated 03/17/2016)

04 Sep 2016, 15:27

Hi, I need something like Rebar for UCR (See sig).
However, UCR uses AHK_H, and we have support for resizable guis + guicontrols in AHK_H, so I was wondering if there is any code in this project which would help me.

Here is a mockup of the GUI that I have, laid out using AHK_H's layout system. I would want to be able to resize the divide between the red and blue GUIs

Code: Select all

#SingleInstance force

Gui, Color, Black
Gui, Margin, 0, 0
Gui, +Resize +HwndhMain

Gui, Left:Color, Red
Gui, Left:-Caption +VScroll

Loop 10 {
	Gui, Left:Add, Edit, w60 aw
}
Gui, Left:Show, w100 Hide	; Set initial dimensions pre size-up

Gui, Right:Color, Blue
Gui, Right:-Caption +VScroll

Loop 20 {
	Gui, Right:Add, Edit, w60
}
Gui, Right:Show, w100 Hide	; Set initial dimensions pre size-up

Gui, % hMain ":Add", Gui, w100 h100 aw ah ,Left
Gui, % hMain ":Add", Gui, x+0 w100 h100 ah ax,Right

Gui, % hMain ":Show", Hide	; Set Min Size
Gui, % hMain ":Show", w400 h200	; Resize up to initial show size
return

GuiClose:
	ExitApp

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Gio710 and 110 guests