Sending or Posting message to other control

L

Leon Chi

I was a VC++ programer. Now I am learning C#. In VC, you can
use API SendMessage() or PostMessage() to send or post message
to other window. Are there some classes defined in .NET can do these?

Thanks.

Best Regards
Leon
 
A

AlexS

Hi, Leon

In .Net it is expected that you use available methods and properties for
such tasks. So, the question is what you are trying to do?
For example, instead of SendMessage with WM_SETTEXT you can use Control.Text
property in assignment operator.

HTH
Alex
 
L

Leon Chi

Alex

Thanks for your reply.

What I want to do is I want to Post a message to a control. For example. I
post a WM_SETFOCUS message to a control
in another control's WM_LBUTTONDOWN event handler. So after the mouse event
handled. the control can get focus.

Can you understand me?

Best Regards
Leon
 
G

Guest

can't you use control1.focus() ?
or use APIs (SendMessage and PostMessage) within C#
 
A

AlexS

Leon,

yes I think I get you. Once again - .Net Framework provides some level of
abstraction from underlying OS - be it Windows or something else. That's why
you should resort to Win32 API only when there are no standard methods and
properties, which can do same task.

HTH
Alex
 
L

Leon Chi

Alex:

So I have to use API(s) to accomplish this? No way in .NET? If so, pity!

Leon
 
A

AlexS

Leon,

your conclusion is not exactly right. You can use standard .Net methods for
this. Intercept mouse in MouseDown and set focus with Control.Focus and/or
Controll.Select methods.

HTH
Alex
 
L

Leon Chi

AlexS:

I tried to do this but failed. When I called Control.Focus() and/or
Select() in MouseDown event handler. Control.Focus()
always return "false". So this way doesn't work. Is there other way?

Best Regards
Leon
 

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