1. Peter Thiem
  2. PowerBuilder
  3. Tuesday, 30 November 2021 00:22 AM UTC

Hi

How do I bring a sheet to front in MDI, with focus and drawing, as the selection via the Window menu bar would?

I am updating this application's task launcher so that when a task opens a sheet but it is already open, the sheet is brought to front.

I've tried wSheet.BringToTop = True (where wSheet is the sheet reference), it brings it to the front, but the focus is not automatically given to the sheet, and sometimes (when sheets are not in maximized mode) the sheet is not redrawn and the underlying sheet is shown.

When changing between sheets using the Window menu bar, the sheets focus is restored to where it last was, and the sheets are drawn properly, and that is ideal behavior.

Cheers, Peter.

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 30 November 2021 00:43 AM UTC
  2. PowerBuilder
  3. # 1

Hi Peter;

  Try wsheet.SetFocus()

Regards ... Chris

Comment
  1. Peter Thiem
  2. Tuesday, 30 November 2021 05:03 AM UTC
Thanks again Chris!

Calling wsheet.SetFocus() does work to bring it to front and focus it as needed.

In this applications case, the windows are opened from treeview click events, and for some reason it is interfering with focusing and redrawing. (Which has really confused my debugging of the problem).

So to force a redraw, i have worked around by calling wsheet.SetRedraw(true).

And to workaround the treeview interfering with focus, I have put the calls to setfocus and setredraw into a function and calling it by the "Post Function" mechanism, which seems to allow these to execute after the treeview click event has processed.

I don't know why the treeview is interfering, but at least the workaround appears to work.

Cheers, Peter.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 30 November 2021 16:01 PM UTC
Hi Peter;

Super glad that the SetFocus() command worked for you. Yes, you often need to POST an Event or Function to let the other PowerScript's "in progress" complete before setting focus - so that the normal flow of the App is not disturbed.

Regards ... Chris
  1. Helpful
  1. Olan Knight
  2. Tuesday, 30 November 2021 18:14 PM UTC
Another option is the BringToFront property:

wsheet.BringToFront = TRUE
  1. Helpful
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.