MDI – Anvil of Time https://anvil-of-time.com Nature Forges Everything on the Anvil of Time Wed, 10 Mar 2021 23:14:31 +0000 en-US hourly 1 PowerBuilder – Calling Methods on Separate Windows https://anvil-of-time.com/powerbuilder/powerbuilder-calling-methods-on-separate-windows/ Sat, 04 Dec 2010 01:20:45 +0000 http://anvil-of-time.com/wordpress/?p=613 If you need to trigger and event or call a function on another window within an application, here are two solutions.

In you have an MDI application you need to get a reference to the sheet. The PFC has a method to get the sheets of a certain class called ‘of_getsheetsbyclass’. You call it and pass in a window array and the classname (window name) you are looking for and it populates the window array and returns the number of sheets of that particular class. This can be put on your frame directly fairly easily. Define a function on the MDI Frame window which takes a window array parameter by reference and a string. The function returns an integer.

// int wf_getsheetsbyclass(ref aw_windowarray[], as_classname)
integer li_counter
window	lw_sheet

// Get all sheets of classname
lw_sheet = this.GetFirstSheet ()
if IsValid (lw_sheet) then
   do
      if ClassName (lw_sheet) = as_classname then
         li_counter++
         aw_windowarray[li_counter] = lw_sheet
      end if
      lw_sheet = this.GetNextSheet (lw_sheet)
   loop until IsNull(lw_sheet) Or not IsValid (lw_sheet)
end if

return li_counter

Create an event on the Frame to call the function. This event gets triggered by the sheet FROM which you wish to call the other sheet. Add parameters as needed.

integer	li_return
window	lw_opensheets[]
// using hard coded value but could just as easily be a string parameter
li_return = this.wf_GetSheetsByClass(lw_opensheets,'w_inv_action_list')

IF li_return > 0 THEN
	// if multiple versions of the same sheet are open, you have may wish to do extra stuff to trigger the event on the correct one.
	// in this instance, trigger it on the first sheet in my lw_opensheets array
   // trigger event on sheet and send it a string parameter
   lw_opensheets[1].event dynamic ue_nextreq(as_parms)
ELSE
   //open the sheet then trigger?
END IF

So in Sheet A you call/trigger the method on Sheet B like this:

 w_frame.event dynamic ue_nextreq(ls_parm)

Where ‘w_frame’ is the name of your frame window.

If you are not using an MDI application the approach is a bit more straightforward. This code is in the CALLING window.

IF not IsValid(w_window_b) THEN   
  open( w_window_b)
  post close( w_window_b) // only if it wasn't open already
end if

w_window_b.event ue_compute()

If you don’t want the flicker of the window opening and closing you could send it a parameter in an Openwithparm call (instead of Open) which you read in the open event of the window and then set the x,y coordinates of the window to -5000 or something.

If the window is as response window, at the moment you execute the ‘open()’ your code will wait to execute until it closes. If you don’t want to change its type, you can also do an OpenSheet(). That will make the called window behave like a sheet, even though the type is response. With this approach you will also need to create a ‘dummy’ MDI frame which you open first then use in the opensheet call. Interestingly the Powerbuilder help explicitly states NOT to open a response window with the opensheet command.

Your code would then look like:

open(w_mdiframe_test) // open the dummy frame
opensheet( w_response_test,w_mdiframe_test)
post close( w_response_test) // only if it wasn't open already
post close(w_mdiframe_test) // close the dummy mdi frame

w_response_test.event ue_callme()
]]>
PowerBuilder: Transparent MDI Frame https://anvil-of-time.com/powerbuilder/powerbuilder-transparent-mdi-frame/ Sat, 07 Aug 2010 01:40:08 +0000 http://anvil-of-time.com/wordpress/?p=254 I’m working on an MDI application which uses an mdi frame (naturally) with a sheet (window type: Main!) which normally covers the entire working area of the frame. This window serves as a large ‘sitemap’ of the over all application. One of the windows of the application displays time sensitive data (could be orders, deliveries, parts in production, whatever) and is also window type Main! but is not opened as a sheet. This means it is not confined to the interior area of the MDI frame.

The end users normally use this ‘monitor’ window to alert them of issues with any of the items on the display. If desired they can open up a detail window on any of the items to see and/or modify information on that specific thing. This detail screen is a Response window.

A problem arises when the end user does the following: Open application, open monitor window, minimize monitor window, minimize application window, maximize monitor window (at this point we have the monitor window displayed with the underlying application window minimized). Open the detail window of an item on the monitor. At this point the application window maximizes itself and the detail window is displayed on top of it (so now the monitor is ‘in the back’ so to speak and hidden). The desired functionality is that the detail window appear on top of the monitor window.

To work around this PowerBuilder ‘feature’ I implemented the following in the event which opens the detail window:

boolean lb_max

// The system must maximize the frame before opening a popup window from a Main window type
if g_pfapp.mdiframe.WindowState = Minimized! then
	lb_max = TRUE
	g_app.mdiframe.transparency = 100 // totally transparent
	g_app.mdiframe.WindowState = Maximized! 
end if
// bring up the details response window on top of the now invisible mdi frame
openwithparm(w_details, this)
IF lb_max THEN
	g_app.mdiframe.WindowState = Minimized!
	g_app.mdiframe.transparency = 0 // opaque again
END IF

The g_app in the example is a PFC based application object.

]]>