Silverfrost Forums

Welcome to our forums

Closing a dialog or window - returned value

23 Mar 2015 3:21 #15948

I've been playing around with this and had a question:

Why is the value returned from a dialog always made a positive number?

It isn't clear in the documentation that this is the case, only that returning a number less than 1 will cause the window or dialog to close, with positive values causing certain actions to take place without necessarily closing the window or dialog.

I ask just for information.

Bill

23 Mar 2015 12:38 #15959

The return value from a dialogue is the button number that caused it to terminate. Ian

23 Mar 2015 1:58 #15961

Well, yes and no. In my case, the return codes (values returned as KIND=3) are assigned by the function performed by clicking buttons. I assign those return values. And, they are negative (as they should be to close the window/dialog) and that works fine.

My question is more esoteric; why are they converted to positive numbers? No matter what their origin might be.

23 Mar 2015 2:10 #15963

Can you supply some code to illustrate the context?

23 Mar 2015 3:05 #15965

Bill,

Because that's how Clearwin+ is, and how it was designed. The documentation expressly states it, and rather unusually explains why it does what it does. Hint: in FTN95.CHM, find Win32 platform > Clearwin + > Format windows > callback functions where it says:

Returning a negative value can be very convenient. Consider a window with a list box and OK and CANCEL buttons. Typically it is required that a double click on a list box item will select that item and close the window as if the OK button had been pressed. To achieve this the list box call-back function should return -1, so that winio@ will return 1 as if the OK button had been pressed - thus saving a flag and more complex program logic.

Eddie

23 Mar 2015 3:55 #15966

Eddie, thanks for the quote. This does explain it, and quite well.

I was just curious, and although I had opened many of the HELP messages, I had missed this one.

Again, thanks! Bill

Please login to reply.