![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Можно ли с помощью Sendmessage
SergeyDon © (2002-05-23 14:47:00)передать не только 2*integer а текст?
или что нибуть аналогичное может есть? надо чтобы компанент получал сообщения.
HighWay (2002-06-25 19:56:00) [1]Пробовал пример - delphi ругается на wm_msgsent.
Если можно, скиньте мне в качестве примера рабочий проект.
Спасибо.
StAL (2002-05-24 17:33:00) [2]ПРИЛОЖЕНИЕ 1
...
type
PStrMsg = ^TStrMsg;
TStrMsg = record
S : PChar;
end;
var
MMFHandle: THandle;
StrMsg: PStrMsg;
...
procedure Form1Create(...);
begin
MMFHandle := CreateFileMapping(...); //см. WinSDK
StrMsg := MapViewOfFile(...);
end;
procedure Form1Close(...);
begin
UnMapViewOfFile(StrMsg);
CloseHandle(MMFHandle);
end;
procedure SendToProc2(str: PChar);
begin
StrMsg^.s := str;
SendMessage (HandleOfProc2, wm_msgsent, 0, 0);
end;
............
ПРИЛОЖЕНИЕ 2
//такое же объеявление типа, создание файла и разрушение
procedure OnMsgSent(var Msg: TMessage);
begin
form2.caption:=strpas(StrMsg^.s);
end;
ОБЯЗАТЕЛЬНОсоздавай файлы в памяти с одинаковым именем!
Alx2 (2002-05-24 14:12:00) [3]>SPeller © (24.05.02 13:19)
Дополню: только внутри своего процесса.
Для чужих процессов - MMF и конструкции на их основе, например, тот же wm_copydata.
SPeller (2002-05-24 13:19:00) [4]Передать можно что угодно, надо только передать указатель на некую структуру, массив и т.п.
Yuri Btr (2002-05-24 09:30:00) [5]SendMessage(hand,WM_CHAR,LongInt(Pchar("a")),1);
Alx2 (2002-05-23 15:28:00) [6]Windows SDK:
The WM_COPYDATA message is sent when an application passes data to another application.
WM_COPYDATA
wParam = (WPARAM) (HWND) hwnd; // handle of sending window
lParam = (LPARAM) (PCOPYDATASTRUCT) pcds; // pointer to structure with data
Parameters
hwnd
Identifies the window passing the data.
pcds
Points to a COPYDATASTRUCT structure that contains the data to be passed.
Return Values
If the receiving application processes this message, it should return TRUE; otherwise, it should return FALSE.
Remarks
An application must use the SendMessage function to send this message, not the PostMessage function.
The data being passed must not contain pointers or other references to objects not accessible to the application receiving the data.
While this message is being sent, the referenced data must not be changed by another thread of the sending process.
The receiving application should consider the data read-only. The pcds parameter is valid only during the processing of the message. The receiving application should not free the memory referenced by pcds. If the receiving application must access the data after SendMessage returns, it must copy the data into a local buffer.
See Also
PostMessage, SendMessage, COPYDATASTRUCT
SergeyDon (2002-05-23 15:24:00) [7]wm_copydata не нахожу в справке можно конкретней
Alx2 (2002-05-23 15:14:00) [8]Если в другой процесс, то wm_copydata спасет отца русской демократии :)
Song (2002-05-23 14:48:00) [9]Передавайте pointer строки