Frohes neues Gronkh und schoen das ihr endlich das UFO hinter euch gelassen habt
Unter Windows darf ein Programm nicht auf den Speicher eines anderen Programms zugreifen. Du musst also erst ein Speicherblock aus dem Ziel-Prozess holen, dort deine Werte reinschreiben und das dann an dein Fenster senden.
Beispiel (Empfaenger) :
Code: Alles auswählen
#MYMESG = #WM_USER + 1000
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure Callback(hWnd, Msg, wParam, lParam)
Protected *point.POINT
If Msg = #MYMESG
*point = lParam
If *point
SetGadgetText(0, Str(*point\x))
SetGadgetText(1, Str(*point\y))
EndIf
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure Main()
If OpenWindow(0, #PB_Ignore, #PB_Ignore, 200, 60, "MyWindow")
SetWindowCallback(@callback(), 0)
TextGadget(#PB_Any, 10, 10, 40, 25, "Point\x : ")
TextGadget(#PB_Any, 10, 35, 40, 25, "Point\y : ")
TextGadget(0, 70, 10, 50, 25, "0")
TextGadget(1, 70, 35, 50, 25, "0")
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
EndProcedure:End Main()
Beispiel (Sender) :
Code: Alles auswählen
#MYMESG = #WM_USER + 1000
#WINDO_TITLE = "MyWindow"
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure Main()
Protected hProcess
Protected hPid
Protected hWnd
Protected WindowTitle.s = Space(1000)
Protected len
Protected mem.i
Protected pt.Point
pt\x = 424
pt\y = 565
hWnd = GetDesktopWindow_()
hWnd = GetWindow_(hWnd, #GW_CHILD)
; Fenster suchen
Repeat
hWnd = GetWindow_(hWnd, #GW_HWNDNEXT)
len = GetWindowText_(hWnd, @WindowTitle, 1000)
If len
If PeekS(@WindowTitle, len) = #WINDO_TITLE
GetWindowThreadProcessId_(hWnd, @hPid)
Break
EndIf
EndIf
Until hWnd = 0
; Nachricht senden
If hPid
hProcess = OpenProcess_(#PROCESS_ALL_ACCESS, #False, hPid)
If hProcess
mem = VirtualAllocEx_(hProcess, 0, SizeOf(Point), #MEM_RESERVE | #MEM_COMMIT, #PAGE_READWRITE)
If mem
WriteProcessMemory_(hProcess, mem, @pt, SizeOf(Point), #Null)
SendMessage_(hWnd, #MYMESG, 0, mem)
VirtualFreeEx_(hProcess, mem, SizeOf(Point), #MEM_RELEASE)
EndIf
CloseHandle_(hProcess)
EndIf
EndIf
EndProcedure:End Main()