I am using IWebBrowser2 interface for rendering an IE page inside a window. I need to show the windows to the user once every thing is rendered. Now I am using DocumentComplete event, to call ShowWindow function. But the actual content shows after an initial grey screen followed by a white screen delay. I need to be able to show the window to the user avoiding these screens.
Any help is appreciated.
You need to hook up the DWebBrowserEvents event sink. This sends a DocumentComplete notification that should be a good hint that the document is ready to be displayed.
To do this, first implement DWebBrowserEvents2 as an IDispatch based object. Then query the WebBrowser object for its IConectionPointContainter interface. Ask that via FindconnectionPoint for the IConnectionPoint interface for DIID_DWebBrowserEvents2, and then call Advise on that, passing your implementation of this dispatch interface.
Related
Iam trying to automate a process in a little game which uses Internet Explorer_Server windows with links as "buttons".
I managed to get the handle of the window and also got the html code from it but now I struggle to send a "click" or Mousebuttonpressed event to the links. I would appreciate any help with this.
You cannot send mouse input directly to the inner controls of an IE window. What you can do instead is start with the HWND of the "Internet Explorer_Server" window, ask it for its IHTMLDocument2 interface (see here for details), and then use Internet Explorer's own DOM interfaces to find the link elements as needed and call their click() method directly.
I have a CPropertySheet instance which is initialized using DoModal() in one of the methods of my CDocument class, in an MDI MFC application
My problem is I would like to refresh the view associated with the document from the sheet without ending the DoModal().
How do I get an handle back to the CDocument from my CPropertySheet so I can manipulated the CView easily ?
I have tried different things from this MSDN article but I am not able to retrieve what I want http://msdn.microsoft.com/en-us/library/bs315d2c.aspx
Thanks a lot.
You can use the SendMessage or PostMessage to the target window. Do this when the apply button is clicked.
Refer: http://cppandmfc.blogspot.com/2012/08/mfc-creating-and-using-property-page.html
You will get a Nice idea from that writeup
How do you create a window that is attached to the side of parent window opens like a drawer?
In such a way that you don't lose focus of parent window.
What you basically need to do is create yourself a custom control representing your drawer. I'm not sure if that's something you're familiar with or not, but if not there are plenty of tutorials about, such as this one.
I imagine what you'd do is designate part of your control to be the "handle", which if clicked upon "opens" the drawer. You would achieve this by handling the WM_LBUTTONDOWN/WM_LBUTTONUP messages in your control's window procedure, and changing its size from its closed size to its open size when clicks are detected. I haven't used it before, but you might be able to simply achieve animation using AnimateWindow.
You'd probably also want to have your control send it's parent window a notification whenever it is opened or closed, so that your parent window can re-size or move other controls if necessary. You can achieve this by sending a WM_NOTIFY message to the parent window with your own notification code, or using your own custom message. Your parent window would then have to respond to such messages in its window procedure.
As far as I'm aware there's no specific examples to be found addressing your exact requirements, so I probably can't supply much more info at the moment. If there's anything else in particular you need to know to get this running, don't hesitate to ask.
I want to make a custom made component (a line chart), that would be used in other applications.
I don't know 2 things:
Where should I use (within component class!) the methods for drawing, like FillRect
or PolyLine? In OnPaint handler that I should define and map it in MESSAGE MAP? Will
it (OnPaint handler) be called from OnPaint handler of the dialog of the application
or where from?
How to connect the component, once it is made, to the test application, which will
for example be dialog based? Where should I instantiate that component? From an
OnCreate method of the MyAppDialog.cpp?
I started coding in MFC few days ago and I'm so confused about it.
Thanks in advance,
Cheers.
Painting the control is handled exactly like it would be if it wasn't a control. Given that you're using MFC, that (at least normally) means you do the drawing in the View class' OnDraw (MFC normally handles OnPaint internally, so you rarely touch it).
Inserting the resulting ActiveX control in the host application will be done like inserting any other ActiveX control. Assuming you're doing your development in Visual Studio, you'll normally do that by opening the dialog, right clicking inside the dialog box, and clicking "Insert ActiveX Control..." in the menu that pops up. Pick your control from the list, and it'll generate a wrapper class for the control and code to create an object of that class as needed. From the viewpoint of the dialog code, it's just there, and you can use it about like any other control.
For create new component in MFC, you must create a class from the window class (CWND),
after that you can have your MessageMap for the component and your methods and also can override CWND::OnDraw method to draw the thing you want.
Before that I suggest you to take a look to device context
http://msdn.microsoft.com/en-us/library/azz5wt61(VS.80).aspx
Good Luck friend.
I have a class derived from CDockablePane. I need to do something when the view is focused, so I handle WM_SETFOCUS and it all works nicely most of the time.
But when the pane is docked in Tabbed Document mode (TDI), and the user activates it, the WM_SETFOCUS is not called.
I used Spy and noticed the WM_MDIACTIVATE message is sent to the pane's parent window.
However if I handle WM_MDIACTIVATE inside the pane or inside the mainframe, it does not get called either.
Any ideas what I need to handle?
You may need to inherit the frame class and trigger the sending of a custom message to your views when WM_MDIACTIVATE is received by the frame.