473,408 Members | 1,845 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,408 software developers and data experts.

PeekMessage in .Net

What is the .Net Framework equivalent of the Windows API function
PeekMessage? Or any other method that will do the same thing. I simply
need to check to see if there are messages waiting to be processed.

Thanks!
Nov 16 '05 #1
1 7983
Jeff,

There is no equivalent in the .NET framework. However, you can call the
API through the P/Invoke layer, using the following declarations:

[StructLayout(LayoutKind.Sequential)]
public struct MSG
{
public IntPtr hwnd;
[MarshalAs(UnmanagedType.U4)]
public int message;
public IntPtr wParam;
public IntPtr lParam;
[MarshalAs(UnmanagedType.U4)]
public int time;
public Point pt;
}

[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern bool PeekMessage(
ref MSG lpMsg,
IntPtr hWnd,
[MarshalAs(UnmanagedType.U4)] wMsgFilterMin,
[MarshalAs(UnmanagedType.U4)] wMsgFilterMax,
[MarshalAs(UnmanagedType.U4)] wRemoveMsg);

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jeff" <a@a.com> wrote in message
news:em**************@TK2MSFTNGP11.phx.gbl...
What is the .Net Framework equivalent of the Windows API function
PeekMessage? Or any other method that will do the same thing. I simply
need to check to see if there are messages waiting to be processed.

Thanks!

Nov 16 '05 #2

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

Similar topics

21
by: Alo Sarv | last post by:
Hi From what I have understood from various posts in this newsgroup, writing event loops pretty much comes down to this: while (true) { handleEvents(); sleep(1); // or _sleep() or...
2
by: JR | last post by:
Hi folks, How can I implement the following in C#? while(AppExitFlag == false) { if(AppPausedFlag == true) { GetMessage(); // Process messages.
2
by: Jeff | last post by:
What is the .Net Framework equivalent of the Windows API function PeekMessage? Or any other method that will do the same thing. I simply need to check to see if there are messages waiting to be...
2
by: Jozsef Bekes | last post by:
Hi All, I am trying to implement a general threading approach in C#, and I have faced this problem: I have the function f_main running in thread th1. I want to invoke two functions f1 and f2 in...
14
by: | last post by:
Hi All, I am little confused here, hope you can help me. While processing WM_POWERBROADCAST (wParam=PBT_APMQUERYSUSPEND), I MUST to do some lengthy operation(30 sec) before system Suspends or...
3
by: John | last post by:
I get the following VB6 sample and it doesn't work in VB .Net. Can anyone help to make it work in VB .Net? Structure POINTAPI Dim x As Long Dim y As Long End Structure Structure MSG Dim...
1
by: Bruce | last post by:
I worte an OCX with events. In order to allow the dialog box (or whatever) to be updated by the event, I had to add a messagepump to the event. void MessagePump() { MSG msg; while...
1
by: SeeSharp Bint | last post by:
Hi I'm using some of the definitions I found pinvoke.net for PostMessage and PeekMessage as follows public static extern bool PostMessage( HandleRef hWnd,// handle to destination window...
11
by: vbguy2008 | last post by:
Hi, I am coding a Windows Form Application in VB.NET 2008. I would like to clear the keyboard buffer or at least empty all outstanding key presses queued up for my application at certain points...
4
by: daved | last post by:
SOLUTION NEEDED FOR ACCESS 2003 / VBA, NOT FOR ANY VERSION OF VB. I need to differentiate between the Enter key on the main keyboard and the numeric keypad and obviously tried using...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.