Info(“windowname”) not always current

In order to have a printusingform work properly, I need to get the Datasheet out of the way if it’s the active window. The procedure below sends it to the back if it is and that works.

Of course, it could be the only open window, so I tried checking to see if it was still the active window. (there’s also a chance thatf another database might have the next open window)

What I found though, is that the Datasheet is still the result of info(“windowname”) if it was active when the procedure started. And after sending it to the back, the second check makes it active again.

If info(“windowname”) = dbname()
    WindowToBack info(“windowname”)
EndIf
Message info(“windowname”)

You have not chosen a category, but I suppose we are talking about Panorama X.

The documentation says:

Note: The printusingform statement may only be used when a form window is currently on top.

Then it allows to print a different form without the need to open that form first.

I corrected the category omission. Thanks

But you’re right about the form window needing to be on top. That’s the reason I’m trying to make sure that it’s not the Datasheet on top. The end user keeps having issues because it is and I’m trying to have Panorama help him avoid it.

So the easy way is to use the openform statement to open a form window or to bring it to the front.

I would suggest that you use the info(“windowview”) function to directly check for the type of window, instead of the indirect method you are using, for two reasons:

  • It’s possible to rename a form window to the name of the database, so your indirect method of checking the form name might not work.
  • The info(“windowname”) function has extra logic to handle magic windows, which I think might be what is tripping you up. The info(“windowview”) function doesn’t know anything about magic windows, it always deals with the actual visible window.

Caveat: I didn’t test your unusual application, so I’m not 100% sure it will work.

In Panorama X 10.2 there will be a new way to do this task that I think would be a superior method using window ID numbers.

The example code on this page shows bringing forward a specific form window, but it could easily be modified to bring forward whatever form window is topmost by changing the third line to this:

if windowinfo(windowNumber,"form")<>""

The new window id number system is really great for precisely dealing with windows without relying on window names, which can be changed at any time (and duplicate window names are also possible).