73 questions
0
votes
1
answer
83
views
Is there a way to automatically wake a WinAPI GetMessage() after n seconds?
As explained here, the Windows API GetMessage() blocks until a message is available.
I would like to automatically wake after n seconds. Alternatively, I'd like to have the system post a WM after n ...
-3
votes
1
answer
147
views
How can I ensure that a Message Loop in Win API doesn't use the CPU when no messages available?
How can I ensure that a Message Loop in Win API doesn't use the CPU when no messages are available? In other words, I effectively want a Message Loop which says "Sleep until I have a new message&...
-1
votes
1
answer
2k
views
How does Win32 API PeekMessage function work
I was trying to program with Win32 API, but I came across an unusual behaviour that I wasn't expecting which left me kinda confused. In my while loop:
while (IsWindow(hwnd)) {
while (PeekMessage(&...
0
votes
2
answers
261
views
C++ How to allowing for Low Level Mouse callback to get called in a loop/ when wait for input
So I am trying to create a console button base (using low level mouse hook) for a console menu (which uses arrow keys and enter key for controls) that I have created before and both work fine alone ...
0
votes
0
answers
51
views
Translate sequences of virtual keycodes into the resulting character message
My understanding is that TranslateMessage collates a sequence of key events and adds a WM_CHAR message to the queue if it results in a character. So on my computer what happens when I press Alt+1234 (...
2
votes
0
answers
275
views
Initializing the COM library in apartment threaded mode in a thread with no message loop
According to the documentation, if the COM library is initialized in "apartment threaded" mode, the thread must have a message loop.
However, I found that using COM in a thread with no ...
0
votes
1
answer
106
views
Necessity of testing key value before calling IsDialogMessage
I've seen several code examples that test the value of a message to determine that it's between WM_KEYFIRST and WM_KEYLAST before calling IsDialogMessage.
I was wondering if that's technically ...
1
vote
1
answer
177
views
MFC CListView how to prevent search & auto-selection when user types letters?
TL;DR
In a C++ MFC CListView, how to prevent automagic selection based on letters the user types when the CListView has keyboard focus?
Situation:
MFC application using a CListView to show a ...
-2
votes
1
answer
496
views
How to invoke into message loop after Application.Run()
How can I invoke into the message loop of the tread/form after calling Application.Run() without a dialog? The reason is that I want to prepare (and later show) a dialog that is clickable even if a ...
0
votes
1
answer
536
views
Why is DestroyWindow blocked?
I create a window and message loop in the child thread.
When I sent a custom message through PostMessage, when I called DestroyWindow in the thread, DestroyWindow blocked and did not trigger ...
0
votes
2
answers
159
views
How to dispatch messages for multiple dialogs in an ATL exe
Microsoft had a knowledge base article describing how to modify the message loop in at ATL .exe so that modeless dialogs can receive appropriate messages.
I was wondering how to elegantly do this if ...
0
votes
1
answer
1k
views
How to quit/break from windows message loop in console app and deferences from windows desktop app?
I want to break from the windows message loop. Just like C++ how to break message loop in windows hook . I came up with one solution, which works fine for Window Desktop Application, but fails for ...
3
votes
1
answer
2k
views
Why does the win32 message loop stop working when threaded?
I am trying to create a WIN32 (C++) program in which I will have to simultaneously process messages and run a while loop. In order to do that, I want to use threads.
When I moved the message loop to a ...
0
votes
1
answer
37
views
Difficulty displaying "login" and "main" forms correctly
I have a WinForms application, with a login form and main form. The login form contains two textboxes for the user to enter credentials, an OK button, and a Cancel button. The following code is the ...
0
votes
0
answers
324
views
CefSharp.WinForms Drag and Drop messageloop override
I need to implement the answer provided to the following StackOverflow thread:
How to receive drag move and drag drop events using CefSharp winforms
I've tried implementing the code, but I feel the ...
3
votes
2
answers
5k
views
Is it possible to create a message loop without creating a window in C++
I was working with some Bluetooth library and for some Bluetooth callback, it is necessary to use Windows message loop. But as per my requirement, I need to create a normal C++ program without any GUI....
1
vote
0
answers
137
views
Why Is PostQuitMessage Necessary
Pretty simple question. I was just curious why I would use PostQuitMessage(0) to break out of my Message Loop, instead of just doing something like:
bool isRunning;
case WM_DESTROY:
{
isRunning =...
1
vote
1
answer
224
views
Why does Task.WaitAll hang when a form is launched directly in Main()?
I've added a splash-screen form to a C# WinForms application to display while the application is being initialized/checking for updates. I'm using Squirrel.Windows to check for updates in Program.cs.
...
-1
votes
1
answer
1k
views
Window message loop ( WndProc | While (GetMEssage)) thread in .NET Core
I am trying to subscribe to window messages using .Net Core
I am able to receive initial messages to create a window ( through pinvoke) and destroy messages. But after that my created windows gets ...
3
votes
1
answer
1k
views
Waiting for GUI events and IOCP notifications at once
Can I wait for GUI events — that is, pump a message loop — and on an I/O completion port at the same time? I would like to integrate libuv with the Windows GUI.
0
votes
1
answer
48
views
How to statistic every button click in mfc using message loop mechanics?
I have a MFC application. I want to statistic every button click, including button ID and time. Can I do it in CWinApp::PreTranslateMessage(MSG* pMsg) or CWnd::PreTranslateMessage(MSG* pMsg)? And how?...
0
votes
0
answers
531
views
[c++ windows]capturing mouse click event from a window that isn't mine
I want to detect when the mouse is pressed on my wallpaper.
So I got the wallpaper handle and now I'm trying to add a message loop to it, but its not working for some reason.
Here's my code so far:
...
0
votes
0
answers
50
views
I get the wrong wParam from WV_MBUTTONDOWN
So I'm trying to build a simple input-handler to work against windows message-loop. But for some reason when I test the case of WM_MBUTTONDOWN I get the same wParam as if I press the "Shift-key". The ...
1
vote
2
answers
326
views
How to push a message loop in WinForms?
In WPF, I can push a message loop using Dispatcher.PushFrame.
What is the equivalent in WinForms? I'm familiar with DoEvents but that must be called in a loop which can spin the CPU instead of the ...
2
votes
1
answer
95
views
Why does Save As dialog block the sender?
The aim of my program is to trigger Save As dialog of Notepad via Save As item in Notepad's menu.
SendMessage(hWndOfNotepad, WM_COMMAND, SaveAsMenuItemId, IntPtr.Zero);
Console.log("Done!");
When run ...
4
votes
1
answer
518
views
.NET's Event Mechanism
In all the books regarding C#/.NET that I have seen till now, when they talk about Events,
they talk about Creating and Consuming Events.
I am curious to understand a bit how it works behind our code ...
0
votes
1
answer
287
views
Unknown Windows Message 0xC052
I'm working on a problem (How to Detect a form open inside the application) and stumbled over a Windows Message I can't understand: 0xC052.
This is the first Message I receive in a MessageFilter when ...
0
votes
1
answer
383
views
Use Windows message loop to receive an event in a library I'm writing
I'm writing a library that wraps some of Media Foundation functionality. I want to be able to notify a library user through a callback of when a webcam is connected/disconnected to/from the system. ...
1
vote
1
answer
685
views
Listening for incoming messages from TCP server causes StackOverflow
I need to continuously listen for messages from my C# TCP server, so I do it in separate thread:
private void StartMessageReceivingLoop()
{
new Thread(){
public void run()
{...
1
vote
1
answer
3k
views
Why can't I get a WM_DESTROY or WM_CLOSE message outside a window procedure?
I wanted to read out messages in my message loop right before I dispatch them to my window procedure. Most messages I tried reading like this were read correctly, but when I close the window, a ...
2
votes
3
answers
5k
views
Message loop in MFC
I have learned a bit about Win32 API, but now I want to learn MFC. In my ebook, they said that the CWinApp class manages main thread of application, but I can't find something like GetMessage, ...
1
vote
0
answers
1k
views
Why does (or how to detect when) my DDE conversation hang randomly from Excel?
Nature of the Problem:
I have a macro enabled excel sheet that successfully establishes a DDE connection and conversation with a terminal application for the ManMan database system, Minisoft. About ...
4
votes
2
answers
2k
views
Using async method for message loop in C#
I'm making an online communication application, and I'd like to process messages asynchronously. I found async-await pattern useful in implementing message loop.
Below is what I have got so far:
...
1
vote
0
answers
673
views
Low Level Keyboard Hook called intermittently, GetMessage never returns
I set up a low level keyboard hook in a worker thread that also runs a message loop. About 1/3 of my key strokes trigger the hook function and none release the GetMessage function in my message loop. ...
2
votes
1
answer
4k
views
WebBrowser control in a class library
So as the title suggests, I'm trying to use WebBrowser control in a class library. I've gone through several SO questions like this excellent post, but the unique thing in my situation is that the ...
2
votes
1
answer
435
views
Message loop is blocking application
I need to close a download popup in web browser control (disallow user to downloading file).
How i can achieve this?
I found this:
How to block downloads in .NET WebBrowser control?
And i used ...
0
votes
2
answers
347
views
Distinguish between user generated and my own application generated mouse moves
My WinForms app moves the mouse cursor about the form simply by setting the Cursor.Position property in some kind of a loop with a timer.
I would like this movement to continue only till the user ...
0
votes
1
answer
419
views
Who sent/posted the WM_MOUSEMOVE?
When using the Win32 API message loop (or any higher level abstraction of the same such as System.Windows.Forms.IMessageFilter) to get a message, how do I find out who/which control/which component/...
0
votes
1
answer
318
views
Is a CPU fetch / execute cycle an :"event loop"
I'm reading about event loops that pass messages, as I have to design one for a project I am working on. To understand it better, I am trying to analogize it to other things that I know somewhat ...
1
vote
1
answer
166
views
How to run multiple plug-in-like XNA games in one WinForms window
I want to create a (WinForms) application which consists of multiple panels. For each panel, I want to be able to assign a .dll file:
Those .dll files should contain XNA games that should be rendered ...
1
vote
1
answer
3k
views
Application.DoEvents() and freezing on some machine [closed]
I have a winforms application which makes calls to Application.DoEvents(). Now the app freezes around the time this method is called (no surprise).
However, this only happens on some machines. Is it ...
0
votes
1
answer
2k
views
MFC messageloop in dialog window
i created a MFC dialog application.
now i want to use a messageloop, but i can not find it. I read that mfc will create it for me but that it will be hidden. so how can i manipulate the messageloop?
...
0
votes
2
answers
808
views
WPF form and Windows messaging for Modal Dialogs
I have a simple WPF form with a textbox and button and on lost focus it simply simply shows a message box.
My code looks like this
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
...
1
vote
1
answer
200
views
Unable to update the UI components in C#
I am writing a program to monitor the status of various devices across a network. The details of these devices are stored in a file. The HandleClientComm class reads information about these devices ...
1
vote
4
answers
2k
views
Application.Run(), Application.Exit() and timers
I have a winforms application that I will be calling through the task scheduler to download files and insert them to a database. However it is unpredictable when the files are available so I have used ...
1
vote
2
answers
3k
views
What is the cleanest way to notify GUI to update in wxWidgets?
I have a small application that needs to update GUI elements if some event occurs in lower levels, say, socket goes off-line, or something like that.
In Windows, I could use PostMessage which would ...
1
vote
2
answers
927
views
Runnable posted by handler sees wrong object state (race condition?)
I'm running into a very strange issue here with wrong object state that I see in methods posted as Runnables using Handler.postDelayed. I use this to schedule draw calls for 2D drawing, and this draw ...
0
votes
1
answer
2k
views
Create child window in WM_CREATE, relevance of same thread?
A typical pattern is to create a child window in the message callback (WndProc) at message WM_CREATE:
LRESULT APIENTRY WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
...
switch (...
1
vote
3
answers
3k
views
Sleep() in windows message loop?
Does a Sleep(sometime) serve a purpose in the typical infinite window message loop, or is it just useless or even harmful?
Some examples contain the Sleep, most of them do not.
// Main message ...
0
votes
3
answers
235
views
role of message loop in this program ? and few more questions
The following code works fine. It gives out the message when the user presses a key. But there are certain things I am not aware of. What is the role of Message Loop here ? I read that calling ...