|
0. very very badly written statement/question.
1. Try the database[^] forum; tell them I sent you.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hi forum............
Can anyone give my any sample for message handling. I am working on a program which should receive a message sent by any other program. These messages will be the keyboard keys (WM_KEYS). So please give me any example; how to handle a message sent by other application using SendMessage API.
Thanks in advance......
Vishal Moharikar.
|
|
|
|
|
Instead of using message passing using SendMessageAPI, i would recommend you to use FileWatcher. Let one application write in it and the other application read from it.
This is a better way of doing it.
Ahsan Ullah
Senior Software Engineer
MCTS 2.0
|
|
|
|
|
Hi Ahsan.......
Thanks for your quick solution.....but I can not use this solution. Actually the second application is pre-build and I can not modify it. Also the second application is written some other language which actually hooks the keyboard events and change its character to any desired language (other than English) character. Besides this task (character interchange) it sends the actual keyboard character to the calling application for its use.
This message passing is done via SendMessage API and I have no idea how to handle the messages. So please help; how can I receive the messages and use them.
Thanks once again....
Vishal Moharikar.
|
|
|
|
|
Why? Message passing is easily more efficient than writing a file, sending a message to all processes which are hooked to the file system, propagating that message and reading the file. And it requires more permissions than simply calling SendMessage, which isn't quite so good if running from an intranet
|
|
|
|
|
To receive a message, you simply override the WndProc method of a Form. I'm not certain that you can receive every message sent (unless they're broadcasted to every Form). However, if you are simply receiving the keyboard keys, then you could simply hook the keyboard. Look at this article for more details
|
|
|
|
|
Sounds like a very strange approach. You're sending fake keystrokes for inter-process communication? Good luck my friend.
If its the SendMessage I'm thinking of you'll need an hWnd to send to. How is the sending application determining this? FindWindow perhaps?
In the receiver, you'll need to derive a window or a control or something and override the WndProc to capture the incoming messages. This is as dodgy as it gets, and I wouldn't even be certain it would work in modern versions of Windows.
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: I wouldn't even be certain it would work in modern versions of Windows.
By which I mean inter-process. A protected operating system has some responsiblity to stop one process interfering with another, so wouldn't be surprised if it blocked keystrokes sent from other processes when they should really only come from keyboards. Only a guess though so I might well be wrong.
Regards,
Rob Philpott.
|
|
|
|
|
Hi Rob...
Thanks for your comments....
I am using one application which hooks all the keyboard events and change the character according to its predefined rules. This helps to perform language typing other than English.
I want to know how to handle any message sent by SendMessage API. Please help.
Thanks...
Vishal.
|
|
|
|
|
vishal moharikar wrote: I am using one application which hooks all the keyboard events and change the character according to its predefined rules. This helps to perform language typing other than English.
What does this have to do with SendMessage() ?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I'm really not sure I can offer much help as I don't fully understand what you're trying to do.
SendMessage sends a message (of WM_ form) to a WndProc (every Window has one) with an LPARAM and a WPARAM, and its been this way since the dawn of time.
As I suggested before, derive something from Control and place it on a form. Provide an override to the WndProc and check the Message parameter for whatever message it is you want. (Something like WM_KEYDOWN, WM_KEYPRESS etc.)
You'll then need to configure the sending application to send the messages to that window.
As I said before I'm doubtful whether one process can send messages to the WndProc of another process.
Spy++ is a useful tool for finding the names and classes of windows and watching what messages are being sent.
Regards,
Rob Philpott.
|
|
|
|
|
If I understand you correctly then if you add the following code to the program.cs then you will be able intercept messages being passed to your app. Hope this helps.
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
MessageFilter messageFilter = new MessageFilter();
Application.AddMessageFilter(messageFilter);
}
internal class MessageFilter : IMessageFilter
{
bool IMessageFilter.PreFilterMessage(ref Message m)
{
switch (m.Msg)
{
case 0x100: //MSG.WM_KEYDOWN
if ((int)m.WParam == (int)Keys.F1)
{
}
}
}
}
Mark
|
|
|
|
|
Hi,
How to fill a combobox with avalue from 20-100
Thankyou
YPKI
|
|
|
|
|
for(int i = 20; i <= 100; i++)
{
comboBox.Items.Add(i.ToString());
}
|
|
|
|
|
for(int i=20;i<=100;i++)
{
cmbName.Items.Add(i.ToString());
}
Hope this help..
|
|
|
|
|
I guess what you need is to Set minValue = 20 and maxValue = 100
Ahsan Ullah
Senior Software Engineer
MCTS 2.0
|
|
|
|
|
how about property of it "Datasource" and "Display Memeber" ? what it use for ? how to use ?
|
|
|
|
|
Hi,
we can set a datatable to datasource.if u want to fill those numbers to combobox we need to loop & then fill datatable & then assign it to combobox.datasource property. Better to use "combobox1.items.add " & a loop .
Display member property is used when we have more no.of columns in a query
for ex: -
<b> SqlCommand cmm = new SqlCommand();
cmm.CommandText = "select Emp_Id,Emp_Name,Emp_Address from Employee";
cmm.CommandType = CommandType.Text;
cn.open();
cmm.Connection = cn;
DataTable dt = new DataTable();
SqlDataAdapter sqldt = new SqlDataAdapter(cmm);
sqldt.Fill(dt);
comboBox1.DataSource = dt;
comboBox1.DisplayMember = "Emp_Name";
comboBox1.ValueMember = "Emp_Id";
cn.close();</b>
While Displaying it Displays employees Name & if u are going to save it in table then we can use
"comboBox1.selectedvalue" property were we get the Emp_Id
|
|
|
|
|
Hi,
i don't think u can have min value & max value for a combo box
Satish Pai B
|
|
|
|
|
i don understand what u mean "min value & max value" ? however i think that in my combo box just store some string values n id. and i want to ask u a bit more... does combo box can store more then 2 colume or fields. for eg: Emp_ID, Emp_Name, Emp_Gender,Emp_Phone.. ?
|
|
|
|
|
No Combo Box can store only 2 columns by 2 Properties
1.DisplayMember - This does the work a displaying a column
2.ValueMember - This does a work what value should be returned when a particular item is choose d.
Ex:-
EmpID EMP_Name
1 abc
2 def
3 xyz
when u select a Emp_name - "def" from combo box & if u use "combobox1.selectedvalue" then it returns 2 or if u select "xyz " then it returns 3
doesn't mind if u still didn't get it.Just reply for doubts.
|
|
|
|
|
does combo box control can show 2 column in its dropdownlist ?
|
|
|
|
|
|
Hi All
I am very new to C#,and i have to set background color of my form, i am trying to do like
Assembly myAssembly = Assembly.GetExecutingAssembly();
Stream testImage= myAssembly.GetManifestResourceStream("Test.jpg");
but here it crashing.
can anybody help me out
thanks in advance
RYK
|
|
|
|
|
Form has BackGroundColor and BackGroundImage property. Use it.
जय हिंद
|
|
|
|