none
Word 2016 PreviewHandler shifts preview left and up RRS feed

  • Question

  • I created a component that uses the IPreviewHandler functionality to display previews of files (like the preview pane in Windows Explorer). Unfortunately the previews of Word files that Word 2016 displays are shifted to the left and shifted up. See image below.

    Preview shifted

    Clicking on the scrollbar makes Word shift the document to the right place:

    Preview in the right place

    I initialize the previewhandler with a stream, set the window and call DoPreview. I observed the same behaviour with other examples of PreviewHandlers (http://www.brad-smith.info/blog/archives/183 and https://theroadtodelphi.wordpress.com/2013/05/24/hosting-preview-handlers-in-delphi-vcl-applications/). This happens on Word 2016 on a Windows 7 machine and Windows 8.1 machine (Windows 8 machine only shifts up). Word 2007 worked on other machines. Does anyone know what causes this behaviour and if there is a fix for it?





    • Edited by The_Fox_ Friday, December 18, 2015 9:52 AM Added images
    Monday, December 7, 2015 8:11 AM

All replies

  • >>>I created a component that uses the IPreviewHandler functionality to display previews of files (like the preview pane in Windows Explorer). Unfortunately the previews of Word files that Word 2016 displays are shifted to the left and shifted up.

    According to your description, could you let us know what kind of application you use the component that uses the IPreviewHandler functionality to display previews of files? and could you provide your sample codes? These will help us reproduce and resolve your issue.

    Thanks for your understanding.

    Tuesday, December 8, 2015 5:51 AM
  • I can make a demo application, but it will be a Delphi application. Not everyone has Delphi available. You can use this C# project to reproduce the problem: http://www.brad-smith.info/blog/wp-content/uploads/2010/09/PreviewHandlers3.zip
    Tuesday, December 8, 2015 8:09 AM
  • >>>I can make a demo application, but it will be a Delphi application. Not everyone has Delphi available. You can use this C# project to reproduce the problem: http://www.brad-smith.info/blog/wp-content/uploads/2010/09/PreviewHandlers3.zip

    According to your description, I have created C# Window Form Project to try to reproduce this issue, unfortunately, I amn't able to reproduce.
    You could refer to below code that create PreviewHandlerHost control then open one word document:

    PreviewHandlerHost host;
    private void FormPreviewHandlerHost_Load(object sender, EventArgs e)
    {
         host = new PreviewHandlerHost();
         host.Open("D:\\OfficeCaseRecord.docx");
              
         host.Dock = DockStyle.Fill;
         this.Controls.Add(host);
    }

    then get this result:

    Wednesday, December 16, 2015 9:26 AM
  • Interesting, I created a bare WinForms project like you did and indeed the problem is gone. I also created a bare Delphi app and the problem is gone also. Still, my other Delphi app and the sample apps given in the links produce the unwanted behaviour.

    It looks like it is caused by loading the preview from a button handler. Add a panel and a button to the top of the WinForms app and set the PreviewHandlerHost to fill the form. Now move the PreviewHandlerHost.Open to the OnClick of the button and you'll get the shifted previews.

    Friday, December 18, 2015 10:03 AM
  • >>>Add a panel and a button to the top of the WinForms app and set the PreviewHandlerHost to fill the form. Now move the PreviewHandlerHost.Open to the OnClick of the button and you'll get the shifted previews.

    According to your description, I have made a sample to try to reproduce your issue, unfortunately, I can't.

    Since this is the forum to discuss questions and feedback for Word for Developers, this issue is related to Delphi, so I suggest that you could post your issue on Delphi forum.

    Thanks for your understanding.

    • Marked as answer by David_JunFeng Wednesday, December 23, 2015 2:21 PM
    • Unmarked as answer by The_Fox_ Wednesday, January 13, 2016 7:45 AM
    Monday, December 21, 2015 6:34 AM
  • Unfortunately I can reproduce the behaviour with a C# app, so it has nothing to do with Delphi. Which version of Windows and Office did you use?
    Monday, December 28, 2015 10:36 AM
  • We are seeing the issue on several machines, Windows7 and using WP6 documents and opening in Word2016.  This appears to be a Word 2016 software issue.
    Friday, October 28, 2016 6:14 PM
  • We are seeing the issue on several machines, Windows7 and using WP6 documents and opening in Word2016.  This appears to be a Word 2016 software issue.

    Hi,

    Maybe you could upvote this uservoice issue to raise awareness?

    Thanks

    Wednesday, November 2, 2016 9:47 AM
  • We are also seeing this issue with Word 2016 both in a C# and a Delphi project.

    When trying to reproduce: We observed that the problem is not appearing if Word is already running when the preview is displayed. Also the biggest chances to fail are for the first document being previewed, subsequent ones work fine most of the time.


    Monday, December 12, 2016 10:47 AM
  • We fixed the issue in Delphi by setting the TPanel.Visible to false before calling DoPreview and setting Visible to true afterwards. Don't know why it works, other PreviewHandlers don't need this.
    Tuesday, April 18, 2017 8:31 AM