forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Closing a dialog or window - returned value

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Mon Mar 23, 2015 4:21 am    Post subject: Closing a dialog or window - returned value Reply with quote

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
View user's profile Send private message Visit poster's website
IanLambley



Joined: 17 Dec 2006
Posts: 490
Location: Sunderland

PostPosted: Mon Mar 23, 2015 1:38 pm    Post subject: Reply with quote

The return value from a dialogue is the button number that caused it to terminate.
Ian
Back to top
View user's profile Send private message Send e-mail
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Mon Mar 23, 2015 2:58 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7923
Location: Salford, UK

PostPosted: Mon Mar 23, 2015 3:10 pm    Post subject: Reply with quote

Can you supply some code to illustrate the context?
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Mon Mar 23, 2015 4:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Mon Mar 23, 2015 4:55 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group