Is it possible to have my Buttons in a message Box stacked Vertically instead of Horizontal?
CASE MESSAGE('Show Data?','Which Data',ICON:Question,'Button&1|Button&2|Button&3|&Abort',10,2)
OF 1
DO Button1
OF 2
DO Button2
OF 3
DO Button3
OF 4
RETURN
END
The above puts all buttons Horizontal.
In some of my Messages Boxes I need more then 15 buttons and some of them have a long full description on the button.
This causes the Message Box to display some of the buttons off the screen and then you have to drag the Message Box to see the rest.
It would be nice if there is a way to stack the buttons Vertical.
I created a Window procedure: MyMessage
Added the Prototype: (STRING,UNSIGNED=0,UNSIGNED=0),UNSIGNED
Added the Parameters: (input_text,caption,icon,buttons,default,style)
When I click on OK to save the procedure clarion just hangs and never comes alive again, I have to kill it in Taskmanager.
The prototype must be the same as MESSAGE (see Builtins.clw): MyMessage(STRING ptext, <STRING pcaption>, <STRING picon>, <STRING pbuttons>, UNSIGNED pdefault=0, UNSIGNED pstyle=0),UNSIGNED,PROC
I now have it partially to work, see attached.
There are still still a few items that I would like to get working but that is far above my knowledge.
Hope you can give me some help.
Set widths and heights of the buttons to Default, this will force them to increase the widths to display full text. Then use simple arithmetics to calculate horizontal positions: ?btn{PROP:Xpos} = (windowWidth - ?btn{PROP:Width}) / 2
Not sure if you really want to replace all message() calls with this window, or just have a useful alternate message procedure that you can call for certain stuff.
Seems like a listbox motif would be a useful/intuitive way to select the choices rather than a bunch of buttons. Easier to code too.
Because I could not get the: 0{Prop:Width} = MaxButtonWidth# + 6
to work I just kept on beating it with a bigger hammer in the hope that at some stage I can get it to work.
Try this way:
LOOP
CONTROL# = 0{PROP:NextField, CONTROL#}
IF CONTROL# = 0
BREAK
END
IF CONTROL# < 0
CYCLE
END
!Set CURSOR:HAND for each button
IF CONTROL#{PROP:Type}=CREATE:BUTTON THEN
CONTROL#{PROP:CURSOR}=β<0FFH,01H,8AH,7FH>β
END
!Set custom icon for each Combo Box
IF CONTROL#{PROP:Type}=CREATE:COMBO THEN
(CONTROL#{PROP:ButtonFeq}){PROP:ICON}=β~Downarrow32.ICOβ
END
END
You can walk through all window controls (see FIRSTFIELD and LASTFIELD in the help), and change control properties if its is of button type (see PROP:Type in the help). Below is the code to center horizontally all buttons.
Routine::Center ROUTINE
DATA
feq SIGNED, AUTO
winW SIGNED, AUTO
CODE
winW = 0{PROP:Width}
LOOP feq = FIRSTFIELD() TO LASTFIELD()
IF feq{PROP:Type} = CREATE:button
feq{PROP:Xpos} = (winW - feq{PROP:Width}) / 2
END
END
There is no guarantee that all controls will be from FIRSTFIELD() to LASTFIELD(). There can be gaps and controls created with CREATE can fall out of that range.
I recommend using Prop:NextField, this will loop through all fields on the window. On caveat, it does not guarantee that the loop will process the controls in order.
Routine::Center ROUTINE
DATA
feq SIGNED, AUTO
winW SIGNED, AUTO
CODE
winW = 0{PROP:Width}
feq = 0
LOOP
feq = 0{Prop:NextField, feq}
if feq = 0
break
end
IF feq{PROP:Type} = CREATE:button
feq{PROP:Xpos} = (winW - feq{PROP:Width}) / 2
END
END