using WebBrowser Control to display a PPT file.
With Office 2007 this is successful, but with Office 2010, the page down key (VK_PRIOR
) does not work.
This code for click previous does not work with Office 2010, but works with Office 2007:
Private Sub btnPREV_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPREV.Click
If docType = DocumentType.PPT Then
If hndl = IntPtr.Zero Then
GetHandles()
End If
NativeMethods.PostMessage(hndl, WM_KEYDOWN, VK_PRIOR, IntPtr.Zero)
NativeMethods.PostMessage(hndl, WM_KEYUP, VK_PRIOR, IntPtr.Zero)
End If
End Sub
This code for click next works with both Office 2007 and 2010:
Private Sub BtnNEXT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNEXT.Click
If docType = DocumentType.PPT Then
If hndl =开发者_高级运维 IntPtr.Zero Then
GetHandles()
End If
NativeMethods.PostMessage(hndl, WM_KEYDOWN, VK_NEXT, IntPtr.Zero)
NativeMethods.PostMessage(hndl, WM_KEYUP, VK_NEXT, IntPtr.Zero)
End If
End Sub
The solution is found:
WebBrowser1 is the object of the WebBrowser Class.
WebBrowser1.Focus()
btnBACK.Focus()
WebBrowser1.Focus()
SendKeys.Send("{UP}")
That's it. The "previous" click starts working, since the Page Up event is fired.
精彩评论