Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Accordion control


  • Please log in to reply
7 replies to this topic
Klaus
  • Members
  • 333 posts
  • Last active: Feb 17 2015 09:31 AM
  • Joined: 12 May 2005
Hi, Community,
even though there are some posts dealing with the accordion control,
I felt free to invent the wheel a second (or third) time, so I constructed
an accordion control in pure AHK.
Here you see a sample code of it as a proof of concept with only one control belonging to each option:
SEtTitlematchmode, 2

;-------------------------------------------------------------------------------
; the accordion control
;-------------------------------------------------------------------------------
Gui, Add, GroupBox, w102 h300 x10 y10 
Gui, Add, Button,   w98  h20  x12 y18 vAcc1opt1    glAccordion1, Option 1
Gui, Add, Text,               x15 y48 vAcc1Opt1t1              , text1
Gui, Add, Edit,     w30       x50 y48 vAcc1Opt1e1      

Gui, Add, Button,   w98  h20  x12 y38 vAcc1opt2    glAccordion1, Option 2
Gui, Add, Text,               x15 y68 vAcc1Opt2t1              , text2
Gui, Add, Edit,     w30       x50 y68 vAcc1Opt2e1   

Gui, Add, Button,   w98  h20  x12 y58 vAcc1opt3    glAccordion1, Option 3
Gui, Add, Text,               x15 y88 vAcc1Opt3t1              , text3
Gui, Add, Edit,     w30       x50 y88 vAcc1Opt3e1   

;-------------------------------------------------------------------------------
; collect all buttons' names in a string
;-------------------------------------------------------------------------------
optionsAcc1=Acc1opt1|Acc1opt2|Acc1opt3

Gui, Show, w122 h320, Accordion

;-------------------------------------------------------------------------------
; hide the not active buttons' controls
;------------------------------------------------------------------------------- 
GuiControl, Hide, Acc1Opt1t1
GuiControl, Hide, Acc1Opt1e1
GuiControl, Hide, Acc1Opt2t1
GuiControl, Hide, Acc1Opt2e1
return

;-------------------------------------------------------------------------------
; when a accordion's control was clicked ...
;-------------------------------------------------------------------------------
lAccordion1:

;-------------------------------------------------------------------------------
; hide the controls of all the accordion's buttons
;-------------------------------------------------------------------------------
GuiControl, Hide, Acc1Opt1t1
GuiControl, Hide, Acc1Opt1e1
GuiControl, Hide, Acc1Opt2t1 
GuiControl, Hide, Acc1Opt2e1
GuiControl, Hide, Acc1Opt3t1
GuiControl, Hide, Acc1Opt3e1

;-------------------------------------------------------------------------------
; decide what's to be done, slide the buttons up ...
;-------------------------------------------------------------------------------
loop, parse, optionsAcc1, |
{
  if A_LoopField <= %A_GuiControl%
  {
    if (A_LoopField = "Acc1opt2")
      ControlMove, Option 2, ,  60, 98, 20
    if (A_LoopField = "Acc1opt3")
      ControlMove, Option 3, ,  80, 98, 20            
  }
}

;-------------------------------------------------------------------------------
; ... or down 
;-------------------------------------------------------------------------------
loop, parse, optionsAcc1, |
{
  if A_LoopField > %A_GuiControl%
  {
    if (A_LoopField = "Acc1opt3")
      ControlMove, Option 3, ,  310, 98, 20
    if (A_LoopField = "Acc1opt2")
      ControlMove, Option 2, ,  290, 98, 20
  }
}

;-------------------------------------------------------------------------------
; active (show) the controls of the clicked button of the accordion 
;-------------------------------------------------------------------------------
if (A_GuiControl = "Acc1Opt1")
{
  GuiControl, Show, Acc1Opt1t1
  GuiControl, Show, Acc1Opt1e1
}
if (A_GuiControl = "Acc1Opt2")
{
  GuiControl, Show, Acc1Opt2t1
  GuiControl, Show, Acc1Opt2e1
}
if (A_GuiControl = "Acc1Opt3")
{
  GuiControl, Show, Acc1Opt3t1
  GuiControl, Show, Acc1Opt3e1
}
return
I invite you to have a (friendly) look at it.

Things to come:
A fully customizable generator to generate accordions
Add a title to the embracing group box
Add arrows to the buttons' titles (arrow down for active option, left for the others)
...
All suggestions are welcome.
Let me know if it's of use for you.
Regards,
Klaus

keybored
  • Members
  • 351 posts
  • Last active: Apr 26 2013 09:08 AM
  • Joined: 18 Jun 2006
Klaus,
I'm impressed with your code. I'm not very good at GUIs myself, and I didn't even know what accordion controls were so I played with it.
There is a slight overlap on the Option 2 button with Option 1.
Have you already used this in an application yourself?

Dra_Gon
  • Members
  • 373 posts
  • Last active: Oct 27 2009 04:20 PM
  • Joined: 25 May 2007
LOL, I immediately thought "now what the heck would I do with a program that played the accordion?" Then I actually tried your script and the lightbulb went on.

This is excellent! I hadn't ever thought to check for something like this {and probably wouldn't have known what to call it}, but I'm sure I can come up with something to use it for sooner or later {with due credit, of course}.
Thanks a bunch!

Ciao,
Dra'Gon

EDIT: How about docking to the sides of the screen?
Posted Image
For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writersca...BlueDragonFire/

SoggyDog
  • Members
  • 803 posts
  • Last active: Mar 04 2013 06:27 AM
  • Joined: 02 May 2006
This is cool.

By the way, the other script that Klaus mentioned in the
top post is considerably smoother and just plain awesome,
but WAY more complex and IMHO, extremely difficult to understand.

This is a great substitute.

PS - ''Option 2'' overlaps ''Option 1'' for me, as well.

Klaus, not logged in
  • Guests
  • Last active:
  • Joined: --
Hi, keybored, Dra_Gon, SoggyDog,

thanks for your friendly attention to my little control.

Me myself stumpled over it in OpenOffice.org which has
lots of "accordions" and I had to research for it's correct
denomination. Here started the idea to realize it in AHK.

I will bear in mind your suggestions - the overlapping
is already fixed and will be published these days..
(Some aweful math that especially with customizable
button height and a title in the groupbox with varying
font size...)

And yes, I already use it in a somewhat bigger configuration
dialogue where it saves a lot of space.

Dra_Gon, please, would you be so kind to specify your "docking" to the
sides of the screen?

Thanks again, have a pleasant weekend,
Klaus

Before I forget:
1. I mentioned these arrows in front of the button's text.
(a down arrow for the activated button, a right arrow for the others).
Any ideas how to realize that (I found that wonderful post with graphics
on a button, but how to place a graphic AND a text on it?

2. Is there a way to give the text of the activated button the
attribute BOLD?

Any suggestions are appreciated!

Dra_Gon
  • Members
  • 373 posts
  • Last active: Oct 27 2009 04:20 PM
  • Joined: 25 May 2007
Basically just sticking to one side of the screen or the other. Maybe if it "hides" itself off-screen until the mouse is in a certain position also. Hmm, dang, there could be MANY more possibilities with this but the script would definitely get complicated :lol: . Might even be a regular project.

Ciao,
Dra'Gon
Posted Image
For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writersca...BlueDragonFire/

Klaus. not logged in
  • Guests
  • Last active:
  • Joined: --
Hi, Dra'Gon,
thank you very much for your explanations. I think these sticking to a side of the screen and appearing when the mouse approaches is a good feature,
but I regard this accordion control as a control to be used in other applications and not as a stand alone programme.
But thank you for your attention, anyway,
Regards,
Klaus

Klaus
  • Members
  • 333 posts
  • Last active: Feb 17 2015 09:31 AM
  • Joined: 12 May 2005
Hi, Community,

after the overwhelming reactions after my first post (There were three replies, thanks again in this place), I post here the1.0-version of the accordion control including a code generator, but I fear the world doesn't need.

Here comes the code:
;-------------------------------------------------------------------------------
; some variables
;-------------------------------------------------------------------------------
NL=`n
QUOTE="
DQUOTE=""

;-------------------------------------------------------------------------------
; a timer for the tool tips
;-------------------------------------------------------------------------------
SetTimer, lToolTips, 250

;-------------------------------------------------------------------------------
; the gui
;-------------------------------------------------------------------------------
Gui, Add, Text,   x10   y10                                   , Gui number
Gui, Add, Text,         y+14                                  , Accordion's number
Gui, Add, Text,         y+14                                  , Upper left corner x
Gui, Add, Text,         y+14                                  , Upper left Corner y
Gui, Add, Text,         y+14                                  , Groupbox's title
Gui, Add, Text,         y+14                                  , Title's position
Gui, Add, Text,         y+14                                  , Control's height
Gui, Add, Text,         y+14                                  , Control's width
Gui, Add, Text,   x210  y10                                   , Buttons' height
Gui, Add, Text,         y+14                                  , Buttons' width
Gui, Add, Text,         y+14                                  , Buttons' text
Gui, Add, Text,         y+14                                  , Border to Buttons
Gui, Add, Text,         y+14                                  , Addition Title
Gui, Add, Text,         y+14                                  , Adjustment top
Gui, Add, Text,         y+14                                  , Adjustment bottom
Gui, Add, Text,         y+14                                  , Description                           
Gui, Add, Text,         y+14                                  , Include commentary
                            
Gui, Add, Edit,   x120  y8     w30       vGuiNr               
gui, Add, Edit,         y+6    w50       vAccNr                                                              
Gui, Add, Edit,         y+6    w30       vulcX                
Gui, Add, Edit,         y+6    w30       vulcY                
Gui, Add, Edit,         y+6    w70       vgbTitle             
Gui, Add, DropDownList, y+6    w70 r3    vtPosition           , CENTER|LEFT|RIGHT           
Gui, Add, Edit,         y+6    w30       vcHeight             
Gui, Add, Edit,         y+6    w30       vcWidth              
Gui, Add, Edit,   x320  y8     w30       vbHeight             
Gui, Add, Edit,         y+6    w30       vbWidth              
Gui, Add, Edit,         y+6    w200      vbTexts              
Gui, Add, Edit,         y+6    w30       vBorderToButtons     , 8
Gui, Add, Edit,         y+6    w30       vAdditionTitle       , 10
Gui, Add, Edit,         y+6    w30       vAdjust1             , 23 
Gui, Add, Edit,         y+6    w30       vAdjust2             , 20
Gui, Add, Edit,         y+6    w200      vDescription
Gui, Add, Checkbox,     y+10             vchbComments CHECKED
          
                                                              
Gui, Add, Button, x10   y+40   w95   h40            glLoad    , Load definition`n     from file                               
Gui, Add, Button, x+10  yp     w95   hp             glSave    , Generate and`n  Save to file
Gui, Add, Button, x+10  yp     wp    hp             glGenClip , %A_Space%%A_Space%%A_Space%Generate and`ncopy to clipboard
Gui, Add, Button, x+10  yp     wp    hp             glQuit    , Quit

Gui, Show,   ,   Generate an accordion control
return

;-------------------------------------------------------------------------------
; the actions of the generator's buttons
;-------------------------------------------------------------------------------
lLoad:
MsgBox, Not implemented yet!
return   

lSave:
MsgBox, Not implemented yet!
return

lGenClip:
; initialize
Gui, Submit, Nohide
ac=

; some defaults
if GuiNr =
  GuiNr = 1
if AccNr = 
  AccNr = 1
if ulcX = 
  ulcX = 10
if ulcY = 
  ulcY = 10
if cHeight = 
{
  MsgBox, Control's height not specified!
  return
}
if cWidth =
{
  MsgBox, Control's Width not specified
  return
}
if bHeight =
  bHeight = 20
if bWidth =
{
  bWidth := cWidth - 4
}  

SetFormat, Float, 0.0
buttonToAcc := (cWidth - bWidth) / 2

  
; generate now!  
AutoTrim, Off
if (chbComments)
{
  append(";-------------------------------------------------------------------------------`n")
  append("; " . Description . NL)
  append("; generated by AccGen v1.0`n")
  append(";-------------------------`n")
  append("; positions, sizes and titles`n")
  append(";-------------------------------------------------------------------------------`n")
}



append("createAcc" . AccNr . ":" . NL) ; a label to be launched by the main programme to create the accordion control
append("DescriptionAcc" . AccNr . " = " . Description . NL) ; a variable to hold the description
append("guiNoAcc" . AccNr . " = " . GuiNr) ; guiNoAcc1 = 1 ; number of the gui where the control will be imbedded 
if (chbComments)
{
  append(A_Space . "; number of the gui where the control will be imbedded")
}
append(NL)
append("ulcXAcc" . AccNr . " = " . ulcX) ; x-value of the upper left corner of the whole control
if (chbComments)
{
  append(A_Space . "; x-value of the upper left corner of the whole control")
}
append(NL)
append("ulcYAcc" . AccNr . " = " . ulcY) ; y-value of the upper left corner of the whole control
if (chbComments)
{
  append(A_Space . "; y-value of the upper left corner of the whole control")
}
append(NL)
append("gbTitleAcc" . AccNr . " = " . gbTitle) ; title of the groupbox
if (chbComments)
{
  append(A_Space . "; title of the groupbox")
}
append(NL)
append("gbTitlePositionAcc" . AccNr . " = " . tPosition) ; adjusting the title
if (chbComments)
{
  append(A_Space . "; adjusting the title")
}
append(NL)
append("gbWidthAcc" . AccNr . " = " . cWidth) ; the groupbox's width
if (chbComments)
{
  append(A_Space . "; the groupbox's width")
}
append(NL)
append("gbHeightAcc" . AccNr . " = " . cHeight) ; the groupbox's height
if (chbComments)
{ 
  append(A_Space . "; the groupbox's height")
}
append(NL)
append("hButtonAcc" . AccNr . " = " . bHeight) ; the height of the buttons
if (chbComments)
{
  append(A_Space . "; the height of the buttons")
}
append(NL)
append("wButtonAcc" . AccNr . " = " . bWidth) ; the width of the buttons
if (chbComments)
{
  append(A_Space . "; the width of the buttons")
}
append(NL)
append("dButtonToAcc" . AccNr . " = " . buttonToAcc) ; the horizontal distance between buttons and groupbox
if (chbComments)
{
  append(A_Space . "; the horizontal distance between buttons and groupbox left and right")
}
append(NL)
append("dButtonToTitleAcc" . AccNr . " = " . BorderToButtons) ; the vertical distance between buttons and groupbox title
if (chbComments)
{
  append(A_Space . "; the vertical distance between buttons and groupbox title")
}
append(NL)
Loop, Parse, bTexts, | ; title of the buttons
{
  append("Button" . A_Index . "titleAcc" . AccNr . " = " . A_LoopField)
  if (chbComments)
  {
    append(A_Space . "; title of button no. " . A_Index)
  }
  append(NL)
}
append("AdditionTitleAcc" . AccNr . " = " . AdditionTitle) ; additional distance betwenn groupbox's upper border and the buttons
if (chbComments)
{
  append(A_Space . "; additional distance betwenn groupbox's upper border and the buttons")
}
append(NL)
append("AdjustmentTopAcc" . AccNr . " = " . Adjust1) ; correctional adjustment at the upper border of the groupbox
if (chbComments)
{
  append(A_Space . "; correctional adjustment at the upper border of the groupbox")
}
append(NL)
append("AdjustmentBottomAcc" . AccNr . " = " . Adjust2) ; correctional adjustment at the lower border of the groupbox
if (chbComments)
{
  append(A_Space . "; correctional adjustment at the lower border of the groupbox")
}
append(NL)
if (chbComments) ; because of the title in the groupbox the buttons have to start deeper
{ 
  append("; because of the title in the groupbox the buttons have to start deeper")
}
append(NL)
append("if (gbTitleAcc" . AccNr . " <> " . DQUOTE . ")" . NL)
append(A_TAB . "dButtontoTitleAcc" . AccNr . "+= AdditionTitleAcc" . AccNr . NL)
append("fButtonUpAcc" .  AccNr . ":= ulcYAcc" . AccNr . " + dButtonToTitleAcc" . AccNr . " + AdjustmentTopAcc" . AccNr)
if (chbComments)
{
  append(A_Space . "; upper left corner of topmost button")
}
append(NL)
append("fButtondownAcc" . AccNr . " := ulcYAcc" . AccNr . " + gbHeightAcc" .  AccNr . " + AdjustmentBottomAcc" . AccNr)
if (chbComments)
{
  append(A_Space . "; upper left corner of lowest button in down position")
}
append(NL)
if (chbComments) ; the accordion control, first the groupbox, followed by the buttons
{
  append(";-------------------------------------------------------------------------------`n")
  append("; the accordion control, first the groupbox, followed by the buttons`n")
  append(";------------------------------------------------------------------------------`n")
}
append("Gui, %GuiNoAcc" . AccNr . "%: Add, Groupbox, w%gbWidthAcc" . AccNr . "% h%gbHeightAcc" . AccNr . "% x%ulcXAcc" . AccNr . "% y%ulcYAcc" . AccNr . "% vAcc" . AccNr . "Box %gbTitlePositionAcc" . AccNr . "%, %gbTitleAcc" . AccNr . "%" . NL) ; the groupbox
loop, Parse, bTexts, | ; the buttons
{
  append("Gui, %GuiNoAcc" . AccNr . "%: Add, Button,")
  if (A_Index = 1)
  {
    append(A_Space . "w%wButtonAcc" . AccNr . "% h%hButtonAcc" . AccNr  . "% xp+%dButtonToAcc" . AccNr . "% yp+%dButtonToTitleAcc" . AccNr . "%")
  }
  else
  {
    append(A_Space . "wp hp y+1")
  }
  append(A_Space . "vAcc" . Accnr . "Opt" . A_Index . " glActionAcc" . AccNr . ", %Button" . A_Index . "TitleAcc" . AccNr . "%")
  append(NL)
}
append(NL)
if (chbComments) ; the individual controls of the accordion
{
  append(";-------------------------------------------------------------------------------`n")
  append("; individually inserted controls belonging to the single buttons`n")
  append("; these controls have to be added to`n") 
  append("; - the initial hiding section when control gets built`n")
  append("; - the click hiding section after having clicked a button`n")
  append("; - show activated button's controls section after having changed the control`n")
  append(";-------------------------------------------------------------------------------`n")
}
loop, parse, bTexts, |
{
  append("; controls for option button " . A_Index . NL)
  append("; Gui, GuiNoAcc" . AccNr . "%: Add, " .  NL)
}
append(NL)
if (chbComments) ; collect all buttons' names for latter parsing
{
  append(";-------------------------------------------------------------------------------`n")
  append("; collect all buttons' names in a string`n")
  append(";-------------------------------------------------------------------------------`n")
}
append("optionsAcc" .  AccNr . "=")
loop, parse, bTexts, |
{
  if (A_Index > 1)
  {
    append("|Acc" . AccNr . "opt" . A_Index)
  }
  else
  {
    append("Acc" . AccNr . "opt" . A_Index)
  }
  buttonCount = %A_Index%
}
append(NL)
if (chbComments) ; a show-command for testing
{
  append(";-------------------------------------------------------------------------------`n")
  append("; show the control for testing, keep the comment when importing`n")
  append(";-------------------------------------------------------------------------------`n")
}
append("; Gui, %GuiNoAcc" . AccNr . "%: Show,, Accordion-Test" . NL)
append(NL)
if (chbComments) ; hide the controls initially
{
  append(";-------------------------------------------------------------------------------`n")
  append("; initial hiding section:`n") 
  append("; hide all controls but these of the lowest button`n")
  append(";-------------------------------------------------------------------------------`n") 
}
append("; GuiControl, Hide, ...`n")
append("return`n")
append(NL)
if (chbComments) ; when a button was clicked ...
{
  append(";-------------------------------------------------------------------------------`n")
  append("; when an accordion's control was clicked ...`n")
  append(";-------------------------------------------------------------------------------`n")
}
append("lActionAcc" . AccNr . ":")
append(NL)
if (chbComments)
{
  append(";-------------------------------------------------------------------------------`n")
  append("; don't do anything if the currently clicked button is it's own successor`n") 
  append("; avoids flickering of the button's controls`n")
  append(";-------------------------------------------------------------------------------`n")  
}
append("IfInString, Acc" . AccNr . "LastButton, %A_GuiControl%" . NL)
append(A_Space . "return")
append(NL)
if (chbComments) ; hide all controls
{
  append(";-------------------------------------------------------------------------------`n")
  append("; click hiding section`n") 
  append("; hide all controls of all the accordion's buttons`n")
  append(";-------------------------------------------------------------------------------`n")
}
append("; GuiControl, Hide, ...")
append(NL)
if (chbComments) ; keep the last clicked control's name
{
  append(";-------------------------------------------------------------------------------`n")
  append("; keep in mind the currently clicked button`n")
  append(";-------------------------------------------------------------------------------`n")
}
append("Acc" . AccNr . "LastButton = %A_GuiControl%" . NL)
if (chbComments) ; move the controls up ...
{
  append(";-------------------------------------------------------------------------------`n")
  append("; decide what's to be done, slide the buttons up ...`n")
  append("; (the topmost button never moves)`n")
  append(";-------------------------------------------------------------------------------`n")
}
append("loop, parse, OptionsAcc" . AccNr . ", |" . NL)
append("{" . NL)
append(A_TAB . "if A_LoopField <= %A_GuiControl%" . NL)
append(A_TAB . "{" . NL)
loop, %ButtonCount%
{

  if (A_Index = 1)
    continue
	append(A_TAB . A_TAB . "if (A_LoopField = " . QUOTE . "Acc" . AccNr . "Opt" . A_Index . QUOTE . ")" . NL)
	tmpCnt := A_Index - 1
  append(A_TAB . A_TAB . A_TAB . "ControlMove, %Button" . A_Index . "TitleAcc" . AccNr . "%,, fButtonUpAcc" . AccNr . " + (" . tmpCnt . " * hButtonAcc" . AccNr . ")" . NL)    
}
append(A_TAB . "}" . NL)
append("}" . NL)
if (chbComments) ; or move them down
{
  append(";-------------------------------------------------------------------------------`n")
  append("; ... or down`n") 
  append(";-------------------------------------------------------------------------------`n")
}

append("loop, parse, OptionsAcc" . AccNr . ", |" . NL)
append("{" . NL)
append(A_TAB . "if A_LoopField > %A_GuiControl%" . NL)
append(A_TAB . "{" . NL)
loop, %ButtonCount%
{
  if (A_Index = 1)
    continue
	append(A_TAB . A_TAB . "if (A_LoopField = " . QUOTE . "Acc" . AccNr . "Opt" . A_Index . QUOTE . ")" . NL)
	tmpCnt := ButtonCount - A_Index + 1
  append(A_TAB . A_TAB . A_TAB . "ControlMove, %Button" . A_Index . "TitleAcc" . AccNr . "%,, fButtonDownAcc" . AccNr . " - (" . tmpCnt . " * hButtonAcc" . AccNr . ")" . NL)    
}
append(A_TAB . "}" . NL)
append("}" . NL)
if (chbComments) ; show the controls of the activated button
{
  append(";-------------------------------------------------------------------------------`n")
  append("; show activated button's controls section`n")
  append("; activate (show) the controls of the clicked button of the accordion`n") 
  append(";-------------------------------------------------------------------------------`n")
}

loop, parse, bTexts, | 
{
  ; if (A_GuiControl = "Acc1Opt1")
  append("if (A_GuiControl = " . QUOTE . "Acc" . AccNr . "Opt" . A_Index . QUOTE . ")" . NL)
  append("{" . NL)
  append(";" . A_TAB . "to be completed manually" . NL)
  append(";" . A_TAB . "GuiControl, Show, ..." . NL)
  append("}" . NL) 
  append(NL)
}
append(NL)
append("Return")
append(NL)
AutoTrim, On
clipboard := ac ; move the generated code to the clipboard
MsgBox, Code generated and copied to the clipboard!
return
;-------------------------------------------------------------------------------
; terminating the generator
;-------------------------------------------------------------------------------
lQuit:
Goto, GuiClose
return   

;-------------------------------------------------------------------------------
; display tooltips for the generator's edit controls
;-------------------------------------------------------------------------------
lToolTips:
IfWinNotActive, Generate an accordion control
{
  ToolTip
  Return
}

tt_text =
MouseGetPos,,,id, TheControl

tt_text=
sb_setText("",3)

if (TheControl=="Edit1")
{
  tt_text=The number of the Gui where`nthe control will reside in`n[default = 1]
}
if (TheControl=="Edit2")
{
  tt_text=The unique number or string`nof the accordion control`n[default = 1]
}
if (TheControl=="Edit3")
{
  tt_text=The x-value of the upper left`ncorner of the whole control`n[default = 10]   
}
if (TheControl=="Edit4")
{
  tt_text=The y-value of the upper left`ncorner of the whole control`n[default = 10]   
}
if (TheControl=="Edit5")
{
  tt_text=The title of the group box`naround the control's buttons,`nleave empty if none is desired   
}
if (TheControl=="ComboBox1")
{
  tt_text=The position of the title,`nin the groupbox's upper border`n[RIGHT, CENTER or LEFT]
}
if (TheControl=="Edit6")
{
  tt_text=The accordion control's height
}
if (TheControl="Edit7")
{
  tt_text=The accordion control's width
}
if (TheControl="Edit8")
{
  tt_text=The height of the control's options
}
if (TheControl="Edit9")
{
  tt_text=The width of the controls options,`nif 0, the width will be set to fill out the groupbox
}
if (TheControl="Edit10")
{
  tt_text=The captions of the buttons,`nseperated by a |,`na preceding & generates`na hotkey ALT + following character
}
if (TheControl="Edit11")
{
  tt_text=The number of pixels between`nupper border of the groupbox`nand the buttons
}
if (TheControl="Edit12")
{ 
  tt_text=A number of pixels to move`nthe buttons down when`nthe groupbox has a title
}
if (TheControl="Edit13")
{ 
  tt_text=A number of pixels to define`nthe buttons' highest position`ndepending on desktop themes`n[23 for classical windows]`nChange only when results don't satisfy
}
if (TheControl="Edit14")
{
  tt_text=A number of pixels to define`nthe buttons' lowest position`ndepending on desktop themes`n[20 for classical windows]`nChange only when results don't satisfy
}
if (TheControl="Edit15")
{
  tt_text=A description of the control
}
if (TheControl="Button1")
{
  tt_text=Generate the code with`ncomments. Or without.
}
Tooltip, %tt_text%
return 
;-------------------------------------------------------------------------------
; terminating the generator
;-------------------------------------------------------------------------------
GuiEscape:
GuiClose:
ExitApp
;-------------------------------------------------------------------------------
; function to append snippets to the generated code
;-------------------------------------------------------------------------------
append(string)
{
  global ac
  ac=%ac%%string%
}

The generator comes with a simple gui whose controls are to be described in the following (there are tooltips, just hover over the edit controls).
Save the code as GenAcc.ahk and let it run. You will see the following gui:

Gui number: The Gui number where the control will be embedded (default: 1) try: 1

Accordion's number: The accordion's number to be able to use more than one accordion in one gui (default: 1) try: 1

Upper left corner x: The x-value of the upper left corner of the control in the grid of it's parent gui (default: 10) try: 10

Upper left corner y: the y-value of the upper left corner of the control in the grid of it's parent gui (default: 10) try: 10

Groupbox's title: Text to appear in the upper border of the groupbox, leave blank if no one is desired, try: Settings

Title' position: Choose in the drop down list, CENTER, LEFT or RIGHT available, try: CENTER

Control's height: The height of the whole accordion control, try: 300

Control's width: The width of the whole accordion control, try: 200

Buttons' height: The height of the single options (buttons) of the accordion, try: 20

Buttons' width: The width of the single options (buttons) of the accordion, try: leave it blank

Buttons' text: These are the captions of the buttons belonging to your accordion, separated by a | and creating hotkeys by preceeding a letter by a &. Try: Options|Misc.|Extras

Border to Buttons: The distance between the buttons and the upper border of the groupbox, for a first try, just leave it at 8

Addition Title: An additional number of pixels to move the buttons down when the groupbox has a title, just leave it at 10, might be the right value for a font size of 10.

Adjustment top: Top adjustment value, due to different themes, have a first try with 23

Adjustment bottom: Bottom adjustment value, due to different themes, have a first try with 20

Description: a brief description of the control, not visible

Include commentary (Checkbox): Include commentaries in generated code recommended if you are interested in the generated code

Load definition from file (Button): Not implemented yet, will load input from earlier written .XML-file, perhaps you will modify and generate again.

Generate and save to file (Button): Not implemented yet, will save generated code into an .AHK-file and the input into a descriptive .XML-file

Generate and copy to clipboard (Button): Generates the .AHK-Code from the current control content and copies it to the clipboard

Quit (Button): Terminates the generator

First try:

1. Fill out the form and generate the code, open a new text file in your preferred editor (PSPad is mine) and paste the code in it.

2. Look for a line like
; Gui, %GuiNoAcc1%: Show,, Accordion-Test                                                     

3. Remove the ";".

4. Save the code as an .AHK-file.

5. Let it run.

6. Now you can click the different buttons and the clicked one comes into focus. That means, the focussed buttons move up (if necessary), the buttons below it move down.

7. But there are no controls (e. g. edit controls) under the buttons. You have to code them by yourself.

8. Look for a line like
; individually inserted controls belonging to the single buttons
Here you can insert controls which will appear when its parent button gets focussed

9. Look for a line like
; initial hiding section:
Here you have to insert the control too, because not all controls may be visible at programme start.
Include here all controls but these of the lowest button, because the are the only visible. At programme start the lowest button is the activated.

10. Look for the line
; click hiding section
Here you have to insert the controls too, because when a new button was clicked, all controls must be hidden

11. Look for the line
; show activated button's controls section
Here you have to "show" the control which belong to the activited button

12. That's it. You can save the test programme again and let it run. You will see the whole control fully functional.

Annotation:
When imbedding the whole control in another programme, remove the
Gui, Show ...
line.
Just insert the generated code into your source file or include it as an #include-file.
Call the control with a
Gosub, CreateAcc{nnn} ; nnn = the accordion's number
Here you see: Use different accordion numbers when including more than one accordion into your source. (But use the same gui number!)

Restrictions:
All button names must be unique (even all the other controls in your main application), because the buttons are moved by calling them by name (means v-option). How could it be done in an name-independent way?

Suggestions:
Are welcome!

Tell me what you think!

Regards,
Klaus