| View previous topic :: View next topic |
| Author |
Message |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Sun Nov 11, 2007 2:05 pm Post subject: [Delphi] Translatemessage / Dispatchmessage |
|
|
I tried making a gui application that can tran/disp a message to a window/
i came up with this code, but it doesnt work. Can someone tell me whats wrong?
| Code: |
procedure TForm1.Button1Click(Sender: TObject);
var
MSG : TMSG;
begin
ZeroMemory(@Msg, sizeof(MSG));
Msg.hwnd := FindWindow(PCHAR(Edit1.text),NIL);
Msg.lParam := (MapVirtualKey(Cardinal(edit2.text),0));
Msg.message := WM_KEYDOWN;
Msg.wParam := strtoint(edit3.text);
TranslateMessage(Msg);
DispatchMessage(Msg);
Msg.message := WM_KEYDOWN;
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
|
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Sun Nov 11, 2007 2:10 pm Post subject: |
|
|
check return values
check last error
check for exceptions
_________________
|
|
| Back to top |
|
 |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Sun Nov 11, 2007 6:04 pm Post subject: |
|
|
| there werent any errors, exceptions, but i dont know how to check the return values :X
|
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Sun Nov 11, 2007 6:09 pm Post subject: |
|
|
| slippppppppp wrote: | | there werent any errors, exceptions, but i dont know how to check the return values :X |
oh gawd. Then you obviously don't even know what functions do.
_________________
|
|
| Back to top |
|
 |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Sun Nov 11, 2007 6:10 pm Post subject: |
|
|
someone tell me instead of giving me their opinions on making me look stupid
|
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Sun Nov 11, 2007 6:26 pm Post subject: |
|
|
TranslateMessage:
| Code: | Return Value
If the message is translated (that is, a character message is posted to the thread's message queue), the return value is nonzero.
If the message is WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, or WM_SYSKEYUP, the return value is nonzero, regardless of the translation.
If the message is not translated (that is, a character message is not posted to the thread's message queue), the return value is zero. |
DispatchMessage:
| Code: | Return Value
The return value specifies the value returned by the window procedure. Although its meaning depends on the message being dispatched, the return value generally is ignored. |
_________________
|
|
| Back to top |
|
 |
assaf84 Expert Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 238
|
Posted: Mon Nov 12, 2007 5:23 am Post subject: |
|
|
| Yout lParam is wrong. Check WM_KEYDOWN message at MSDN.
|
|
| Back to top |
|
 |
|