How to get complete HTML body using browser helper object (BHO) in case of DHTML/AJAX page? - c++

I'm writing a BHO that analyze the HTML taken from the 'onDocumentComplete' event of 'DWebBrowserEvents2'. Currently it works fine, unless I have a DHTML/AJAX page, where HTML handle is delivered too soon.
For sample, I tried using it on 'http://www.google.com'. From the 'onDocumentComplete' event I can get most of the page but in the topmost link/anchors, the 'href' for maps, videos, orkut etc. is not available (normally it is javascript:void(0)).
Has anyone any ideas how to capture it when the page is fully loaded rather than just when the frame/body is loaded?
Thanks,
UPDATE
It seems there is some problem with the MSHTML API. I have posted the same question on MSDN forum and some response. Also I have detailed out my problem and findings....
http://social.msdn.microsoft.com/Forums/en-US/ieextensiondevelopment/thread/d517dbd1-df22-4dce-8ff9-0ca6786757f9
In case someone finds some way to solve this then please do share...
Thanks,

The AJAX DHTML changes mostly don't cause a further onDocumentComplete call.
You need to register for further Window or Document events such as DISPID_HTMLWINDOWEVENTS2_ONLOAD.
One method is to advise the window of a com object that you provide with the generic event sink interface.
hr = AtlAdvise(winDisp, pWinHandler, DIID_HTMLWindowEvents2, &dwCookie);
When this further event is triggered re examining the document you will find that it is updated.

Related

ListView in android for dynamic data

how to refresh List View dynamic data content in android?
I tried loading dynamic data for the List View in android application but no luck .Any advice how to accomplish this?
Call notifyDataSetChanged() on your Adapter object once you've modified the data in that adapter.
Some additional specifics on how/when to call notifyDataSetChanged() can be viewed in this Google I/O video.
Or else Look at this link.it may helpful.
Dynamic ListView in Android app
Or else
The right thing to do is to call notifyDataSetChanged() on your Adapter.
Troubleshooting
If calling notifyDataSetChanged() doesn't work all the layout methods won't help either. Believe me the list view was properly updated. If you fail to find the difference you need to check where the data in your adapter comes from.
If this is just a collection you're keeping in memory check that you actually deleted the item from the collection before calling the notifyDataSetChanged().
If you're working with a database or service backend you'll have to call the method to retrieve the information again (or manipulate the in memory data) before calling the notifyDataSetChanged().
The thing is this notifyDataSetChanged only works if the dataset has changed. So that is the place to look if you don't find changes coming through. Debug if needed.
UI Thread
It is true that this has to be called from the UI thread. Other answers have examples on how to achieve this. However this is only required if you're working on this information from outside the UI thread. That is from a service or a non UI thread. In simple cases you'll be updating your data from a button click or another activity/fragment. So still within the UI thread. No need to always pop that runOnUiTrhead in.
More Information
Another nice post about the power of list Views is found here:http://www.vogella.com/articles/AndroidListView/article.html

ActiveX Property Persistance

I have a question about an ActiveX Control I am developing. I have hashed my way through most problems but I am stuck at a real road block. This ActiveX is being imorted into other software so I have to have a good implementation of the Property Pages. I have managed to get some persistant properties working with one issue. When I make a change in the property page it is updated and persists as long as the application that is development app that is using it is open but it reverts back when I reload the app. I have narrowed this down to the fact that the development app doesnt realize the ActiveX has changed and therfore doesnt save. If i make a unrelated change and save the program all is good and the values persist as expected. I have tried everything and cant seem t get the application that imports my ActiveX to realize when it has changed via the property page. I am wondering if anyone has some work arounds for this type of problem. It seems to me if I could force the DoPropExchange() it would work but I dont know how to call this explicitly.
Thanks in advance
Matt
Thanks for the input. I did have the SetModifiedFlag() but it wasnt working. After poking at it I solved that problem but now I am redirecting my question. I had removed the property above in question from the idl files dispinterface in order to prevent the application that loads the activex from displaying the property in its "Connection List"(3rd party application specific"). It appears that the app loads all the interface into this list but this is not good as some properties should be persistant and only modifiable through the proppages. I tried all the flags like hidden and local but still were displayed in the list. When I removed it from the dispinterface it was how I wanted it but would not signal the IsModified. My new question is in there another way to define properties for an instance like this or is it possible to have a secondary interface(I have not tested if the application would see this interface because I am not sure how I would go about defining this inteface)or to have a property only between the proppage and control. Or is there another way to signal the dirty. The OnMemberVariable of the control was properly executing I know from testing it just seems SetModifiedFlag() doesnt do anything if the property is not in the dispinterface
Thanks Again
You need to mark your control as "modified", so that its host could detect it and re-save persistent properties. In this case IPersistXxx::IsDirty implemented by your control would indicate dirty state.
MFC based control has COleControl::SetModifiedFlag for this purpose:
Call this function whenever a change occurs that would affect your control's persistent state. For example, if the value of a persistent property changes, call this function with bModified TRUE.
Update: To hide a property from property browser you can use nonbrowsable attribute.
Use the [nonbrowsable] attribute to tag an interface or dispinterface member that should not be displayed in a properties browser.

access url from microsoft web browser control in mfc VC++

i am using Microsoft web browser control in an MFC Application.
It displays a login page initially using
control.navigate(URL) method
After login i need to access the URL from the control.
How this can be done?
Can anyone help me out
The WebBrowser control has an event OnBeforeNavigate2 that fires before switching pages. The event handler receives the new visited URL.
If you use a CDHTMLView, you don't even have to add an event handler: Just override the virtual OnBeforeNavigate2().
The URL is sent to you in the DocumentComplete event. Check the MFCIE sample, the sample handles the event to update its address bar.
Note the url may be different from the one you passed to Navigate or get from OnBeforeNavigate2. For example if you pass microsoft.com to Navigate2, you will get www.microsoft.com back due to server side redirects.
MSDN has a section all about "Using MFC to Host a WebBrowser Control". In there it mentions using the following:
//CWebBrowser2 m_browser - to access the WebBrowser control
CString string1, string2;
string1 = m_browser.GetLocationName(); // gets the page title
string2 = m_browser.GetLocationURL(); // gets the page URL
Regarding when you try to get that information, you could check m_browser.Busy(...) or m_browser.ReadyState(...) to see if any kind of navigation/download is currently happening.
I confess to never using the control myself so don't know if there's a simple way to get a callback saying that the URL has changed, but the above link should give you most of the information you need. Hopefully :)

Multi-page application in Silverlight for Windows Embedded 7

I'm trying to develop an application in Silverlight for Windows Embedded 7, which uses C++.
I was able to run a simple page with a button, which calls another function (a simple Hello world message box).
The great question here is: how can I make a function display another page, defined in another XAML file? All the examples I found online, and even in Microsoft resources, uses a single XAML file with everything done inside it.
Thanks in advance!
I'm a student who is suffering from the same problem now. Hope there's someone to help us solve it.
I have searched and found that FRAME is not supported in the SWE.
I have found an alternative way to solve this problem but I'm not familiar with C++ code.
If you knows how to program in C++, would you please read through this and teach me a bit?
Thanks so much.
You can search for"Create a Custom User Control in Silverlight for Windows Embedded".
You'll found a PDF file released by Microsoft.
With this way you can create a custom user control to hold your "multi page".
I have done this step, and with the control I created, I am able to "hide" and "show" it in order to achieve the "multipage" effect.
In my User Control, I have some more buttons to let users to click. However, from the mainpage which hosting the user control, the buttons inside cannot be detect.
In the PDF tutorial they teach how do we call out the methods in the custom control, but I don't understand the C++ code.
If you can get the user control done make the controls in your custom control function correctly, would you please tell me? thank you.
To do multi-page applications, you need multiple xaml files. Not sure what the Microsoft tutorials you found were referencing, but i am developing an application now which has more than 20 different pages or screens. You need to design the layouts in XAML/ExpressionBlend and then using event handlers and pointers to the XAMl, implement the views in the C++ source code.
// ============================================================================
// LockDataLogger_Click
//
// Description: Event handler implementation
//
// Parameters: pSender - The dependency object that raised the click event.
// pArgs - Event specific arguments.
// ============================================================================
HRESULT MainPage::LockDataLogger_Click (IXRDependencyObject* pSender, XRMouseButtonEventArgs* pArgs)
{
HRESULT hr = E_NOTIMPL;
if ((NULL == pSender) || (NULL == pArgs))
{
hr = E_INVALIDARG;
}
//m_pDeviceSettings_Lang->m_pYear->Focus(false);
if(m_pDeviceSettings_Lang)
{
m_pDeviceSettings_Lang->m_pYear->SetIsDropDownOpen(false);
}
m_pLoginScreen->SetVisibility(XRVisibility_Visible);
m_pLogin_Password->SetPassword(L"");
m_pHome_LoginOptions->SetVisibility(XRVisibility_Collapsed);
return hr;
}
So this is an event handler implementation for when you clock the "Lock" button on the home screen of my device. All you need to do is name your different pages/menus accordingly and based on event handler implementations, using points, set/change the visibility of the different pages. Very straightforward and hope the example code provides some insight.

How do I setup a callback mechanism for RichEdit in win32

In win32, how do I setup a callback mechanism for RichEdit I have not created myself?
PART 1
I'm reading from a textedit field in another application's GUI. This works just fine now, except after the first read I'd like to fetch only new or modified lines. In GTK+ or Qt I'd just install a callback on some signal the field edits when its changed, but how does it work on Win32?
My MSDN searches result with nothing useful, probably because I don't know the exact term to search for. The class of the textedit is RichText20W, and it has some messages that are probably used somehow, though that article just discusses using them for the parent of the class.
PART 2
Also, if there is no such "text changed, here is the newly inserted text" callback which returns the new content immediately, I need some way to easily detect what is new. From top-of-my-head:
Have a marker at the end of the text block we've read, and only read between that and the end.
Store what we've read previously, and after a second read, remove the duplicate part from the latter to have the newly inserted stuff.
Option 2 might not be viable, since the textedit can contain any amount of text. The marker part sounds doable, but yet again, my feeble Win32 skills and horrible Win32 function names prevent me from finding the right way to do it.
Note that all these must be doable for a textedit I do not own and have not created, they belong to a third party process.
Code samples in C++ highly appreciated.
Disclaimer
Obviously, if there is some better way of doing it, let me know. I only assumed callback would be the way to go based on my previous experience with GTK+/Qt. Feel free to show me the path :)
Win32 controls don't work on message-specific callbacks that you can subscribe to. They just send messages to their parent window when something happens, in this case EN_UPDATE, EN_CHANGE and all that. Even these events don't tell you what text changed. They only tell you that it did change.
You could subclass the parent, but the documentation for SetWindowLongPtr explicitly says you "should not subclass a window class created by another process." Something like this is probably possible with hooks, but I haven't used them enough to say for certain how you'd actually do it.
I realize it's an old post, but this article seems to be doing something similar.
Based on Joel's answer, I quit looking for callbacks and just made a small class that hooks itself (not by a real API hook though) to the richedit and polls it once a second for content length, and if it has changed since the last poll, it asks for the content, compares that to previous known content and emits a signal with the changed content.
This seems to work OK for this purpose, but if someone knows a better way still (some real and tested way of doing it via API hooks or something), please post.