[.NET] SendMessage 訊息進不去另一個class的 …
請輸入專案類型(網站專案或者應用程式專案):應用程式專案
在一個專案中,一個Class傳送訊系如下,想要讓Form Class做一些動作
並變更畫面欄位值,不過發生訊息常常進不去的狀況
還請各位先進指點
=========function class===========
<DllImport("user32.dll", SetLastError:=True, EntryPoint:="SendMessage")> _
Public Shared Function SendMessage(ByVal hwnd As IntPtr, ByVal wMsg As
Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
End Function
sub send()
Dim vProcess As Process = Process.GetCurrentProcess()
Dim vcpd As New CopyDataStruct
Dim vadd = Marshal.AllocCoTaskMem(Marshal.SizeOf(vcpd))
SendMessage(vProcess.MainWindowHandle, WM_COPYDATA, 2, CInt(vadd))
Marshal.FreeCoTaskMem(vadd)
end sub
============Form Class=============
Protected Overrides Sub WndProc(ByRef msg As Message)
Select Case msg.Msg
Case WM_COPYDATA
dofunction()
End Select
MyBase.WndProc(msg)
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.249.163.125
→
03/08 10:37, , 1F
03/08 10:37, 1F
→
03/10 09:51, , 2F
03/10 09:51, 2F