Questions tagged [windows-messages]

Questions about various messages in a Windows system.

Windows is an event driven operating system basically only responding to messages.

Message-identifier values are used as follows:

  • The system reserves message-identifier values in the range 0x0000 through 0x03FF (the value of WM_USER – 1) for system-defined messages. Applications cannot use these values for private messages.

  • Values in the range 0x0400 (the value of WM_USER) through 0x7FFF are available for message identifiers for private window classes.

  • If your application is marked version 4.0, you can use message-identifier values in the range 0x8000 (WM_APP) through 0xBFFF for private messages.

  • The system returns a message identifier in the range 0xC000 through 0xFFFF when an application calls the RegisterWindowMessage function to register a message. The message identifier returned by this function is guaranteed to be unique throughout the system. Use of this function prevents conflicts that can arise if other applications use the same message identifier for different purposes.

312 questions
3
votes
1 answer

How to Capture the Windows Message that is Sent from this Menu?

In most applications, when you click some MenuItem, a WindowsMessage is sent (usually WM_COMMAND), with a wParam representing the ID of the chosen MenuItem. There is a certain program that has a Window Menu (the menu accessible via clicking the…
spaceman
  • 1,061
  • 1
  • 11
  • 31
3
votes
1 answer

GUI message queues (message pump - parallel or series)

I can't seem to find an answer to this anywhere. I'm not sure if I know how to phrase it. Do messages destined for controls on a form process in parallel to each other? I was always under the impression we had one message pump per thread apartment,…
user1830285
  • 578
  • 8
  • 24
3
votes
1 answer

Application-wide message handler in C# WinForms application

In Delphi 6 I could set an application-wide message handler: procedure TFrmMain.TntFormShow(Sender: TObject); begin Application.OnMessage:=AppMsgHandler; end; procedure TFrmMain.AppMsgHandler(var Msg:TMsg; var Handled:Boolean); begin if…
Paul
  • 25,812
  • 38
  • 124
  • 247
3
votes
1 answer

Form WM_KEYDOWN and WM_KEYUP messages aren't captured in WndProc

Form keydown and keyup messages aren't captured: public partial class Form1 : Form { const int WM_KEYDOWN = 0x100; const int WM_KEYUP = 0x101; protected override void WndProc(ref Message m) { if (m.Msg == WM_KEYDOWN) …
Paul
  • 25,812
  • 38
  • 124
  • 247
3
votes
1 answer

SetWindowsHookEx for WM_MOUSEWHEEL

I need a code example written in VB.NET to capture the mousewheel scrolling events outside the form using a low-level hook with user32.dll and WM_MOUSEWHEEL like said by Hans Passant answer in my other question: Record mouse Middle button and wheel…
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
3
votes
1 answer

The name 'WM_DEVICECHANGE' does not exist in the current context

I am trying to detect a usb arrival event . I tried to override wndproc() for getting my messages. But I am facing an error by windows messages. The error is : The name 'WM_DEVICECHANGE' does not exist in the current context The name…
Zigma
  • 529
  • 6
  • 37
3
votes
1 answer

Get child window handles in C#

I'm starting a process in C# and then sending Windows messages to that process with SendMessage. Usually I send the messages to Process.MainWindowHandle, but in some instances I might need to find a child window handle and send messages there…
James Cadd
  • 12,136
  • 30
  • 85
  • 134
3
votes
1 answer

VB.NET Incorporate Alt+Window+Drag into Form

I know this would work If I wasn't using a web browser filling up my form. Dim drag As Boolean Dim mousex As Integer Dim mousey As Integer Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) MyBase.WndProc(m) '--- Alter…
Michael Schwartz
  • 8,153
  • 14
  • 81
  • 144
3
votes
2 answers

Difference between WM_CLOSE and SC_CLOSE

I just want to know what is the difference between these two messaging constants. Which one should I use in WndProc method when overriding, to handle close button message.
Soham Dasgupta
  • 5,061
  • 24
  • 79
  • 125
2
votes
1 answer

If no message in windows application message queue, then will message loop still continuously runs?

I have a doubt about windows message queue, and message loop. Could any one help me in understanding, or pls provide some reference links. If no message in windows application message queue, then will message loop still continuously runs? If runs…
Hara
  • 1,467
  • 4
  • 18
  • 35
2
votes
3 answers

WM_TIMER messages suppressed when clicking and holding the mouse over windows X button

I'm working on a game where the client needs to continue processing windows messages or else the game can be exploited. In order to solve this problem during window re-size and drag events, we have a WM_TIMER message that fires every 50ms which…
Zyrca
  • 43
  • 5
2
votes
0 answers

Preventing Windows shutdown in Rust

I'm trying to require a user to confirm a Windows shutdown while my program is performing critical tasks. In order to do this, I want to listen for a WM_QUERYENDSESSION message (in a seperate thread from the main program). If this message is…
2
votes
0 answers

Why does my app not receive the WM_CREATE message?

I want to get notified of new windows before they are shown. Therefore I subclass my application and listen for the WM_CREATE message. I am using Paul Caton's VB6 subclasser. Subclassing and listening to Windows Messages usually works fine for me,…
tmighty
  • 10,734
  • 21
  • 104
  • 218
2
votes
2 answers

How to add tray icon in a C++ console program?

I am developing a console program and I have planned to add a tray icon for it. But it seems that only Win32 GUI program can do something caused by messages. (WndProc()) My message checking loop code snippet: (Independent sub thread) void…
Yuchen Ren
  • 287
  • 5
  • 13
2
votes
1 answer

Listening to messages in another Windows app

I'd like my program to listen to messages in another Windows app. I am aware of SetWindowsHook, but am concerned about this line: If the dwThreadId parameter is zero or specifies the identifier of a thread created by a different process, the lpfn…
Asker
  • 1,299
  • 2
  • 14
  • 31