combview.cpp
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 23k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. #include "shellprv.h"
  2. extern "C" {
  3. #include <regstr.h>
  4. #include <shellp.h>
  5. #include "ole2dup.h"
  6. #include "ids.h"
  7. #include "defview.h"
  8. #include "lvutil.h"
  9. #include "idlcomm.h"
  10. #include "filetbl.h"
  11. #include "undo.h"
  12. #include "vdate.h"
  13. } ;
  14. #include "cnctnpt.h"
  15. #include "mmhelper.h"
  16. #include "mshtml.h"
  17. #include <sfview.h>
  18. #include "sfviewp.h"
  19. #include "shellp.h"
  20. /*
  21.  * Defines and handy macros
  22.  */
  23. #define DM_DOCHOSTUIHANDLER DM_TRACE
  24. #define LISTVIEW_PROP   TEXT("CombView_listview_subclass")
  25. #define ISMOUSEDOWN(msg) ((msg) == WM_LBUTTONDOWN || (msg) == WM_RBUTTONDOWN || (msg) == WM_MBUTTONDOWN)
  26. #define HWNDLISTVIEW (g_pdsvlvp->pdsv->_hwndListview)
  27. #define CELEMENTS 10
  28. #define MAXELEMENTSIZE 10
  29. /*
  30.  * Type definitions
  31.  */
  32. typedef struct  {
  33.     WNDPROC    lpfnOldWndProc;
  34.     CDefView   *pdsv;
  35.     BOOL       fInPaint;
  36.     HHOOK      hHookMouse;
  37.     HHOOK      hHookGetMsg;
  38. } DVLVPROP;
  39. /*
  40.  * Global delarations
  41.  */
  42. //
  43. // We need this global (g_pdsvlvp) for the mouse hook we need to implement the combined
  44. // view.  Since we only have one combined view at this point it is sufficient to have
  45. // a single global, but if we end up with more than one combined view then
  46. // there needs to be some additional code added so the hook(s) can figure out
  47. // which combined view(s) it is associated with.
  48. // 
  49. DVLVPROP * g_pdsvlvp = NULL;
  50. const LPCTSTR c_rgElements[] = {   
  51.     TEXT("A"),
  52.     TEXT("ANCHOR"),   // ???
  53.     TEXT("PLUGINS"),  // ???
  54.     TEXT("APPLET"),
  55.     TEXT("EMBED"),
  56.     TEXT("FORM"),
  57.     TEXT("IFRAME"),
  58.     TEXT("BUTTON"),
  59.     TEXT("INPUT"),
  60.     TEXT("OBJECT") 
  61. };                              
  62. /*
  63.  * Prototypes for externs
  64.  */
  65. int DV_HitTest(CDefView *, const POINT *ppt);
  66. BOOL CombView_EnableAnimations(BOOL fEnable);
  67. // Returns the first sibling window of the passed in window
  68. HWND GetSpecialSibling(HWND hwnd)
  69. {
  70.     HWND hwndT = GetWindow(hwnd, GW_HWNDFIRST);
  71.     while (hwnd == hwndT)
  72.         hwndT = GetWindow(hwndT, GW_HWNDNEXT);
  73.     return hwndT;
  74. }
  75. LRESULT CALLBACK CombView_LV_SubclassProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
  76. {
  77.     DVLVPROP *pdsvlvp;
  78. #ifdef CRAZY_CODE
  79. #define MAGIC_TIMER 0x5343
  80. #define MAGIC_TIMEOUT 100
  81.     static HRGN hrgnSave = NULL;
  82.     static DWORD dwLastPaint;
  83. #endif
  84.     if (!(pdsvlvp = (DVLVPROP *)GetProp(hwnd, LISTVIEW_PROP)))
  85.         return 0;
  86.     if (!pdsvlvp->fInPaint && pdsvlvp->pdsv->_fCombinedView && (iMsg == WM_PAINT)) {
  87. #ifdef CRAZY_CODE
  88.         RECT rc;
  89.         if (!hrgnSave) {
  90.             HWND hwndT = GetSpecialSibling(hwnd);
  91.             hrgnSave = CreateRectRgn(0, 0, 0, 0);
  92.             if (hrgnSave) {
  93.                 pdsvlvp->fInPaint = TRUE;
  94.                 if (GetUpdateRect(hwndT, &rc, FALSE)) {
  95.                     GetWindowRgn(hwnd, hrgnSave);
  96.                     SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_TRANSPARENT);
  97.                     SetWindowRgn(hwnd, NULL, FALSE);
  98.                     InvalidateRect(hwndT, &rc, FALSE);
  99.                     UpdateWindow(hwndT);
  100.                     SetTimer(hwnd, MAGIC_TIMER, MAGIC_TIMEOUT, NULL);
  101.                 } else {
  102.                     DeleteObject(hrgnSave);
  103.                     hrgnSave = NULL;
  104.                 }
  105.                 pdsvlvp->fInPaint = FALSE;
  106.             }
  107.         }
  108.         dwLastPaint = GetTickCount();
  109. #else  // This code works well for general painting, like minimizing a window or
  110.        // or surfacing the desktop.  However, it doesn't help the drag full windows
  111.        // scenario very much.
  112.         HRGN hrgn, hrgn2;
  113.         RECT rc;
  114.         HWND hwndT = GetSpecialSibling(hwnd);
  115.         // Turn on animations!
  116.         CombView_EnableAnimations(TRUE);
  117.         if (hwndT && (hrgn = CreateRectRgn(0, 0, 0, 0))) {
  118.             if (hrgn2 = CreateRectRgn(0, 0, 0, 0)) {
  119.                 pdsvlvp->fInPaint = TRUE;
  120.                 if (!GetClassLongPtr(hwndT, GCLP_HBRBACKGROUND))
  121.                     SetClassLongPtr(hwndT, GCLP_HBRBACKGROUND, (LPARAM)GetStockObject(HOLLOW_BRUSH));
  122.                 if (GetUpdateRect(hwndT, &rc, FALSE)) {
  123.                     RECT rcLV = rc;
  124.                     MapWindowPoints(hwndT, hwnd, (LPPOINT)&rcLV, 2);
  125.                     SetRectRgn(hrgn2, rcLV.left, rcLV.top, rcLV.right, rcLV.bottom);
  126.                     GetWindowRgn(hwnd, hrgn);
  127.                     CombineRgn(hrgn2, hrgn, hrgn2, RGN_DIFF);
  128.                     SetWindowRgn(hwnd, hrgn2, FALSE);
  129.                     InvalidateRect(hwndT, &rc, FALSE);
  130.                     UpdateWindow(hwndT);
  131.                     SetWindowRgn(hwnd, hrgn, FALSE);
  132.                     InvalidateRect(hwnd, &rcLV, FALSE);
  133.                 } else {
  134.                     DeleteObject(hrgn);
  135.                     DeleteObject(hrgn2);
  136.                 }
  137.                 pdsvlvp->fInPaint = FALSE;
  138.             } else {
  139.                 DeleteObject(hrgn);
  140.             }
  141.         }
  142. #endif
  143.     }
  144. #ifdef CRAZY_CODE
  145.     if ((iMsg == WM_TIMER) && (wParam == MAGIC_TIMER) &&
  146.         ((GetTickCount() - dwLastPaint) > MAGIC_TIMEOUT)) {
  147.         if (hrgnSave) {
  148.             SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) & ~WS_EX_TRANSPARENT);
  149.             SetWindowRgn(hwnd, hrgnSave, FALSE);
  150.             hrgnSave = NULL;
  151.         }
  152.         KillTimer(hwnd, MAGIC_TIMER);
  153.     }
  154. #endif
  155.     return CallWindowProc(pdsvlvp->lpfnOldWndProc, hwnd, iMsg, wParam, lParam);
  156. }
  157. // We need to set capture while we are stealing the mouse so that the
  158. // window manager won't send WM_SETCURSOR messages to the wrong window.
  159. // This function will also, as a side effect, send the WM_SETCURSOR to the
  160. // listview so that it will set the hand cursor when it needs to.
  161. void StealMouse(DVLVPROP * pdvlvp, BOOL fSteal, UINT msg)
  162. {
  163.     HWND hwndCapture = GetCapture();
  164.     if (fSteal && (hwndCapture == NULL || hwndCapture == HWNDLISTVIEW)) {
  165.         // We need to set capture so that the window manager will not
  166.         // try to send the wm_setcursor message to the wrong window, and we
  167.         // send it here ourself to the listview.
  168.         SetCapture(HWNDLISTVIEW);
  169.         SendMessage(HWNDLISTVIEW, WM_SETCURSOR, (WPARAM)HWNDLISTVIEW,
  170.             MAKELPARAM(HTCLIENT, LOWORD(msg)));
  171.     } else {
  172.         // If the listview still has capture release it now
  173.         if (HWNDLISTVIEW == hwndCapture)
  174.             ReleaseCapture();
  175.     }
  176. }
  177. LRESULT CALLBACK CombView_GetMsgHook (int nCode, WPARAM wParam, LPARAM lParam)
  178. {
  179.     #define LPMSG ((LPMSG)lParam)
  180.     HHOOK hHookNext = NULL;
  181.     if (g_pdsvlvp) {
  182.         if (LPMSG->message >= WM_MOUSEFIRST && LPMSG->message <= WM_MOUSELAST) {
  183.             POINT pt;
  184.             int iHit;
  185.             pt.x = GET_X_LPARAM(LPMSG->lParam);
  186.             pt.y = GET_Y_LPARAM(LPMSG->lParam);
  187.             MapWindowPoints(LPMSG->hwnd, HWNDLISTVIEW, &pt, 1);
  188.             iHit = DV_HitTest(g_pdsvlvp->pdsv, &pt);
  189.             // Unhook our hook when all of the mouse buttons are up and we're not over
  190.             // an item in the listview
  191.             if (GetKeyState(VK_LBUTTON) >= 0 &&
  192.                 GetKeyState(VK_RBUTTON) >= 0 &&
  193.                 GetKeyState(VK_MBUTTON) >= 0 &&
  194.                 iHit == -1) {
  195.                 UnhookWindowsHookEx(g_pdsvlvp->hHookGetMsg);
  196.                 g_pdsvlvp->hHookGetMsg = NULL;
  197.             } else {
  198.                 hHookNext = g_pdsvlvp->hHookGetMsg;
  199.             }
  200.                        
  201.             if (IsChildOrSelf(GetSpecialSibling(HWNDLISTVIEW), LPMSG->hwnd) == S_OK) {
  202.                 // If we have grabbed the mouse, give it to the listview
  203.                 LPMSG->hwnd = HWNDLISTVIEW;
  204.                 LPMSG->lParam = MAKELPARAM(LOWORD(pt.x), LOWORD(pt.y));
  205.             }
  206.         } else {
  207.             hHookNext = g_pdsvlvp->hHookGetMsg;
  208.         }
  209.         // If we've just unhooked, or the hover is coming through to the listview and
  210.         // no mouse button is down then clear our ownership of the mouse
  211.         #define MK_BUTTON (MK_LBUTTON | MK_RBUTTON | MK_MBUTTON)
  212.         if (!hHookNext ||
  213.             // We need to special case the WM_MOUSEHOVER here so that the listview
  214.             // is able to implement hover select.  If we have capture set when the
  215.             // hover select message goes through then it will ignore the message, so
  216.             // clear the capture now.
  217.             (LPMSG->message == WM_MOUSEHOVER && LPMSG->hwnd == HWNDLISTVIEW && !(LPMSG->wParam & MK_BUTTON)))
  218.             StealMouse(g_pdsvlvp, FALSE, 0);
  219.     }
  220.     if (hHookNext)
  221.         CallNextHookEx(hHookNext, nCode, wParam, lParam);
  222.     return 0;
  223.     #undef LPMSG
  224. }
  225. BOOL DoesElementNeedMouse (LPTSTR psz)
  226. {
  227.     for (int i = 0; i < ARRAYSIZE(c_rgElements); i++) {
  228.         if (lstrcmpi(c_rgElements[i], psz) == 0)
  229.             return TRUE;
  230.     }
  231.     return FALSE;
  232. }
  233. BOOL ShouldStealMouseClick(POINT * ppt, DVLVPROP * pdsvlvp)
  234. {
  235.     IHTMLDocument2 *pihtmldoc2;
  236.     IHTMLElement *pielem;
  237.     HRESULT hr = E_FAIL;
  238.     if (SUCCEEDED(pdsvlvp->pdsv->GetItemObject(SVGIO_BACKGROUND, IID_IHTMLDocument2, (LPVOID*)&pihtmldoc2))) {
  239.         // BUGBUG (reinerf)
  240.         // elementFromPoint is returning success here even though pielem is
  241.         // still NULL, so we need to EVAL it until trident fixes this
  242.         if (SUCCEEDED(pihtmldoc2->elementFromPoint(ppt->x, ppt->y, &pielem)) && pielem) {
  243.             IHTMLElement *pielemT;
  244.             do {
  245.                 BSTR bstr = NULL;
  246.                 TCHAR sz[MAX_PATH];
  247.                 pielem->get_tagName(&bstr);
  248.                 SHUnicodeToTChar(bstr, sz, ARRAYSIZE(sz));
  249.                 SysFreeString(bstr);
  250.                 if (DoesElementNeedMouse(sz)) {
  251.                     hr = E_FAIL;
  252.                 } else {
  253.                     if (SUCCEEDED(hr = pielem->get_parentElement(&pielemT))) {
  254.                         pielem->Release();
  255.                         pielem = pielemT;
  256.                     } else {
  257.                         hr = S_OK;
  258.                         pielem->Release();
  259.                         pielem = NULL;
  260.                     }
  261.                 }
  262.             } while (SUCCEEDED(hr) && pielem);
  263.             if (pielem)
  264.                 pielem->Release();
  265.         }
  266.         pihtmldoc2->Release();
  267.     }
  268.     return SUCCEEDED(hr);
  269. }
  270. LRESULT CALLBACK CombView_MouseHook (int nCode, WPARAM wParam, LPARAM lParam)
  271. {
  272.     #define PMHS ((MOUSEHOOKSTRUCT *)lParam)
  273.     if ((nCode == HC_ACTION) && g_pdsvlvp && (PMHS->hwnd != HWNDLISTVIEW) && IsWindowVisible(HWNDLISTVIEW)) {
  274.         // If it isn't over the listview and the button is going down or we're
  275.         // moving over an area that would hit a listview icon then
  276.         // we need to start hooking mouse events.  Install the GetMessage hook
  277.         // so that we can do what we need to do.
  278.         HWND hwndParent = GetSpecialSibling(HWNDLISTVIEW);
  279.         HWND hwndHittest;
  280.         POINT ptLV = PMHS->pt;
  281.         int iHit;
  282.         BOOL fStealMouse;
  283.         hwndHittest = WindowFromPoint(PMHS->pt);
  284.         ScreenToClient(HWNDLISTVIEW, &ptLV);
  285.         iHit = DV_HitTest(g_pdsvlvp->pdsv, &ptLV);
  286.         ScreenToClient(hwndParent, &(PMHS->pt));
  287.         fStealMouse = (ISMOUSEDOWN(wParam) && ShouldStealMouseClick(&(PMHS->pt), g_pdsvlvp)) ||
  288.                       (!GetCapture() && (iHit != -1) && (!hwndHittest || (hwndHittest == HWNDLISTVIEW)));
  289.         if (!g_pdsvlvp->hHookGetMsg) {
  290.             if (hwndHittest && (IsChildOrSelf(hwndParent, hwndHittest) == S_OK)) {
  291.                 if (fStealMouse) {
  292.                     // Note:  We have to steal the mouse at this point and use the
  293.                     // GetMessage hook to redirect the mouse messages to our listview
  294.                     // window.  If we do something different like swallow the message here
  295.                     // and then PostMessage faked up events to the listview then all
  296.                     // of the hover select functionality will break because the system
  297.                     // won't detect the mouse as being over the listview.
  298.                     StealMouse(g_pdsvlvp, TRUE, (UINT) wParam);
  299.                     g_pdsvlvp->hHookGetMsg = SetWindowsHookEx(WH_GETMESSAGE, CombView_GetMsgHook,
  300.                                                 NULL, GetCurrentThreadId());
  301.                 }
  302.             }                                          
  303.         } else {
  304.             if (fStealMouse) 
  305.                 StealMouse(g_pdsvlvp, TRUE, (UINT) wParam);
  306.             else
  307.                 SendMessage(HWNDLISTVIEW, WM_SETCURSOR, (WPARAM)HWNDLISTVIEW, MAKELPARAM(HTCLIENT, LOWORD((UINT) wParam)));
  308.         }
  309.     }
  310.     if (g_pdsvlvp)
  311.         return CallNextHookEx(g_pdsvlvp->hHookMouse, nCode, wParam, lParam);
  312.     else
  313.         return 0;
  314.     #undef PMHS
  315. }
  316. /*
  317.  * EnableCombinedView
  318.  *
  319.  * This is the main entry point where a defview can be turned into a combined
  320.  * view.  The effect of a combined view is to layer an extended view under
  321.  * the listview icons (via a regional listview) of a normal defview.
  322.  *
  323.  * Warnings:
  324.  * 1) This is currently only used by the "Active Desktop", it is optimized
  325.  * to only support one instance.  Multiple combined views are not currently supported.
  326.  * 2) Disabling the combined view doesn't completely unhook itself from the defview
  327.  */
  328. void EnableCombinedView(CDefView *pdsv, BOOL fEnable)
  329. {
  330.     DVLVPROP * pdsvlvp;
  331.     pdsvlvp = (DVLVPROP *)GetProp(pdsv->_hwndListview, LISTVIEW_PROP);
  332.     if (pdsvlvp) {
  333.         if (!fEnable) {
  334.             // We are only expecting one combined view
  335.             ASSERT(g_pdsvlvp == pdsvlvp);
  336.             // Unhook ourselves
  337.             UnhookWindowsHookEx(pdsvlvp->hHookMouse);
  338.             if (pdsvlvp->hHookGetMsg) {
  339.                 UnhookWindowsHookEx(pdsvlvp->hHookGetMsg);
  340.                 StealMouse(pdsvlvp, FALSE, 0);
  341.             }
  342.             g_pdsvlvp = NULL;
  343.             RemoveProp(pdsv->_hwndListview, LISTVIEW_PROP);
  344.             LocalFree((HLOCAL)pdsvlvp);
  345.         }
  346.     } else {
  347.         if (fEnable) {
  348.             if ((pdsvlvp = (DVLVPROP *)LocalAlloc(LPTR, SIZEOF(DVLVPROP)))) {
  349.                 // We are only expecting one combined view
  350.                 ASSERT(g_pdsvlvp == NULL);
  351.                 // Get ourself hooked in
  352.                 pdsvlvp->pdsv = pdsv;
  353.                 pdsvlvp->lpfnOldWndProc = (WNDPROC)SetWindowLongPtr(pdsv->_hwndListview, GWLP_WNDPROC, (LONG_PTR)CombView_LV_SubclassProc);
  354.                 SetProp(pdsv->_hwndListview, LISTVIEW_PROP, (HANDLE)pdsvlvp);
  355.                 pdsvlvp->hHookMouse = SetWindowsHookEx(WH_MOUSE, CombView_MouseHook, NULL, GetCurrentThreadId());
  356.                 g_pdsvlvp = pdsvlvp;
  357.             }
  358.         }
  359.     }
  360. }
  361. /*
  362.  * CombView_EnableAnimations
  363.  *
  364.  * This function is used to optimize the combined view ("Active Desktop") by turning
  365.  * off any animated html elements or embeddings when it is completely obscured.
  366.  *
  367.  * Note that we always honor enabling animations if they aren't already enabled. 
  368.  * To make the client code easier though we only disable animations if we know
  369.  * the desktop is obscured.
  370.  *
  371.  * Returns: The state of animation after the call
  372.  */
  373. BOOL CombView_EnableAnimations(BOOL fEnable)
  374. {
  375.     static BOOL fEnabled = TRUE;
  376.     if ((fEnable != fEnabled) && g_pdsvlvp)
  377.     {
  378.         IOleCommandTarget* pct;
  379.         BOOL fChangeAnimationState = fEnable;
  380.         if (!fEnable)
  381.         {
  382.             HDC hdc;
  383.             RECT rc;
  384.             HWND hwnd;
  385.             if ((hwnd = GetSpecialSibling(HWNDLISTVIEW)) && (hdc = GetDC(hwnd)))
  386.             {
  387.                 fChangeAnimationState = (GetClipBox(hdc, &rc) == NULLREGION);
  388.                 ReleaseDC(hwnd, hdc);
  389.             }
  390.         }
  391.         if (fChangeAnimationState &&
  392.             SUCCEEDED(g_pdsvlvp->pdsv->_psb->QueryInterface(IID_IOleCommandTarget, (LPVOID*)&pct)))
  393.         {
  394.             VARIANT var = { 0 };
  395.             TraceMsg(DM_TRACE, "Active Desktop: Animation state is changing:%d", fEnable);
  396.             var.vt = VT_I4;
  397.             var.lVal = fEnable;
  398.             pct->Exec(NULL, OLECMDID_ENABLE_INTERACTION, OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
  399.             pct->Release();
  400.             fEnabled = fEnable;
  401.         }
  402.     }
  403.     return fEnabled;
  404. }
  405. /*
  406.  * IDocHostUIHandler implementation
  407.  *
  408.  * This is implemented by the combined view so that we can support various
  409.  * Win95 desktop functionality in a compatible way in the extended view.
  410.  * Some examples include picking off context menu invocations, configuring the
  411.  * host to display the way we want it too, and modifying drag/drop behavior.
  412.  */
  413. HRESULT CSFVSite::ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
  414. {
  415.     DebugMsg(DM_DOCHOSTUIHANDLER, TEXT("CSFVS::ShowContextMenu called"));
  416.     CSFVFrame* pFrame = IToClass(CSFVFrame, m_cSite, this);
  417.     CDefView* pView = IToClass(CDefView, m_cFrame, pFrame);
  418.     // For Web View's w/o DVOC, it might be nice to let Trident's menu through...
  419.     if ((dwID == CONTEXT_MENU_DEFAULT || dwID == CONTEXT_MENU_IMAGE) && pView->_hwndListview) {
  420.         // we used to unselect everything first, but that's bogus because it breaks the app key trying
  421.         // to get a context menu on the currently selected items
  422.         
  423.         // BOGUS - Trident blows up if we send the message here and the user
  424.         // turns off webview.  Post it for now.
  425.         PostMessage(pView->_hwndListview, WM_CONTEXTMENU,
  426.             (WPARAM)pView->_hwndListview, MAKELPARAM((short)LOWORD(ppt->x), (short)LOWORD(ppt->y)));
  427.         return S_OK;
  428.     } else {
  429.         return S_FALSE;
  430.     }
  431. }
  432. HRESULT CSFVSite::GetHostInfo(DOCHOSTUIINFO *pInfo)
  433. {
  434.     CSFVFrame* pFrame = IToClass(CSFVFrame, m_cSite, this);
  435.     CDefView* pView = IToClass(CDefView, m_cFrame, pFrame);
  436.     DebugMsg(DM_DOCHOSTUIHANDLER, TEXT("CSFVS::GetHostInfo called"));
  437. #if 0 // BUGBUG - Trident currently doesn't initialize the size field!
  438.     if (pInfo->cbSize < SIZEOF(DOCHOSTUIINFO)) {
  439.         return E_INVALIDARG;
  440.     }
  441. #endif
  442.     pInfo->cbSize = SIZEOF(DOCHOSTUIINFO);
  443.     if (pView->_fCombinedView)
  444.     {
  445.         pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU |  // We don't want Trident's help
  446.                          DOCHOSTUIFLAG_NO3DBORDER |         // Desktop should be borderless
  447.                          DOCHOSTUIFLAG_SCROLL_NO; // |          // Desktop should never scroll
  448.                          // DOCHOSTUIFLAG_DIALOG;              // Prevent selection in Trident
  449.     }
  450.     else
  451.     {
  452.         pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU |
  453.                          DOCHOSTUIFLAG_DIALOG |
  454.                          DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE;
  455.     }
  456.     if (SHIsLowMemoryMachine(ILMM_IE4))
  457.         pInfo->dwFlags = pInfo->dwFlags | DOCHOSTUIFLAG_DISABLE_OFFSCREEN;
  458.     
  459.     pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;     // default
  460.     return S_OK;
  461. }
  462. HRESULT CSFVSite::ShowUI( 
  463.     DWORD dwID, IOleInPlaceActiveObject *pActiveObject,
  464.     IOleCommandTarget *pCommandTarget, IOleInPlaceFrame *pFrame,
  465.     IOleInPlaceUIWindow *pDoc)
  466. {
  467.     DebugMsg(DM_DOCHOSTUIHANDLER, TEXT("CSFVS::ShowUI called"));
  468.     // Host did not display its own UI. Trident will proceed to display its own. 
  469.     return S_OK;
  470. }
  471. HRESULT CSFVSite::HideUI(void)
  472. {
  473.     DebugMsg(DM_DOCHOSTUIHANDLER, TEXT("CSFVS::HideUI called"));
  474.     // This one is paired with ShowUI
  475.     return S_FALSE;
  476. }
  477. HRESULT CSFVSite::UpdateUI(void)
  478. {
  479.     DebugMsg(DM_DOCHOSTUIHANDLER, TEXT("CSFVS::UpdateUI called"));
  480.     // LATER: Isn't this equivalent to OLECMDID_UPDATECOMMANDS?
  481.     return S_FALSE;
  482. }
  483. HRESULT CSFVSite::EnableModeless(BOOL fEnable)
  484. {
  485.     DebugMsg(DM_DOCHOSTUIHANDLER, TEXT("CSFVS::EnableModeless called"));
  486.     // Called from the Trident when the equivalent member of its
  487.     // IOleInPlaceActiveObject is called by the frame. We don't care
  488.     // those cases.
  489.     return S_OK;
  490. }
  491. HRESULT CSFVSite::OnDocWindowActivate(BOOL fActivate)
  492. {
  493.     // Called from the Trident when the equivalent member of its
  494.     // IOleInPlaceActiveObject is called by the frame. We don't care
  495.     // those cases.
  496.     return S_OK;
  497. }
  498. HRESULT CSFVSite::OnFrameWindowActivate(BOOL fActivate)
  499. {
  500.     // Called from the Trident when the equivalent member of its
  501.     // IOleInPlaceActiveObject is called by the frame. We don't care
  502.     // those cases.
  503.     return S_OK;
  504. }
  505. HRESULT CSFVSite::ResizeBorder( 
  506. LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
  507. {
  508.     // Called from the Trident when the equivalent member of its
  509.     // IOleInPlaceActiveObject is called by the frame. We don't care
  510.     // those cases.
  511.     return S_OK;
  512. }
  513. HRESULT CSFVSite::TranslateAccelerator( 
  514. LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
  515. {
  516.     // Called from the Trident when the equivalent member of its
  517.     // IOleInPlaceActiveObject is called by the frame.
  518.     // Trap F5 alone and handle the refresh ourselves!
  519.     // Note:This code-path will be hit for desktop only if the active desktop
  520.     // is turned on.
  521.     //
  522.     // And probably if focus is on Trident. It's probably good to
  523.     // pick this off for Web View too.
  524.     //
  525.     if((lpMsg->message == WM_KEYDOWN) && (lpMsg->wParam == VK_F5))
  526.     {
  527.         CSFVFrame* pFrame = IToClass(CSFVFrame, m_cSite, this);
  528.         CDefView* pView = IToClass(CDefView, m_cFrame, pFrame);
  529.         pView->Refresh();
  530.         return S_OK;
  531.     }
  532.     return S_FALSE; // The message was not translated
  533. }
  534. HRESULT CSFVSite::GetOptionKeyPath(BSTR *pbstrKey, DWORD dw)
  535. {
  536.     // Trident will default to its own user options.
  537.     *pbstrKey = NULL;
  538.     return S_FALSE;
  539. }
  540. HRESULT CSFVSite::GetDropTarget( 
  541. IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
  542. {
  543.     DebugMsg(DM_DOCHOSTUIHANDLER, TEXT("CDOH::GetDropTarget called"));
  544.     HRESULT hres = S_OK;
  545.     if (_dt._pdtDoc) {
  546.         _dt._pdtDoc->Release();
  547.         _dt._pdtDoc = NULL;
  548.     }
  549.     if (pDropTarget) {
  550.         if (_dt._pdtFrame == NULL) {
  551.             CSFVFrame* pFrame = IToClass(CSFVFrame, m_cSite, this);
  552.             CDefView* pView = IToClass(CDefView, m_cFrame, pFrame);
  553.             pView->_psb->QueryInterface(IID_IDropTarget, (LPVOID*)&_dt._pdtFrame);
  554.         }
  555.         if (_dt._pdtFrame) {
  556.             _dt._pdtDoc = pDropTarget;
  557.             pDropTarget->AddRef();
  558.     
  559.             *ppDropTarget = &_dt;
  560.             AddRef();
  561.             DebugMsg(DM_DOCHOSTUIHANDLER, TEXT("CDOH::GetDropTarget returning S_OK"));
  562.             ASSERT(hres == S_OK);
  563.         } else {
  564.             ASSERT(0);
  565.             hres = E_UNEXPECTED;
  566.         }
  567.     } else {
  568.         hres = E_INVALIDARG;
  569.     }
  570.     return hres;
  571. }
  572. HRESULT CSFVSite::GetExternal(IDispatch **ppDisp)
  573. {
  574.     TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::GetExternal called");
  575.     HRESULT hr;
  576.     if (ppDisp)
  577.     {
  578.         *ppDisp = NULL;
  579.         hr = S_OK;
  580.     }
  581.     else
  582.     {
  583.         hr = E_INVALIDARG;
  584.     }
  585.     return hr;
  586. }
  587. HRESULT CSFVSite::TranslateUrl(DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
  588. {
  589.     TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::TranslateUrl called");
  590.     HRESULT hr;
  591.     if (ppchURLOut)
  592.     {
  593.         *ppchURLOut = NULL;
  594.         hr = S_OK;
  595.     }
  596.     else
  597.     {
  598.         hr = E_INVALIDARG;
  599.     }
  600.     return hr;
  601. }
  602. HRESULT CSFVSite::FilterDataObject(IDataObject *pDO, IDataObject **ppDORet)
  603. {
  604.     TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::FilterDataObject called");
  605.     HRESULT hr;
  606.     if (ppDORet)
  607.     {
  608.         *ppDORet = NULL;
  609.         hr = S_OK;
  610.     }
  611.     else
  612.     {
  613.         hr = E_INVALIDARG;
  614.     }
  615.     return hr;
  616. }