1. Yuri Denshchik
  2. PowerBuilder
  3. Wednesday, 26 June 2019 16:30 PM UTC

I have modal window with OK and Cancel buttons. 

On OK button the modal closes and returns some string value: CloseWithReturn(Parent, ls_string)

On Cancel it just closes the modal:Close(Parent)

How to distinguish on  parent window that user clicked on OK or Cancel button when return string is empty ?

Message.StringParm is empty for both of the cases.

Thank you,

Yuri

 

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 26 June 2019 18:36 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi, Yuri -

I always pass to the opened window a generalized parameters structure that contains a special-purpose boolean along with unbounded arrays of many different datatypes:

Boolean b_cancel
Boolean b_val[]
Integer i_val[]
UInt    ui_val[]
Long    l_val[]
ULong   ul_val[]
Decimal dec_val[]
String  s_val[]
DataWindow dw_val[]
  .
  .
  .

You get the idea. I populate the arrays as needed before passing the structure in to a window via OpenWithParm or OpenSheetWithParm, and I pass back another parameters structure that has been populated as needed via CloseWithReturn.

The opened window must set the "b_cancel" structure member to TRUE if the user closes the window by canceling. The structure is returned as Message.PowerObjectParm. I always open/close windows with this convention so that the opened window can notify the calling window/object if the user closed the window by canceling.

HTH

John

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 26 June 2019 19:26 PM UTC
  2. PowerBuilder
  3. # 1

I like to put this in both buttons:

CloseWithReturn(Parent, this.ClassName())

Then in the calling script I put a case statement like this:

choose case Message.StringParm
   case "cb_ok"
   case else // cb_cancel or empty if the X button clicked
end choose

 

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 26 June 2019 18:51 PM UTC
  2. PowerBuilder
  3. # 2

Hi Yuri;

  You should always then use a CloseWithReturn - for example

CloseWithReturn (Parent, "")   

// OR ....

        Message.StringParm = ""

Close (Parent)

HTH

Regards ... Chris

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.