473,320 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

send/post a message to a window

In a standard unmanaged win32 application I can send/post a message to a
window as a communication mean.
Can it be down also in a dot net application?

Regards
Mark
Oct 7 '07 #1
7 2211
Mark wrote:
In a standard unmanaged win32 application I can send/post a message to a
window as a communication mean.
Can it be down also in a dot net application?
Yes. A .NET Control-based object still has an underlying window that
receives messages and a window proc that handles these messages. Your
own code can override the WndProc method in the class if it has a need
to deal with custom messages.

That said, the kinds of things that may have been done using SendMessage
or PostMessage are often better done using some other mechanism in .NET.
Occasionally you may indeed want to use the "old-style" mechanisms
you're used to, but it would be a mistake to generally try to do
Win32-style programming in .NET (even if .NET is filled with various
behaviors it's inherited from the native Win32 API :) ). It's better to
think of .NET as a whole new platform, and focus on implementing
behaviors in a way that use the .NET mechanisms.

Pete
Oct 7 '07 #2
Thanks,
Following your advise, can you indicate what is the similar mechanism for
sending Windows messages in dot net?

Regards

Mark
"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote in message
news:13*************@corp.supernews.com...
Mark wrote:
In a standard unmanaged win32 application I can send/post a message to a
window as a communication mean.
Can it be down also in a dot net application?

Yes. A .NET Control-based object still has an underlying window that
receives messages and a window proc that handles these messages. Your
own code can override the WndProc method in the class if it has a need
to deal with custom messages.

That said, the kinds of things that may have been done using SendMessage
or PostMessage are often better done using some other mechanism in .NET.
Occasionally you may indeed want to use the "old-style" mechanisms
you're used to, but it would be a mistake to generally try to do
Win32-style programming in .NET (even if .NET is filled with various
behaviors it's inherited from the native Win32 API :) ). It's better to
think of .NET as a whole new platform, and focus on implementing
behaviors in a way that use the .NET mechanisms.

Pete

Oct 8 '07 #3
MArk wrote:
Following your advise, can you indicate what is the similar mechanism for
sending Windows messages in dot net?
That depends on what you really want to do. If you literally want to
send a message, you will have to use the regular Win32 Send/PostMessage
mechanism.

My point is that for the kinds of things that messages are often used
for, you just don't do that any more. For example, you might have used
something messages like EM_SETSEL and EM_REPLACESEL to modify the text
in an edit control. In .NET, the TextBox control has instance methods
and properties to do work like that (for example, the Select() method to
change the selection and the SelectedText property to change the text in
the selection).

You mention using messages "as a communication means", but that's not
very descriptive. In a certain sense, ALL window messages are "a
communication means". So saying that's what you're using messages for
is pretty vague.

If you have some specific "communications" that you are trying to
accomplish, there is likely in .NET a better way to do it that sending a
window message. But absent some specific information about what you're
really trying to accomplish, it's not really possible to answer the
question.

Pete
Oct 8 '07 #4

"MArk" <ma**@giron.comwrote in message
news:eT**************@TK2MSFTNGP05.phx.gbl...
Thanks,
Following your advise, can you indicate what is the similar mechanism for
sending Windows messages in dot net?
SendMessage becomes Control.Invoke(Delegate)
PostMessage becomes Control.BeginInvoke(Delegate)
>
Regards

Mark
"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote in message
news:13*************@corp.supernews.com...
>Mark wrote:
In a standard unmanaged win32 application I can send/post a message to
a
window as a communication mean.
Can it be down also in a dot net application?

Yes. A .NET Control-based object still has an underlying window that
receives messages and a window proc that handles these messages. Your
own code can override the WndProc method in the class if it has a need
to deal with custom messages.

That said, the kinds of things that may have been done using SendMessage
or PostMessage are often better done using some other mechanism in .NET.
Occasionally you may indeed want to use the "old-style" mechanisms
you're used to, but it would be a mistake to generally try to do
Win32-style programming in .NET (even if .NET is filled with various
behaviors it's inherited from the native Win32 API :) ). It's better to
think of .NET as a whole new platform, and focus on implementing
behaviors in a way that use the .NET mechanisms.

Pete


Oct 8 '07 #5
Ben Voigt [C++ MVP] wrote:
"MArk" <ma**@giron.comwrote in message
news:eT**************@TK2MSFTNGP05.phx.gbl...
>Thanks,
Following your advise, can you indicate what is the similar mechanism for
sending Windows messages in dot net?

SendMessage becomes Control.Invoke(Delegate)
PostMessage becomes Control.BeginInvoke(Delegate)
That's only partly true.

Many examples of where you might use SendMessage in particular are
simply replaced by calling a method directly. You'd only use Invoke()
in situations when you'd have used a cross-thread SendMessage() in Win32.

IMHO, PostMessage() has a much closer correlation to BeginInvoke(), but
even there I wouldn't say there's a 1-to-1 correlation. At least some
of the things one might have used PostMessage() for are, again, better
handled just using normal .NET calls.

Pete
Oct 8 '07 #6

"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote in message
news:13*************@corp.supernews.com...
Ben Voigt [C++ MVP] wrote:
>"MArk" <ma**@giron.comwrote in message
news:eT**************@TK2MSFTNGP05.phx.gbl...
>>Thanks,
Following your advise, can you indicate what is the similar mechanism
for
sending Windows messages in dot net?

SendMessage becomes Control.Invoke(Delegate)
PostMessage becomes Control.BeginInvoke(Delegate)

That's only partly true.

Many examples of where you might use SendMessage in particular are simply
replaced by calling a method directly. You'd only use Invoke() in
situations when you'd have used a cross-thread SendMessage() in Win32.

IMHO, PostMessage() has a much closer correlation to BeginInvoke(), but
even there I wouldn't say there's a 1-to-1 correlation. At least some of
the things one might have used PostMessage() for are, again, better
handled just using normal .NET calls.
The original post asked about SendMessage and PostMessage as a means of
communication. Which to my small little brain means "between threads",
because I'd have used a direct function call in native code as well if that
was what I wanted.
Oct 9 '07 #7
Ben Voigt [C++ MVP] wrote:
The original post asked about SendMessage and PostMessage as a means of
communication. Which to my small little brain means "between threads",
because I'd have used a direct function call in native code as well if that
was what I wanted.
I don't disagree with that application. But I do think that's an overly
narrow interpretation of "communication". As I mentioned to the OP, the
problem description, such as it was, was very vague and it's very
difficult to answer vague questions like that in a really useful way.

But I would not limit "communication" to be inter-thread communication.
I would say that sending messages like WM_SETTEXT, EM_REPLACESEL, etc.
are forms of communication, and they often occur in a single thread.
Likewise, something like WSAASyncSelect() that uses window messages to
handle Winsock communications; again, usually all in the same thread.

I also think that while direct function calls are best where possible,
there are viable means of inter-thread communication that don't use
Send/Post/Invoke/etc. as the mechanism.

I have tried to encourage the OP to clarify what it is exactly he's
trying to replicate in .NET. With better details, it's a lot easier to
provide a useful reply. And it may well be that using Control.Invoke()
or Control.BeginInvoke() are in fact the things he's looking for. But
those apply to very specific needs, and it could just as easily be that
he doesn't need those at all.

Pete
Oct 9 '07 #8

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

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
9
by: Etienne Charland | last post by:
Hi, there is an application running on a remote desktop (under Citrix ICA, but the same problem applies for RDC or PC Anywhere). Now, I want to send keys to the remote application from a local app....
15
by: Steve Horrillo | last post by:
I can't figure out why this script won't insert the subject in the email and why can't I control the font and size being used? I'm not sure where to post this. Let me know where if this is OT. ...
3
by: Max | last post by:
When you send an email programatically throgh Microsoft Outlook it goes into the Outbox and stays there. I have an application that opens the email window and allows the user to type a message and...
3
by: Lars Netzel | last post by:
Hello! I have a button, in the click event I have this code: ---------------------------------------------------------------------------- ---------------------------- Response.Write("<script...
6
by: paul | last post by:
HI! How do we send a variable from an Iframe page back to its parent? I have a script that calculates the iframe's window size but I need to know how to send that value back to its parent so I...
15
by: cj | last post by:
How can I get a button in VB to send the contents of a text box via email in a manner similar to the "Send To\Mail Recipient" functionality that you can select via right clicking a file in Windows...
3
by: keith.schincke | last post by:
I know I must be missing something basic. I am developing of Firefox 1.5 and am trying to to send a basic QUERY_STRING to a test CGI that will print the data back to the brower: I can print my...
2
by: ajaxcoder | last post by:
Hi In my project i had a login form and i am trying to send the username and password to the server for authentication using xmlHttpRequest. Hence i am using POST request but i am unable to send...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.