How do you send a windows message?

B

bern11

How do you send a windows message in the .net framework? Creating
messages is easy, so is intercepting messages, but I cannot find a .net
equivalent to the windows api sendmessage() function.
 
G

Greg Young

[DllImport("user32.dll")]
public static extern int SendMessage(
int hWnd, // handle to destination window
uint Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
 
G

Guest

Check out pinvoke.net; they have several different versions and some good
info on the sendmessage function.
 
B

bern11

Well, yeah. I meant how do you do it within the .Net framework? What
is the point of having a Message class if you can't Send them?

I'm going to try one last gimmick I thought of, then I'm off to
#include <Windows.h> world....

Greg said:
[DllImport("user32.dll")]
public static extern int SendMessage(
int hWnd, // handle to destination window
uint Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung

How do you send a windows message in the .net framework? Creating
messages is easy, so is intercepting messages, but I cannot find a .net
equivalent to the windows api sendmessage() function.
 
B

bern11

I isolated the code that opened a second form out of the header and
into the .cpp file. That way the main form header didn't have to
include the 2nd form header, so I could then include the main form
header in the 2nd form header and declare a pointer as a member, which I
then set the 'this' pointer to, and then accessed the main form callback
through the pointer.

It's not 1/2 a confusing as it sounds:

in MainForm.cpp:
#include NewForm.h

NewForm^ form2 = gcnew NewForm;
form2->mainFormPtr = this;
form2->ShowDialog();

in NewForm.h
#include MainForm.h;
...
Proj::MainForm^ mainFormPtr;


mainFormPtr->ExecMemberFunction();


It was HeaderA including HeaderB which included HeaderA causing the
problem....
Well, yeah. I meant how do you do it within the .Net framework?
What is the point of having a Message class if you can't Send them?

I'm going to try one last gimmick I thought of, then I'm off to
#include <Windows.h> world....

Greg said:
[DllImport("user32.dll")]
public static extern int SendMessage(
int hWnd, // handle to destination window
uint Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung

How do you send a windows message in the .net framework? Creating
messages is easy, so is intercepting messages, but I cannot find a
.net equivalent to the windows api sendmessage() function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top