Can I have Vertical Buttons instead of Horizontal in a Message Box


#1

Hi,

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.

Regards

Johan de Klerk


#2

Sure, you can use SYSTEM{PROP:MessageHook} to replace standard MESSAGE with your own, and customize it like you wish.


#3

Hi Mike,

Thanks for the reply.

I have tried it previously by following this article: https://www.icetips.com/showarticle.php?articleid=1543 but could not get it to work.

I am using C6.3-9058 if that makes a difference.

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.

Regards

Johan de Klerk


#4

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


#5

Hi Mike,

Thanks for your help an guidance.

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.

Regards

Johan de KlerkOwnMessageBox.zip (10.7 KB)


#6

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


#7

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.


#8

Hi Mike,

Thanks.
It works perfect.

Regards

Johan de Klerk


#9

Hi Jeff,

No I don’t want to replace all message boxes.
Only in some very specific cases with my one.

Thanks for the suggestion.
I will take a dive into this and see how it will work.

Regards

Johan de Klerk


#10

Hi,

One more thing I am trying to get working but my code does not seem to work.

I have the size/width of the button with the most text

I am setting my window width as follows:
0{Prop:Width} = MaxButtonWidth# + 6 ! Does not Work
0{Prop:Center} = TRUE
Resizer.Resize
Resizer.Reset

However the windows width does not get set.
My original window width is 250.
Even after I set it it stay at 250.

What am I doing wrong?

Regards

Johan de Klerk


#11

I believe you know why you wrote above lines :grinning:


#12

Hi Mike,

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.

So far no luck.

Regards

Johan de Klerk


#13

just added this line and it works:
0{PROP:Width} = 0{PROP:Width} * 2


#14

Hi Mike,

I must have done something wrong.
I copied yours and now it works.

Regards

Johan de Klerk


#15

I currently currently have 13 of these: ?Button1{Prop:Hide} = FALSE

CASE Button#
OF 1
?Button1{Prop:Hide} = FALSE
OF 2
?Button2{Prop:Hide} = FALSE
END

How can I replace the 1,2,3,4,5,6,7,8,9,10,11,12,13 in ?Button1
with the value of Button#


#16

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


#17

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

#18

Man, the support, help and advice on this group is great.
I am constantly learning something new on this group.

I am getting there slowly but surely.
I have almost everything working/done that I wanted it to do.

I will post my app here once I am happy with it, maybe it can help others as well.

Thanks for all the help and advice.

Regards

Johan de Klerk


#19

Hi Mike,

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

#20

Hi Rick,

Thank you very much for the tip.

Regards

Johan de Klerk