Web Browser Events using MsHTML.h - c++

I am using cwebpage integrated into my program. CWebpage information can be found here:
https://www.codeproject.com/Articles/3365/Embed-an-HTML-control-in-your-own-window-using-pla
My question is regarding events. I currently have this setup to setup click events using get_anchors() in IHTMLDocument2. I then iterate over all of the elements to create a IDispatch in memory. This holds the event information. When an item is clicked, it sends a WM_NOTIFY to the window and then I can handle the event and parse out what I need to parse from the element that was selected.
This all works fine until I run into a page in my software with close to 50,000 anchor tags in which we run out of memory since we hold the events in memory until the the page is destroyed.
Is there a simple way to obtain the clicked element without having to set an event for each individual element? Is it possible to set a click event at a document level and then find the element that tripped it? All I am trying to do is obtain the id of the element that is clicked.
What I've tried:
I tried to just use a WM_LBUTTONDOWN message read in our browser window and then use htmlDoc2->elementFromPoint() to simply get the information that I need from the element selected. This however does not work well if the page is zoomed or wraps.
Please note this programming is in C/C++, not javascript or vb.
Thank you.

HTML events "bubble" from child elements to parent elements. So, you can simply assign a single onClick handler to the IHTMLDocument2 itself, and then use the srcElement property of the IHTMLEventObj object that is given to your handler every time on onClick event is fired by any child element on the page. See Understanding the Event Model.

Related

Is there an event mask I can set in Xlib to receive an event whenever a window title is changes

I'm writing a window manager in C++ (mostly c stuff but i need unordered_map) with Xlib and my current approach to updating window titles is to get window titles whenever it receives any unrelated event. The problem with this is that if I open XTerm, for example, the titlebar says "xterm" until I do something that sends an event (like clicking the titlebar) and then the window title changes to "username#hostname:WD". It's supposed to update to that format after showing "xterm" for only a split second. It's also supposed to change every time you use the cd command.
Is there an event mask I can use to do this? I looked in a list of Xlib event masks and couldn't find an event mask that does this.
The client should set _NET_WM_NAME application window property. If you want to get events when application updates this property you can set PropertyChangeMask on the application window. Mask value is 0x400000.

How to keep track of dirty controls in a dialog

I was wondering how Windows applications typically keep track of dirty controls in a dialog, so that when the user clicks a button like "Apply" or "Save," the application knows which controls' values to commit.
I see that edit controls have an EM_GETMODIFY message, which will tell you whether the contents of the edit control have been modified, but I don't think that type of message is available for other controls like date-time pickers or combo boxes.
So I suspect that this would be done by monitoring change notifications sent from the controls to the parent dialog. But if that's the case, how might the change events be flagged or stored? I thought that perhaps that whenever a change occurs, the application could store the control's ID or hwnd in a std::unordered_set, and then iterate through the set when it's time to commit. Or is there another, more accepted and efficient way? Thank you for any guidance.

why are Key events c++ WxWidgets not being caught?

Good day guys
I am using WxWidgets 2.8. I have created a grid like interface using text boxes. I would like to change the values in text boxes by simply navigating to them using the arrow keys.
I have set up a panel in which the text boxes are placed, then added a onkeydown event which should just display a message when a key is pressed. This does not work.
I have tried oncharevent, and even adding the the events to the wxFrame.
Why can I not catch the key events?
Only the currently focused window gets the key events and the frame will never have focus if it has any children taking it, such as text controls.
Also do consider using wxWidgets 3.0 for any new code, in particular it provides Bind() which can be convenient for handling key events from all your controls in a single place if this is what you want to do.

if I select a text in tree control than how I'll get that message in list control

Can anybody tell me, if I select an item in tree control than how I'll get that text in List control at the same time. I am getting how to do it?
Please help me out.
When a CTreeCtrl has an item selected, there is a WM_NOTIFY notification of TVN_SELCHANGED - See MSDN for details.
As it also says in MSDN :
As the user interacts with the control, it will send various
notification messages. You can specify a function to handle each of
the messages you want to handle by adding an ON_NOTIFY_REFLECT
macro in your control window's message map or by adding an
ON_NOTIFY macro to your parent window's message map.
If you do this, you will detect the clicked item, from which you can retrieve the text and add an entry to a list (or whatever else you need to do).

Microsoft Equivalent of WebkitGTK hovering-over-link signal

I need to add ability to catch event each time there is mouse hover event both on Linux and Windows. In Linux I easily connect to hovering-over-link signal. I cannot seem to find Windows equivalent. Searched google, checked the MSDN, I could not find.
Does Such a functionality available in windows? If no is there a way to achieve it?
Can you use the StatusTextChange event? This event is fired when the mouse is hovered over a link, with sText set to the link URL.
It is also fired with additional messages such as when loading a page. In these cases, sText is set to "Connecting to (URL)", "Waiting for (URL)", etc. These messages can be simply ignored by doing a basic URL validation of sText.
A more involved method would be in the DocumentComplete event to search for all anchor elements using getElementsByTagName and attach to the HTMLAnchorEvents onmouseover. This of course wouldn't work for anchor elements dynamically created after page load.