[.NET] SendMessage 訊息進不去另一個class的 …

看板Visual_Basic作者 ( )時間15年前 (2011/03/07 16:05), 編輯推噓0(002)
留言2則, 1人參與, 最新討論串1/1
請輸入專案類型(網站專案或者應用程式專案):應用程式專案 在一個專案中,一個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
http://0rz.tw/rxYTA 繼續研究中
03/08 10:37, 1F

03/10 09:51, , 2F
找不出原因 放棄 改用Delegate來做
03/10 09:51, 2F
文章代碼(AID): #1DT97WuT (Visual_Basic)