1. Tracy Lamb
  2. PowerBuilder
  3. Saturday, 18 February 2023 16:48 PM UTC

Hi all,

I have a window with a tab folder.  The tab folder has 4 tabs.  In one of the tabs, I need to open a pop-up window from the dw on the tab page to do some calculations.  (The window pops up from an option on the RMB menu). The dw has a couple values that the pop-up window needs. I'd also like to move the focus from one row to another on the dw, and then read new values from the dw.

Is there a way to do this with a pop-up window?  

Thanks,

~~~Tracy

 

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Tuesday, 21 February 2023 23:13 PM UTC
  2. PowerBuilder
  3. # Permalink

Thank you for all of your support!  All I really wanted to do is to communicate with the dw that opens the pop-up window.  For some reason, I thought I had to communicate through functions on the parent window, so I didn't ask about that (lol!).  That being said, here's what I did....

1. Created a pop-up window with an instance variable: u_dw idw_1   (u_dw is the pfc flavor of a standard dw )
2. Added an event to the dw on the parent window's tab/tabpage/dw object that's fired from the RMB menu (ue_open_calculator)
3. Open the popup window with a reference to the dw: OpenWithParm(w_popup_calculator, this)
4. In the open event of the popup window, grab the dw reference:  idw_1 = Message.PowerObjectParm
5. Populate the calculator-related sle's with values from idw_1: 
     il_Row = idw_1.GetRow()
     ls_nominal = idw_1.GetItemString(il_Row, "nominal")
     sle_nominal.text = ls_nominal
     (etc)
6. In the Activate event, re-populate the sle's just in case the user changed the row in the parent dw (the pop-up window allows interaction with the parent window while it's still open, unlike a response window): 
    if IsValid(idw_1) then
        il_Row = idw_1.GetRow()
        ls_nominal = idw_1.GetItemString(il_Row, "nominal")
        sle_nominal.text = ls_nominal
        (etc)
7.  Do calculations based on what the user enters. 
8.  When the user clicks the SAVE button: write a couple values to idw_1, advance to the next row in idw_1, and grab the new values.

The "missing link" for me was knowing what the optional 3rd parameter in the OpenWithParm function does. Turns out, it doesn't do anything useful for me.

Again, many thanks to all for your thoughtful feedback.  Cheers!
~~~Tracy

 

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 20 February 2023 20:23 PM UTC
  2. PowerBuilder
  3. # 1

// In the parent window - Instance variables:
w_parent_window     iw_parent


// The structure istr_parms:
// --> add an entry to the structure:  
w_parent_window      iw_parent_window_handle


// Populate the w_parent_window with the handlke of the window
// OPEN event of the window
w_parent = this


// When you are opening the popup window, set the pointer to the parent window
istr_parms. iw_parent_window_handle = iw_parent

// Open the popup window and pass the parms
OpenWithParm(w_popup_tolerance, istr_parms, iw_parent)

// In the popup window:
// Instance variable
w_parent_window     iw_parent

// In the OPEN event of the popup
iw_parent = istr_parms. iw_parent_window_handle             // or "astr_parms" if you name the parameter this way.  :)

// You call a user function that is designed to handle the msgs from the popup
iw_parent.of_process_popup_msgs (string as_msg, long al_msg, long al_return_code)     // Or however you code the function


Comment
  1. Tracy Lamb
  2. Monday, 20 February 2023 21:14 PM UTC
If I add an entry to the istr_parms structure, just give it a type 'long'? Or 'longptr'? Or 'window'?
  1. Helpful
  1. Olan Knight
  2. Monday, 20 February 2023 21:19 PM UTC
Just use the type of the window with which you will communicating. That's where the function to process the messgaes resides.

In my example I declared the parent window to be of type "w_parent_window", and the instance varieable was "iw_parent".

When populating the instance variable in the OPEN event you can set it toe "this"; iw_parent = this
  1. Helpful 1
  1. Chris Pollach @Appeon
  2. Monday, 20 February 2023 23:28 PM UTC
Hi Tracy;

It could be a data type of either 'Window" class or "PowerObject" class in your structure. The OpenWithParm command does not automatically pass any parent window pointer. You have to declare it in your structure because you're passing multiple parameters.

Regards ... Chris
  1. Helpful 1
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Saturday, 18 February 2023 17:02 PM UTC
  2. PowerBuilder
  3. # 2

Hi Tracy;

  Easy, just use the OpenWithParm command & pass the address of the Window you want it to interact with in the parameter arguments.

Regards ... Chris 

Comment
  1. John Fauss
  2. Sunday, 19 February 2023 02:37 AM UTC
Hi, Tracy - The instance variable iw_parent already contains a reference to the parent window. Can you add a member to the str_parms structure to hold a window reference. If so, then assign iw_parent to that new member of the structure. When the popup window examines the structure contents, the reference to the parent window will be there.

It isn't clear from your issue description if the popup window is going to communicate with only this one parent window, or with others. If only the one window object class, then the structure member can be safely defined as that object class. For example, if the parent window's object classname is "w_data_entry", then you can add a structure member such as "w_data_entry w_parent" (a member of type w_data_entry named w_parent).

If multiple windows are going to be opening this popup window, define the structure member using a generic window reference: "window w_parent". In the popup window, it can check the actual window object class name via the ClassName() function: If w_parent.ClassName() = 'w_data_entry" Then ... End If

The popup window can have a local or instance variable for each parent window class, and when the "generic" window reference gets assigned to the specific window reference variable, the popup window can then reference objects, events, and public functions in the particular parent window.
  1. Helpful 2
  1. Tracy Lamb
  2. Monday, 20 February 2023 21:25 PM UTC
I'm still a bit confused on two points:

1. shouldn't OpenWithParm(w_popup_tolerance, istr_parms, iw_parent) be passing the handle/reference to the parent window? Why would I need to add another handle/reference in the parameter structure I'm passing? Can I just somehow use the value passed to reference the parent, or is that value always interpreted as a "generic" window type unless I define it differently?

2. the pop-up window be communicating only with the parent window that opened it. Once I successfully get the reference to the parent window, can I call events/functions on object in the parent window? For instance, iw_parent.tab_1.tabpage_2.dw_2.ScrollToRow(3) ?



  1. Helpful
  1. John Fauss
  2. Tuesday, 21 February 2023 00:01 AM UTC
I'll answer (2) first: Yes (mostly). If you have a valid reference to the parent window, you can (a) trigger and/or post events (because all events have public access). You can (b) call object functions in the window, as long as they are defined with public access. You can (c) reference controls within the parent window, trigger/post events in those controls, and/or (d) invoke public functions in the controls, such as ScrollToRow in a DW in a tabpage in a tab control in the window. I do NOT recommend it, but you can (e) access and even change instance variables defined in the parent window if the instance variables are defined with the access rights that will permit it.



Now for (1): The optional third argument in the OpenWithParm PowerScript function (the reference to the parent window, iw_parent) does NOT get supplied to the window that is to be opened via the global Message object. Only the second argument is made available. The Windows O/S requires that popup windows and child windows have their "parent" window identified in order for the popup/child window to be opened, so PB uses the iw_parent argument (it actually supplies the parent window's handle) in the underlying WIndows API call that actually creates/instantiates the popup/child window. If you use OpenWithParm to open a popup/child window and omit the third argument, PB will use the currently active window as the "parent". Look at the PB Help topic for OpenWithParm for additional information.
  1. Helpful 2
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.