No, you shouldn't call init.
I thought you have your own preview form or form class, but you let _REPORTPREVIEW generate a listener with preview form you want to move with _screen. You could have said so in the first place.
I thought you were rather doing legacy REPORT FORM... WINDOW yourwindow.
Still bindevent is applicable, this just has to be done a bit more complicated with yet another helper class to be added.
That new class will have the Synch method.
Ideally, instead of that new helper class, you would modify the base preview form class the _REPORTPREVIEW app creates. That would indeed be possible, but an overhead in comparison with this, as you'd need to change the ReportPreview pjx and compile a new ReportPreview.App. I doubt you want to go in so deep, so take this instead:
Code:
loNewPreview = .NULL.
DO (_REPORTPREVIEW) WITH m.loNewPreview
WITH loNewPreview
.Topform = .T.
.AllowPrintFromPreview = .F.
&& ..........
.AddObject("oScreenEventHandler","ScreenEventHandler")
BINDEVENT(_Screen,"Moved",.oScreenEventHandler,"ScreenSynch")
ENDWITH
loNewListener = NEWOBJECT("ReportListener")
loNewListener.ListenerType = 1
loNewListener.PreviewContainer = loNewPreview
REPORT FORM Test1 PREVIEW OBJECT loNewListener
WITH loNewPreview.oform
.movable = .F.
.minbutton = .T.
.alwaysontop = .T.
ENDWITH
*...
* At the end of your prg:
DEFINE CLASS ScreenEventHandler as container
Procedure ScreenSynch()
This.Parent.oForm.Left = _screen.Left
This.Parent.oForm.Top = _screen.Top
Endproc
ENDDEFINE
Now that I added the DEFINE CLASS to your code, it needs to be a prg, because inside a method or a click event of a button you can't DEFINE a CLASS.
BUT:
You could also put that DEFINE CLASS in a seperate prg and let your code SET PROCEDURE TO C:\yourprojects\yourproject\prgs\that.prg ADDITIVE to be able to use that class from your code.
See if that works at least. It will put the preview window into the left top corner of the screen, once you move the _screen, and you/we/I will need to ammend that with a shift to retain the relative postion the preview has initially, but this will do for a first test drive. Please come back if you've got so far or have another problem.
Bye, Olaf.