Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Delphi [игнор отключен] [закрыт для гостей] / Параметры SendMessage / 15 сообщений из 15, страница 1 из 1
19.11.2003, 15:39
    #32328947
Cauchy
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
Собственно в хелпе написано :
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
LRESULT SendMessage(

    HWND hWnd,	// handle of destination window
    UINT Msg,	// message to send
    WPARAM wParam,	// first message parameter
    LPARAM lParam 	// second message parameter
   );	
 

Parameters

hWnd

Identifies the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows. 

Msg

Specifies the message to be sent. 

wParam

Specifies additional message-specific information. 

lParam

Specifies additional message-specific information. 

 

Return Values

The return value specifies the result of the message processing and depends on the message sent. 

А вот где узнать какие значения Msg, wParam и lParam для чего используются не пойму.
В частности мне нужно послать сообщение окну, что нажата такая-то клавиша.
...
Рейтинг: 0 / 0
19.11.2003, 15:45
    #32328968
Berg
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
В частности:

WM_KEYDOWN
The WM_KEYDOWN message is posted to the window with the keyboard focus when a nonsystem key is pressed. A nonsystem key is a key that is pressed when the ALT key is not pressed.

A window receives this message through its WindowProc function.

LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_KEYDOWN
WPARAM wParam, // virtual-key code
LPARAM lParam // key data
);
Parameters
wParam
Specifies the virtual-key code of the nonsystem key.
lParam
Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. Value Description
0–15 Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.
16–23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM).
24 Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
25–28 Reserved; do not use.
29 Specifies the context code. The value is always 0 for a WM_KEYDOWN message.
30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up.
31 Specifies the transition state. The value is always zero for a WM_KEYDOWN message.


Return Values
An application should return zero if it processes this message.

Remarks
If the F10 key is pressed, the DefWindowProc function sets an internal flag. When DefWindowProc receives the WM_KEYUP message, the function checks whether the internal flag is set and, if so, sends a WM_SYSCOMMAND message to the top-level window. The wParam parameter of the message is set to SC_KEYMENU.

Because of the autorepeat feature, more than one WM_KEYDOWN message may be posted before a WM_KEYUP message is posted. The previous key state (bit 30) can be used to determine whether the WM_KEYDOWN message indicates the first down transition or a repeated down transition.

For enhanced 101- and 102-key keyboards, extended keys are the right ALT and CTRL keys on the main section of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and arrow keys in the clusters to the left of the numeric keypad; and the divide (/) and ENTER keys in the numeric keypad. Other keyboards may support the extended-key bit in the lParam parameter.

Windows 2000 or later: Applications must pass wParam to TranslateMessage without altering it at all.
...
Рейтинг: 0 / 0
19.11.2003, 15:45
    #32328970
ZrenBy
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
WM_KEYDOWN

nVirtKey = (int) wParam; // virtual-key code
lKeyData = lParam; // key data

Открой Win32.hlp и набери в Index WM_
...
Рейтинг: 0 / 0
19.11.2003, 16:15
    #32329040
Cauchy
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
А примерчик например для клавиши "К"?
...
Рейтинг: 0 / 0
19.11.2003, 16:22
    #32329051
Cauchy
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
Написал для Enter:
SendMessage(handle,WM_KEYDOWN,VK_RETURN,0);
SendMessage(handle,WM_KEYUP,VK_RETURN,1);
Правильно ли?
...
Рейтинг: 0 / 0
19.11.2003, 16:43
    #32329098
Cauchy
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
Вроде SendMessage работает.

Появился еще вопросик:
автор писал:
var h:HWND;
....
ShellExecute(h,'open',PChar('Project1.exe'),nil,nil,SW_SHOW);
SendMessage(h,WM_KEYDOWN,VK_RETURN,0);
SendMessage(h,WM_KEYUP,VK_RETURN,1);
Так правильно делать (что-то не работает)?
По-моему я с handle что-то неправильно делаю.
...
Рейтинг: 0 / 0
20.11.2003, 11:10
    #32329787
Cauchy
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
Sorry за невнятные вопросы.

Начнем все с начала. У меня есть прога, назовем ее Prog1, которую я запускаю из своей проги. После запуска Prog1 мне нужно в нее передать сообщение, что нажата клавиша Enter.
Пробовал передавать сообщения в приложении от одного окна к другому (этого же приложения) - все работает. Пробовал запускать Prog1 и передавать ему сообщение о нажатии Enter - не пашет:
Код: plaintext
1.
2.
3.
4.
var h:HWND; 
.... 
ShellExecute(h,'open',PChar('Project1.exe'),nil,nil,SW_SHOW); 
SendMessage(h,WM_KEYDOWN,VK_RETURN, 0 ); 
SendMessage(h,WM_KEYUP,VK_RETURN, 1 );

Что я неправильно делаю?
...
Рейтинг: 0 / 0
20.11.2003, 11:20
    #32329795
ZrenBy
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
>>SendMessage(h,

Так ты посылаешь сообщение не какому-либо окну Project1.exe
а некоемому parent window

Если у тебя есть в Project1.exe скажем форма TMyMainForm-GUID
то используй

hWindow := FindWindow('TMyMainForm-GUID',nil)

и если hWindow > 0 то и

SendMessage(hWindow,
...
Рейтинг: 0 / 0
20.11.2003, 11:25
    #32329805
Cauchy
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
Ааа... Оказывается у приложения и у окна разные handle!
Как же тогда узнать handle окна?
...
Рейтинг: 0 / 0
20.11.2003, 11:36
    #32329822
Berg
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
Ты вообще ответы читаешь?
Тебе же написали:
hWindow := FindWindow('TMyMainForm-GUID',nil)
Вот именно так и получай
...
Рейтинг: 0 / 0
20.11.2003, 11:45
    #32329847
Cauchy
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
автор писал:Ты вообще ответы читаешь?
Читаю. Просто я набрал ответ, потом меня отвлекли на пару минут, а потом я нажал кнопку опубликовать. Да и иннет у меня тормозной (потому что халявный).

А что делать, если я не знаю "имя" окна?
...
Рейтинг: 0 / 0
20.11.2003, 11:52
    #32329861
JibSkeart
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
перебором ищи

а вообще как это не знать название окна ?


_____________
__
...
Рейтинг: 0 / 0
20.11.2003, 14:33
    #32330170
Cauchy
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
А как передать сообщение консольному приложению?
...
Рейтинг: 0 / 0
20.11.2003, 14:37
    #32330184
JibSkeart
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
С консольными помойму все позаковырестее будет
но гдето в инете я это видел , всмусле на этот вопрос
ну если я вообще ничего не путаю :)
_____________
__
...
Рейтинг: 0 / 0
20.11.2003, 14:56
    #32330227
Cauchy
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Параметры SendMessage
Вот тут нашел : http://www.sources.ru/delphi/system/delphi_pipes.shtml
Буду разбираться...
...
Рейтинг: 0 / 0
Форумы / Delphi [игнор отключен] [закрыт для гостей] / Параметры SendMessage / 15 сообщений из 15, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]