View previous topic :: View next topic |
Author |
Message |
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Mon Mar 23, 2015 4:21 am Post subject: Closing a dialog or window - returned value |
|
|
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 |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Mon Mar 23, 2015 1:38 pm Post subject: |
|
|
The return value from a dialogue is the button number that caused it to terminate.
Ian |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Mon Mar 23, 2015 2:58 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Mon Mar 23, 2015 3:10 pm Post subject: |
|
|
Can you supply some code to illustrate the context? |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Mon Mar 23, 2015 4:05 pm Post subject: |
|
|
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:
Quote: | 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 |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Mon Mar 23, 2015 4:55 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
|