On Tue, May 20, 2014 at 9:08 AM, Staffan Tylen <staffan.tylen@gmail.com> wrote:

Now the problem is the reverse in a way. I have dialog A that does a popupAsChild of a PropertSheet dialog.

Hi Staffan,

What I want is that this dialog should position itself where it was when it was closed last time. So in the initDialog of class B, which is a subclass of PropertySheetDialog I do:

self~getLastPosition
forward class(super) continue
self~moveWindow("top", x, y, "showwindow")

But I've found that 'forward' doesn't cause the window to show up, this doesn't happen until initDialog returns to the system. But moveWindow still gives return code .true. When the window shows up it is in it's 'normal', semi-random position.

So my question is, where should moveWindow be called from if initDialog is not the place?

I think your basic problem in working with PropertySheetDialog dialogs is not realizing that "Unlike most other ooDialog dialogs, the operating system manages much of the property sheet dialog itself." 

So, when I first read your message I thought, well when the dialog is shown, it has displayed the first page.  That would be where to position the dialog.  If you look at the page notifications, you see that before a page is shown, it is sent a setActive notification.

That seems like a good place to position the dialog, when the very first setActive notification is sent.  And it does work well:

::method setActive unguarded
    expose wasPositioned
    use arg propSheet

    if \ wasPositioned then do
        p = .Point~new(0, 0)
        propSheet~moveTo(p, "SHOWWINDOW")
        wasPositioned = .true
    end
    return 0

The thing is, the notification is sent every time the page is switched to.  You only want to position the dialog the very first time the page is shown.  Note that I am saying *page*, not *propertysheet*.

The above code is from the PropertySheetDemo.rex example.  In that example, the ListView *page* is shown first, and the setActive() method is a method of the ListView page dialog, not the PropertySheetDemoDlg class.

As another point of reference, in this code:

self~getLastPosition
forward class(super) continue
self~moveWindow("top", x, y, "showwindow")

The initDialog() method of all the ooDialog dialog classes, does absolutely nothing.  Forwarding the initDialog method to its super class is not needed in any way, and does absolutely nothing.  

The sole purpose of the method is to be over-ridden by your subclasses.  It allows the ooDialog framework to invoke the method, of your subclass, at the proper point in time for you to do any initialization that needs to be done before the dialog is shown.

Now, as the last point of reference, I misread your message the first time I read it and thought you had already tried positioning the PropertySheetDialog in the initDialog() method of the property *sheet* dialog.  And said it didn't work.

But, that was not correct, you were doing it in the initDialog() method of the PropertySheetDialog.  Which is not likely to work, because the operating system is managing that dialog.

The best place to do this is in the initDialog() method of the page dialog that is first shown.  So, don't use the setActive notification, put the code in the initDialog() method of the first *page* dialog that is shown.  From the PropertySheetDemo example, the very end of the initDialog() method:

    -- Connect 2 list-view events to Rexx methods in this dialog.  The double-
    -- click on a list-view item, and the click on a column header events.
    self~connectListViewEvent(IDC_LV_MAIN, "ACTIVATE", "onActivate")
    self~connectListViewEvent(IDC_LV_MAIN, "COLUMNCLICK")

    p = .Point~new(0, 0)
    self~propSheet~moveTo(p, "SHOWWINDOW")

That works excellent, and you don't need to worry about doing it more than once.

The only thing is, you don't have to open the first physical page as the first page displayed,  That is just the default.  If you change that, you will need to place the code in the initDialog() method of each page in the dialog.  And then you still need to ensure that it is only done the very first time.

Hope that gives you some better understanding of the PropertySheetDialog.

--
Mark Miesfeld