开发者

Lock the word document and open Modal Dialog above the document

开发者 https://www.devze.com 2023-04-12 19:41 出处:网络
In a Windows Forms application I need to open a word document and hide the main form, and above the word document I need to open a Modal Dialog. When the modal dialog is shown, the word should be disa

In a Windows Forms application I need to open a word document and hide the main form, and above the word document I need to open a Modal Dialog. When the modal dialog is shown, the word should be disabled, meaning that the user can not scroll, or zoom, or write something in the document. The document will be controlled by the modal dialog.

Now I am using a function from user32.dll, with which I set the parent process for the modal dialog, so that when I hide the main form, the modal dialog will remain visible.

[DllImport("user32.dll")]
public static extern IntPtr SetPare开发者_运维百科nt(IntPtr child, IntPtr newParent);

The problem is that if I open the modal dialog with Show() or ShowModal(), I can still have access to the word document, and if I open it with ShowDialog(), the form is kinda integrated in the document and I can't click it or focus it.

Can anyone tell me how can I lock the word document and still be able to have access to the modal dialog?

Is there a Office.Interop.Word function that can help?


I think the best solution would be to write a Word-Addin, but that will be a lot of work, and may not be possible for you at the moment.

I think the second best solution would be to hide Word when you show the modal dialog.


What you describe isn't the way to go... to achieve what you want you need to implement an Office AddIn instead of the WinForms App... for a walkthrough including source code on how to do that see http://msdn.microsoft.com/en-us/library/bb157892.aspx

EDIT - as per comments:

Another option would be to render the Word Document to a PDF and display that... for editing the Word document you could use OpenXML from MS (free) and/or Aspose.Words (commercial) or similar library...


Yes, the document can be locked under the form by using the word vbModal:

Sub AutoOpen()
    frmIntro.Show vbModal
End Sub
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号