Does anybody know how to send messages and receive messages in C# ?
Thanks a lot !
--
Wason
--
Justin Rogers
jus...@mlstoday.com
digi...@hotmail.com
"Wilson Wei" <P...@DZXX.COM> wrote in message
news:#11FgLYRBHA.1460@tkmsftngp04...
Thanks for the speedy reply. My problem is, how to use the
SendMessage(..) API function in C# Winform.
--
Wilson
"Justin Rogers" <jus...@mlstoday.com> wrote in message
news:#gL6otYRBHA.1508@tkmsftngp04...
Simple as pie really, but I'm sure there are some Gotchas. Mainly because I
think PreProcessMessage traps a lot of normal messages and hands them to
other functions or calls events, but I'm not sure of the list of said
messages.
--
Justin Rogers
jus...@mlstoday.com
digi...@hotmail.com
"Wilson Wei" <P...@DZXX.COM> wrote in message
news:OffIa2YRBHA.320@tkmsftngp03...
--
Wilson
"Justin Rogers" <jus...@mlstoday.com> wrote in message
news:Ov2ld8YRBHA.1972@tkmsftngp04...
http://www.cshrp.net/content.aspx?showID=497
I don't know how to recieve messages though.
--
Magnus Lindberg
cshrp.net - Elegant code by witty programmers
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Congratulations!! I've solved the problem !
Thanks for Rogers and Lindberg ,thank you very much !
Attach my codes below:
------------------------------------
/////////////////////////////////////////
///file name: Note.cs
///
public class Note
{
[DllImport("User32.dll",EntryPoint="SendMessage")]
private static extern int SendMessage(
int hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);
[DllImport("User32.dll",EntryPoint="FindWindow")]
private static extern int FindWindow(string lpClassName,string
lpWindowName);
//For Messaging
public const int USER = 0x500;
public const int TEST = USER + 1;
private void SendMsgToMainForm(int MSG)
{
int WINDOW_HANDLER = FindWindow(null,@"Kingsoft Notes - List");
if(WINDOW_HANDLER == 0)
{
throw new Exception("Could not find Main window!");
}
SendMessage(WINDOW_HANDLER,MSG,100,200);
}
}
/////////////////////////////////////////
/// File name : Form1.cs
///
public class Form1 : System.Windows.Forms.Form
{
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent
call
//
}
/// Override the DefWndProc of Form1
protected override void DefWndProc(ref System.Windows.Forms.Message m)
{
switch(m.Msg)
{
case Note.USER:
string message = string.Format ("Received message!
parameters are :{0},{1}",m.WParam ,m.LParam);
MessageBox.Show (message);
break;
default:
base.DefWndProc(ref m);
break;
}
//Console.WriteLine(m.LParam);
}
--
Wilson Wei