 |
|
รบกวนหน่อยครับ ผมต้องการเปิด Microsoft Word ใน Panel ครับ VB หรือ c# ก็ได้ครับ |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Imports System.Runtime.InteropServices
Public Class Form4
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInt32, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
End Function
<DllImport("user32.dll", SetLastError:=True)> _
Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
End Function
Private Const WM_SYSCOMMAND As Integer = &H112
Private Const SC_MINIMIZE As Integer = &HF020
Private Const SC_MAXIMIZE As Integer = &HF030
Private Sub Form4_Load(sender As Object, e As System.EventArgs) Handles Me.Load
'Dim panel As New Panel() With {.BorderStyle = BorderStyle.FixedSingle}
'Me.Controls.Add(panel)
'Arguments = "...",
Dim p As Process = Process.Start(New ProcessStartInfo() With {.FileName = String.Concat(Application.StartupPath, "\ReadMe.docx"), .WindowStyle = ProcessWindowStyle.Minimized})
System.Threading.Thread.Sleep(500)
Dim value As IntPtr = SetParent(p.MainWindowHandle, ExcelPanel.Handle)
SendMessage(p.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
End Sub
End Class
|
 |
 |
 |
 |
Date :
2018-10-29 11:07:18 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (C#)
Imports System.Runtime.InteropServices
Public Class Form4
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInt32, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
End Function
<DllImport("user32.dll", SetLastError:=True)> _
Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
End Function
Private Const WM_SYSCOMMAND As Integer = &H112
Private Const SC_MINIMIZE As Integer = &HF020
Private Const SC_MAXIMIZE As Integer = &HF030
Private Sub Form4_Load(sender As Object, e As System.EventArgs) Handles Me.Load
'Dim panel As New Panel() With {.BorderStyle = BorderStyle.FixedSingle}
'Me.Controls.Add(panel)
'Arguments = "...",
Dim p As Process = Process.Start(New ProcessStartInfo() With {.FileName = String.Concat(Application.StartupPath, "\ReadMe.docx"), .WindowStyle = ProcessWindowStyle.Minimized})
System.Threading.Thread.Sleep(500)
Dim value As IntPtr = SetParent(p.MainWindowHandle, ExcelPanel.Handle)
SendMessage(p.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
End Sub
End Class
|
 |
 |
 |
 |
Date :
2018-10-29 11:07:54 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เปิดได้Excel ครับ พี่ word เปิดไม่ได้
|
 |
 |
 |
 |
Date :
2018-10-29 13:11:14 |
By :
2127832830566218 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันติด Error หรือ Permission อะไรหรือเปล่าครับ
|
 |
 |
 |
 |
Date :
2018-10-29 13:47:55 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าใช้ process ไม่ติด Error ครับ
word ถูกเปิดขึ้นแต่ไม่เข้าไปใน panelครับ
ส่วนโค้ดที่ผม ใช้ แล้ว ติด Error
Code (VB.NET)
Dim oWord As New Word.Application
Dim oDoc As Word.Document
oWord = CreateObject("Word.Application")
oWord.WindowState = Word.WdWindowState.wdWindowStateNormal
oWord.Visible = True
oWord.DisplayAlerts = False
oDoc = oWord.Documents.Open("C:\Users\Sixsigma\Desktop\notepad\Set terminal auto run.docx")
SetParent(oWord.Hwnd, pnList1.Handle)
SendMessage(oWord.Hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
Error ตรง
SetParent(oWord.Hwnd, pnList1.Handle) ครับ
|
 |
 |
 |
 |
Date :
2018-10-30 14:36:57 |
By :
2127832830566218 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|