on CoUnmarshalInterface

CoUnmarshalInterface() and CoGetInterfaceAndReleaseStream() are not re-entrancy safe.  This has certain implications for objects that attempt to unmarshal interfaces into member variables, as a member of my team recently discovered. Suppose you have something that looks like this: class MyObject {public:    MyObject() { _pUnk = NULL; }    HRESULT DoStuff(IStream *pStream)   {      …       hr = CoUnmarshalInterface(pStream, IID_IUnknown,…

0

pop-up blocker and ActiveX controls, part one: IWebBrowser::Navigate(), IWebBrowser::Navigate2()

As I mentioned previously, one reason users may continue to experience unwanted pop-up windows while browsing is creative use of ActiveX controls that provide methods that allow web sites to open new browser windows.  This series of posts will provide best-practices for ActiveX control implementors. There are two things to keep in mind while considering…

8

IOleCommandTarget, CGID_MSHTML and ActiveX controls

If you write an application that hosts the WebBrowser Control, and you want the control to do something, you can send commands to mshtml via the IOleCommandTarget interface. However, if you are an ActiveX control and you want to send CGID_MSHTML commands, you may try something like this:     …    IOleCommandTarget *pCommandTarget = NULL;    hr…

6

on getting IOleCommandTarget wrong (and a bit in the middle about ActiveX controls)

IOleCommandTarget is very useful.  It provides a generic way of sending commands between objects.  IE makes extensive use of IOleCommandTarget, both publically and internally.  And, like IUnknown, people frequently get it wrong. Each command is composed of a GUID (Command Group Identifier) and a DWORD (Command Identifier).  First, what is wrong with this code: HRESULT CFoo::Exec(const GUID…

7

on 64 bit data conversion, comctl32 and reading the documentation

Question: What is wrong with this code? case WM_DRAWITEM:{   LPDRAWITEMSTRUCT pdis = (LPDRAWITEMSTRUCT) lParam;   COMBOBOXEXITEM cbexItem = {0};   cbexItem.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;   cbexItem.iItem = pdis->itemID;    CallWindowProc(pfnOldWndProc, hwnd, CBEM_GETITEM, 0, (LPARAM)&cbexItem);   …} Answer: It will break on 64 bit machines. This is just one example of a well-known issue.  ComboBoxEx makes frequent use of -1 when asking for the item…

0

on IObjectWithSite, IOleObject and ActiveX controls

ActiveX® controls frequently need to communicate with their containing object.  For example, a control may want to QueryService for the cached InternetSecurityManager object to decide whether or not to take a particular action.  Controls can obtain a pointer to their containing object (also called the object’s site) in one of at least two ways.  The…

6

the importance of context

Almost every navigation in Internet Explorer results in a flurry of security checks.  Many of these checks are fairly obvious things, such as checking the URL of the current location (the context URL) and the pending navigation’s destination URL to see if their zones/domains/protocols/etc are the same/different/acceptable/etc.  Much of my time recently has been spent…

8

on calling refresh during onResize

From time to time I have come across web sites that do something like this: <body onResize=“document.execCommand(‘Refresh’)”> … </body> Generally this is done so the page can redo all of the necessary layout calculations for the new size it is being constrained to.  This leads to a lot of useless page reloads as the user…

3

a brief history of setHomePage()

I started working on IE right after IE 5.5 shipped.  Since then, there is one little feature which has been the subject of my loving attention from time to time– setHomePage(). setHomePage() is implemented as a behavior in iepeers.dll.  It takes one argument– the URL you would like to prompt the user to set as…

14

channel 9

If you have not had a chance to check out channel 9, click on over. 

1