Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IsValid() not working

Status
Not open for further replies.

Statey603

Programmer
Nov 10, 2009
196
US
I am trying to trigger an event on an open window when another window is being closed. I am trying to use the IsValid() function but it returns False indicating the window is not open - even though it is open and I have confirmed via Objects in Memory.

boolean lb_window_open
// see if window1 is open
lb_window_open = IsValid(w_window1)
IF (lb_window_open = TRUE) THEN
// trigger window 1 retrieve to refresh data
w_window1.PostEvent("ue_retrieve")
ENDIF

NOTE: The window is opened via the following code:
window lw_frame
w_window1 lw_sheet
lw_frame = of_getmdiframe()
OpenSheet(lw_sheet,lw_frame,0,Layered!)

QUESTION:
Does anyone have any ideas why my window is not being detected as open? I have also trued checking the Handle but that returns null.


I appreciate any info/suggestions.
- Bill

--------------------------
PowerBuilder 11.0
 
In 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.
Code:
// of_getsheetsbyclass(aw_windowarray[], as_classname)
window	lw_sheet

// Validate window requestor - remove if not using PFC
if IsNull(iw_requestor) Or not IsValid (iw_requestor) then
	return -1
end if

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

return li_counter

In this example the iw_requestor is the frame window. Remove this reference if the method is directly on the Frame.

Call the of_getsheetsbyclass from the Frame like this:
Code:
integer	li_return
window	lw_opensheets[]
// the PFC handles this via the inv_sheetmanager
li_return = this.inv_sheetmanager.of_GetSheetsByClass(lw_opensheets,'w_inv_action_list')

IF li_return > 0 THEN
   // trigger event on sheet and send it a string parameter
   lw_opensheets[1].event dynamic ue_nextreq(as_parms)
END IF

So in my examples you would trigger an event on the frame from window(sheet) A (passing a parameter if needed). Which would look through the open sheets in the MDI frame and, if it is found, triggers the desired event(forwarding on the parameter if needed). You can modify the above so you don't have to bother with the inv_sheetmanager and just have the frame do the work.

Matt

"Nature forges everything on the anvil of time"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top