Capturing and reacting to custom windows events in wxPython - windows

I'm in the process of writing an app to interface with a service running on another machine. When I ask this service for some information, this service adds the requested information to a separate queue, and sends a windows message to the calling application (my application) indicating there is a message waiting in this separate queue which needs to be decoded.
The windows message this service sends is a custom message, defined in the service code as having some constant int value. I've found examples of creating custom events in wxpython, and using TryBefore() and TryAfter() to react to these events in specific ways, but I haven't found any way to associate this NewEvent() with an int value so I can identify it when it comes in, much less any way to determine what an int value of an incoming event is.
Has anyone done this before or know of any functions I'm not aware of? I'm using python 3.6 and wxpython 4.0.
Thanks for your help, everyone.

I think this is what you are looking for: https://wiki.wxpython.org/HookingTheWndProc
When you get the custom message from the hooked WndProc you can either react to it there, or you can turn it into a wx event and send it so it can be caught by binding an event handler like normal. The wx.lib.newevent module has some helpers for creating a custom event class and an event binder. Its use is demonstrated in some of the demo samples and library modules.

Related

UWP TimedMetadataTrack Events are not firing

I can not seem to get the a TimedMetadataTrack object to fire the events CueEntered or CueExited for SpeechCue events.
Any thoughts?
So, apparently this line is needed when registering for IMediaCue.CueEntered and IMedia.CueExited events (at least the SpeechCue implementation of the interface):
((Windows.Media.Playback.MediaPlaybackItem)item).TimedMetadataTracks.SetPresentationMode((uint)index, Windows.Media.Playback.TimedMetadataTrackPresentationMode.ApplicationPresented);
This line is required to exactly allow the system to send the CueEntered and CueExited events that are being listened for.
Yet again, another case of Microsoft not fully documenting things in their API Documentation or Code Examples.

Getting a notification when a local file is accessed in windows

I'd like to get notified when a specific file get accessed (AFAIK, most generally for a Userland code - by CreateFile() / NtCreateFile())
I already know about FileSystemWatcher which should do the same within the .NET environment, But I'm working in plain C + WinAPI.
As for the type of notification , raising a specified Event would be perfect, but sending a callback to be called , will also work.
See FindFirstChangeNotification function in WinAPI and related links.
Alternatively, when functionality of that function is not enough, you can use a filesystem filter driver (write yours or use our CallbackFilter product).

Event Bus Vs HandlerManager in GWT?

When i working with one GWT project am using MVP pattern and HandlerManager for communicating on the application via Events. Now am implementing History Machanisam on my project.
They(GWT tearm) used Class EventBus for managing the events.
When read some blog i foud HandlerManger is used for Widgets and EventBus for other application wide communication.
But i feel both of them have same functionalities, then whats the purpose of this two implemetations, or whats the difference between them .
please help me
HandlerManager is the ancestor of the EventBus, which was extracted from (factored out of) it.
The main difference is that a HandlerManager has a source that it enforces on the events being dispatched to it, whereas EventBus can dispatch events with no source (fireEvent) or with a given dynamic source (fireEventFromSource). You can then attach handlers to the EventBus that will only be triggered for events from a given source.
Within widgets, you want to enforce that the event source is the widget. For a global application-wide event bus, you either want no source, or a source dynamically set for each event, as needed (RequestFactory uses it for its EntityProxyChange events so you can listen only to events related to a given kind of EntityProxy)
Note: the javadoc for HandlerManager discourages using it for an application-wide event bus.

Winsock object problem with WithEvents

I am developing a Standard EXE Project for sending mail.
I have a class module for sending email using winsock.
I have a withevents winsock variable set to the winsock control of a form.
The problem is that events are being catched in form's control event handler.
When i comment form's control event handling procedures and put a breakpoint in class module witheevents variable's event handler,i am unble to catch the events.
Please suggest a workaround.
If you really need to create a class (little c) that wraps constituent controls you create a UserControl, which can be invisible at runtime and have no UI interaction at all. Then, as the Winsock control's container, this UserControl will receive the events and you can handle them there.
I do this fairly often in order to create higher-level communication components, moving things like a message framing protocol inside. Then the container I put these UserControls onto only handles events raised when it has received complete messages for example. I've done the same thing to create an embeddable HTTP Server control, raising events back to the containing Form to process GET/POST requests with parameters and so on to provide a Web UI.
A Class (big C), Form, and UserControl are just three kinds of class (little c) you can create in VB6. "Class modules" really should have been called "UserClass" for clarity I suppose, in hindsight.

Is there an API event for when person changes clock on Windows?

I was wondering if there's some sort of system event that gets fired every time a user changes the time in Windows. I know there's a way to enable this in Windows' EventLog, but I was looking for a way to respond to this event programatically (like using the Windows API).
A WM_TIMECHANGE message is sent whenever there is a change in the system time
I'm not sure from your question if you're working in managed or native code. But if you're working in managed code you can use the TimeChanged event on the SystemEvents class.
Microsoft.Win32.SystemEvents.TimeChanged

Resources