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

TranslateMessage (user32)
 
.
Summary

C# Signature:

[DllImport("user32.dll")]
static extern bool TranslateMessage([In] ref MSG lpMsg);

VB.NET Signature:

<DllImport("user32.dll")> _
Public Shared Function TranslateMessage( _
     ByRef lpMsg As MSG) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function

VB Signature

Public Declare Function TranslateMessage Lib "user32" _
         (byref lpMsg As MSG) As Long

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

     public struct MSG
     {
     public IntPtr hwnd;
     public uint message;
     public IntPtr wParam;
     public IntPtr lParam;
     public uint time;
     public POINT pt;
     }

     [StructLayout(LayoutKind.Sequential)]
     public struct POINT
     {
     public int X;
     public int Y;

     public POINT(int x, int y)
     {
         this.X = x;
         this.Y = y;
     }

     public static implicit operator System.Drawing.Point(POINT p)
     {
         return new System.Drawing.Point(p.X, p.Y);
     }

     public static implicit operator POINT(System.Drawing.Point p)
     {
         return new POINT(p.X, p.Y);
     }
     }

void ProcessThisThreadMessagesUntilFOO()

{

        MSG myMsg = new MSG();
        while (WindowsAPIs.GetMessage(out msg, IntPtr.Zero, 0, 0) && ! FOO_EXPRESSION )
        {
        if(msg.message != FILTERED_MESSAGE)
        {
            WindowsAPIs.TranslateMessage(ref msg);
            WindowsAPIs.DispatchMessage(ref msg);
        }
        }

}

Alternative Managed API:

Do you know one? Please contribute it!

Documentation

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
Edit This Page
Find References
Show Printable Version
Revisions