Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

SendMessage (user32)
 
.
Summary
Sends the specified message to a window or windows.

C# Signature:

[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, UIntPtr wParam,
   IntPtr lParam);

VB Signature:

Declare Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer,
   ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr

User-Defined Types:

None.

Notes:

Parameters

hWnd can be set using the Handle property of a Control. Msg constants can be found at http://www.codeproject.com/csharp/cswindowsmessages.asp.

Tips & Tricks:

Example useage to enumerate windows, and send a message to one (in C#): http://www.sloppycode.net/sloppycode/Article-104.html

Sample Code:

private const int WM_NCPAINT = 0x0085;

// Tell ourselves to paint our border

private void foo()

{

    SendMessage(this.Handle,WM_NCPAINT,new IntPtr(0),new IntPtr(0));

}

Alternative Managed API:

Do you know one? Please contribute it!

Documentation
SendMessage on MSDN

(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/messagesandmessagequeues/messagesandmessagequeuesreference/messagesandmessagequeuesfunctions/sendmessage.asp)

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions