How to capture events fired from new Popup IE window - c++

Greetings!
Situation:
My ActiveX DLL contains a customized webbrowser. The webbrowser displays a web page. When user clicks the link within the displayed page, a new IE window pop up and navigate to the clicked link URL.
Question:
How can I capture the DocumenComplete and NavigateComplete events fired from the NEW pop up IE window?
What I already tried:
I tried to capture the
*NewWindow2(IDispatch **ppDisp,
VARIANT_BOOL Cancel)
event fired from customized webbrowser (not new IE window), and obtained the pointer ppDisp which points to the new IE windown. I tried to use this pointer as event source to advise or connect to the event handler (IDispatch::Invoke) for event capture. However it does not work. Maybe the failure is because the document in new IE window has not been loaded yet. I am not sure.
Can you please give me an suggestion what I should do?
Thanks!

You don't obtain the new web browser in ppDisp. You create one, sink events, and return its application property in ppDisp to the event.

void CYourDlg::OnNewWindow2(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel)
{
CDlgNewWB* dlgNewWB = new CYourDlg;
this.listDialogWeb.Add(dlgNewWB);
dlgNewWB ->Create(IDD_WBDLG_DIALOG);
dlgNewWB ->m_webBrowser.SetRegisterAsBrowser(TRUE);
*ppDisp = dlgNewWB ->m_webBrowser.GetApplication();
}

Related

Cant focus Firemonkey application when modal dialog open, unless modal dialog itself is clicked

I have an application in which users, upon logging in, are prompted with a modal dialog where they must choose the facility they wish to work out of. At this stage, the application looks like this:
The modal dialog is shown by calling this method:
bool __fastcall ShowFacChoiceForm()
{
TFacChoiceForm *Form = new TFacChoiceForm( Application );
bool Result = ( Form->ShowModal() == mrOk );
delete Form;
return Result;
}
In this case, TFacChoiceForm inherits from TForm so the ShowFacChoiceForm() function is calling the standard TForm.ShowModal method documented here.
The issue I am running into is that if my application loses focus, it cannot become the active window again unless the modal dialog itself is clicked. To better illustrate this, I will present the following scenario:
Lets say its Friday afternoon and I decide to goof off a bit and read some web comics. With my application open, I open up another window on top of it, like so:
Then, out of nowhere my boss comes in for a performance review, and I attempt to refocus my application by clicking somewhere on the main form. For example, at the position of this red X in the next image.
In the above image, I have clicked at the location of the red X. Now, both the form containing the web comic, and my application are inactive. Thus, my application does not come to the front of the screen.
However, if I am able to click somewhere on the modal dialog, like the red X in the following image...
...then my application comes to the front like one would expect.
To solve this, I have looked at using something like SetForegroundWindow from the Windows API, but I have not been able to find a way to trigger the event, since my main form does not fire events while I have a modal dialog open.
My question is, how can I make sure that if the user clicks anywhere on my application that it is brought to the front? Is there a property I can edit in my form to do this?
If you set modalresult to mrcancel in the ondeactivate of the modal dialog then the main form will get focus when its clicked. You can then check if the user is logged in the mousedown event of the main form and if not, show the modal dialog again.

An outgoing call cannot be made since the app is dispatching an input-synchronous call

I have a MFC application with a dialog that has an edit control for user input. When I set a value and click with the mouse outside the control on the dialog everything works fine and the viewer (other dialog inside the main dialog) updates correctly. When I set the value and click on the viewer the function
psink_interface->QueryInterface(
IID_IConnectionPointContainer,
(void**)&pIConnectionPointContainerTemp
);
returns an error HRESULT
http://i.stack.imgur.com/kLYNP.png
and the program gets an exception
http://i.stack.imgur.com/xvA7I.png
Can someone please help me with some guidance? Thank you in advance!

how to access the onload event by C++ bho

I have a problem in using the IWebBrowser. My project is that, when the user clicks button in the IE toolbar, a popup window (created by CreateWindow Method) is displayed. The popup window is used for displaying HTML. I use a new IWebBrowser point to display, not the point which set in the SetSite method. But I can't catch the load event from the popup window.
My bho extend IDispatch, and in the method Invoke, it can catch the load event from the website which opens in the browser not the popup window!
Is there any problem in my code? what can I do if I want to catch the load event?

Open response on new window

In Django, how can I get the response to be opened in a new window from the view?
if i do this, this will open the mynewpage.html in the original window
return HttpResponse('mynewpage')
I want to open mynewpage.html in a new window , separate from the originial.
Your server has no concept of windows - it just sends back files to the browser. You need to do this via javascript:
window.open('url to open','window name','attribute1,attribute2')
So you can either create a custom view and template whose job is to open a new window with a specified link, then return the main window to the page it was previously at, or simply open the url you want from the original window without contacting the server

asp repeater itemcommand not working on second click

I have a repeater which I bind the data using Bind method from the database. There is a Asp:Button with an onclientclick and onclick event. In OnClientClick I open a new window and onclick I am adding the data to the database. This works perfectly on the first Page load. After first click on any of the buttons in the repeater, the click events stops working on subsequent clicks.
I have spending hours on finding a solution for the same, can any one guide me where i am going wrong what needs to be done.
P.S: My application is AJAX Enabled , using WCF and JQUERY
Thanks & Regards,
Phani...
Never Mind I got it solved my self. For others who are trying to solve the same issue, here is the solution:
The code below opens up a new window with out popup blocker blocking the window
OnClientClick of the button write Javascript like below to open a new window and refresh the parent window (I have to do this as the ItemCommand event was not firing until the page is refreshed)
OnClientClick = "target='_blank'; setTimeout("location.reload(true);", timeout);
Phani...