message-pump

Sending and receiving Windows messages

五迷三道 提交于 2021-01-28 00:09:08
问题 Windows messages seems a good way to notify an application on Windows OSes. It actually works well, but few question comes up to my mind: How to specify structured data to the lparam of the SendMessage routines (like many message codes does)? I mean... of course the parameter is a pointer, but how the process access to it? Maybe is it allocated by a DLL loaded by the processes sending/receiving the message? Is it possible to share message structured parameters (between sender and receiver)?

Pumping Windows Messages During Long Operation?

北战南征 提交于 2019-12-22 02:05:07
问题 I'm getting the following message on a big operation that I'm running: The CLR has been unable to transition from COM context 0x1fe458 to COM context 0x1fe5c8 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage

Visual Basic.NET: how to create a thread to update the UI

泄露秘密 提交于 2019-12-17 19:59:16
问题 The usual VB way to handle a computationally heavy task is to put it in a background worker thread, while the main thread keeps handling the UI. Say for whatever reason I needed to do this the other way around: the main thread doing the grunt work and the background one updating the UI. Here's what I have so far. The only problem is, while the UI window (Form1) does get redrawn, you can't interact with it, not even move or resize it (the mouse cursor turns to hourglass and won't click).

C# Windows (touch -> click/focus) messages between Form and Controls (WM_xxx)

人走茶凉 提交于 2019-12-12 05:28:06
问题 I have a 3rd party open-source control (not important which one really, but its CefSharp's Chromium Web browser [v 43]). Initially, there was a problem where if a form menu was open when you clicked inside the control, the menu was not dismissing itself (as if the control was swallowing the click event). To circumvent this, the sample application suggested intercepting the WM_MOUSEACTIVATE message between the form and the control, and reacting by posting a WM_NCLBUTTONDOWN back to an element

How to make a program not show up in Alt-Tab or on the taskbar

吃可爱长大的小学妹 提交于 2019-12-10 01:47:52
问题 I have a program that needs to sit in the background and when a user connects to a RDP session it will do some environment setup then launch a program. When the program is closed it will do some housekeeping and logoff the session. The current way I am doing it is I have the terminal server launch this application. This is built as a windows forms application to keep the console window from showing up: public static void Main() { //(Snip...) Do some setup work Process proc = new Process(); //

How to make a program not show up in Alt-Tab or on the taskbar

≯℡__Kan透↙ 提交于 2019-12-05 00:50:17
I have a program that needs to sit in the background and when a user connects to a RDP session it will do some environment setup then launch a program. When the program is closed it will do some housekeeping and logoff the session. The current way I am doing it is I have the terminal server launch this application. This is built as a windows forms application to keep the console window from showing up: public static void Main() { //(Snip...) Do some setup work Process proc = new Process(); //(Snip...) Setup the process proc.Start(); proc.WaitForExit(); //(Snip...) Do some housecleaning

Message pump in a console application

最后都变了- 提交于 2019-12-01 16:54:05
问题 I have a fairly simple console application written in .NET. Sometimes the application is run in batch mode without an operator, other times it is run "out of pocket". If it's running in batch mode, there is a defined default option which allows the program to run automatically. If there is an operator present, there are other options which allow the user to select from a list of functions. For reasons I don't want to go into, command-line parameters are not preferred. Instead, I've created a

Visual Basic.NET: how to create a thread to update the UI

你说的曾经没有我的故事 提交于 2019-11-28 10:35:40
The usual VB way to handle a computationally heavy task is to put it in a background worker thread, while the main thread keeps handling the UI. Say for whatever reason I needed to do this the other way around: the main thread doing the grunt work and the background one updating the UI. Here's what I have so far. The only problem is, while the UI window (Form1) does get redrawn, you can't interact with it, not even move or resize it (the mouse cursor turns to hourglass and won't click). Public Class ProgressDisplay Private trd As Thread Public Sub New() trd = New Thread(AddressOf threadtask)

Ending a Program Mid-Run

試著忘記壹切 提交于 2019-11-27 15:23:28
pythoncom.PumpMessages() From what I understand this line basically tells the program to wait forever. For my purposes it seems to be working. However, I'd like to be able to end the program given the right stimulus. How would one go about ending the above line, or stopping the program from running any further. According to these docs , pythoncom.PumpMessages() : Pumps all messages for the current thread until a WM_QUIT message. So one way to stop collecting messages is by posting a WM_QUIT message to the message queue by using the ctypes library to call PostQuitMessage : ctypes.windll.user32

Exceptions silently caught by Windows, how to handle manually?

让人想犯罪 __ 提交于 2019-11-27 11:28:19
问题 We're having problems with Windows silently eating exceptions and allowing the application to continue running, when the exception is thrown inside the message pump. For example, we created a test MFC MDI application, and overrode OnDraw: void CTestView::OnDraw(CDC* /*pDC*/) { *(int*)0 = 0; // Crash CTestDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; // TODO: add draw code for native data here } You would expect a nasty error message when running the application, but you