473,586 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ned help with marshaling (SendMessage, lparam, WM_MOUSEMOVE)

Hello,

I need some help with the SendMessage method. I've imported it into C# with
the following statement:

[DllImport("user 32.dll", SetLastError=tr ue)]

public static extern IntPtr SendMessage(Int Ptr hWnd, int Msg, long wparam,
int lparam);

and the following for sending the message:

User32.SendMess age(WindowObjec t_Basic_GDI_Han dle, User32.WM_MOUSE MOVE,
User32.MK_LBUTT ON, MakeLParam(X, Y));

and below for constructing the lparam:

private int MakeLParam(int LoWord, int HiWord)
{

//System.Diagnost ics.Debug.Write Line("LoWord: " + LoWord2(((HiWor d << 16) |
(LoWord & 0xffff))));

return (int) ((HiWord << 16) | (LoWord & 0xffff));
}

Unfortunately, whenever I send a WM_MOUSEMOVE message to a window
(Notepad.exe), the lparam parameter doesn't mike it there!

Spy++ reports X and Y coordinates of 0. (Everything else makes it there ok).

Does anyone have ideas what kind or marshaling I need to do, or if I am
sending the correct data?

Thanks,

Ryan
Nov 17 '05 #1
2 8526
wparam should be int not long.

I prefer to use IntPtr though which would allow you to send a long value.

[DllImport("user 32.dll", SetLastError=tr ue)]
public static extern IntPtr SendMessage(Int Ptr hWnd, int Msg, IntPtr wparam,
IntPtr lparam);

SendMessage(thi s.Handle, 0x200, (IntPtr)(long)0 x1, (IntPtr)MakeLPa ram(X,Y));

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Ryan Ross" <ry***@nni.co m> wrote in message
news:0s******** ************@nn i.com...
Hello,

I need some help with the SendMessage method. I've imported it into C#
with the following statement:

[DllImport("user 32.dll", SetLastError=tr ue)]

public static extern IntPtr SendMessage(Int Ptr hWnd, int Msg, long wparam,
int lparam);

and the following for sending the message:

User32.SendMess age(WindowObjec t_Basic_GDI_Han dle, User32.WM_MOUSE MOVE,
User32.MK_LBUTT ON, MakeLParam(X, Y));

and below for constructing the lparam:

private int MakeLParam(int LoWord, int HiWord)
{

//System.Diagnost ics.Debug.Write Line("LoWord: " + LoWord2(((HiWor d << 16)
| (LoWord & 0xffff))));

return (int) ((HiWord << 16) | (LoWord & 0xffff));
}

Unfortunately, whenever I send a WM_MOUSEMOVE message to a window
(Notepad.exe), the lparam parameter doesn't mike it there!

Spy++ reports X and Y coordinates of 0. (Everything else makes it there
ok).

Does anyone have ideas what kind or marshaling I need to do, or if I am
sending the correct data?

Thanks,

Ryan

Nov 17 '05 #2
Ah, that works.

Thank You,
Ryan
"Mick Doherty"
<EX***********@ AND.REMOVE.SQUA REBRACKETS.[mdaudi100#ntlwo rld.com]> wrote in
message news:Oy******** *****@TK2MSFTNG P15.phx.gbl...
wparam should be int not long.

I prefer to use IntPtr though which would allow you to send a long value.

[DllImport("user 32.dll", SetLastError=tr ue)]
public static extern IntPtr SendMessage(Int Ptr hWnd, int Msg, IntPtr
wparam, IntPtr lparam);

SendMessage(thi s.Handle, 0x200, (IntPtr)(long)0 x1,
(IntPtr)MakeLPa ram(X,Y));

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Ryan Ross" <ry***@nni.co m> wrote in message
news:0s******** ************@nn i.com...
Hello,

I need some help with the SendMessage method. I've imported it into C#
with the following statement:

[DllImport("user 32.dll", SetLastError=tr ue)]

public static extern IntPtr SendMessage(Int Ptr hWnd, int Msg, long
wparam, int lparam);

and the following for sending the message:

User32.SendMess age(WindowObjec t_Basic_GDI_Han dle, User32.WM_MOUSE MOVE,
User32.MK_LBUTT ON, MakeLParam(X, Y));

and below for constructing the lparam:

private int MakeLParam(int LoWord, int HiWord)
{

//System.Diagnost ics.Debug.Write Line("LoWord: " + LoWord2(((HiWor d << 16)
| (LoWord & 0xffff))));

return (int) ((HiWord << 16) | (LoWord & 0xffff));
}

Unfortunately, whenever I send a WM_MOUSEMOVE message to a window
(Notepad.exe), the lparam parameter doesn't mike it there!

Spy++ reports X and Y coordinates of 0. (Everything else makes it there
ok).

Does anyone have ideas what kind or marshaling I need to do, or if I am
sending the correct data?

Thanks,

Ryan


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2153
by: Sn | last post by:
Does anyone know how to use the SendMessage() function to save a text file in UTF-8 format. what are the Msg, Wparam and the lParam parameters passed to the function?
3
3635
by: Rudy Velthuis | last post by:
Hello, Does anyone know how to create a struct that will marshal to the following C++ struct A, containing an array of the user defined String10 type: struct String10 { char SLen; char S;
0
1466
by: Jeff | last post by:
Hi guys Mattias, thanx for answering my last question Well, I'm struggling with marshaling a struct that has **ptr to an array of arrays of struct. Why? I'm stuck with it 1. I need to know how to get to the contents of "dumberstruct" contained within "dumbstruct" (i.e. dumbstruct.dstruct) 2. How to get to dumbstruct.tag_field_value and...
7
5948
by: Mo | last post by:
I am having problem with marshaling struct in C#. //the original C++ struct typedef struct _tagHHP_DECODE_MSG { DWORD dwStructSize; // Size of decode structure. TCHAR pchMessage; // decoded message data TCHAR chCodeID; // AIM Id of symbology TCHAR chSymLetter; ...
0
1656
by: Nickneem | last post by:
I' m trying to disable all right mouse clicks by using the vbAccelerator Windows Hooks Library The small (systray / console) app. must catch all (right) mouseclicks before they are received by the users application (for instance IE). I' m not getting passed the stage where I write to the console catching clicks on my applications form.. I...
1
3540
by: alexwhitman | last post by:
Hi, I'm trying to port a c++ class to c# and in the c++ class I have a struct defined as: struct SNARLSTRUCT { SNARL_COMMANDS cmd; long id; long timeout; long lngData2; char title;
3
7153
by: Mark Ingalls | last post by:
Hello Everyone, I'm trying to send a text string to a dialog edit control using SendMessage and WM_SETTEXT and cannot get it working correctly. Here is the declaration of the function: <DllImport("user32.dll", EntryPoint:="SendMessage", SetLastError:=True, CharSet:=CharSet.Auto)_ Private Function SendMessageString(ByVal hWnd As IntPtr,...
1
13392
by: Necromis | last post by:
Ok, I have gotten my head around things better regarding SendMessage and FindWindow functions. However, I am running into an issue with my code still. The program I am working with is EXTRA! by Attachmate. It is a mainframe terminal. Here is the issue and strange part of it. It is accepting sendmessage when I use the WM_KEYDOWN/UP commands....
8
1711
by: Dr1ZZ | last post by:
Hi, I'm currently working on a bot for a game. It works like this: 1: Take a picture of the current playing field 2: Do the calculations on what i gotta do (best move) 3: Use sendmessage to send a mouseclick to the game at the correct position
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.