📄 view.cpp
字号:
/*****************************************************************************\
FUNCTION: _OnInvokeLoginAs
DESCRIPTION:
PARAMETERS:
\*****************************************************************************/
HRESULT CFtpView::_OnInvokeLoginAs(HWND hwndOwner)
{
ASSERT(m_pff);
return LoginAsViaFolder(hwndOwner, m_pff, m_psfv);
}
/*****************************************************************************\
FUNCTION: _OnInvokeNewFolder
DESCRIPTION:
PARAMETERS:
\*****************************************************************************/
HRESULT CFtpView::_OnInvokeNewFolder(HWND hwndOwner)
{
POINT pt = {0,0};
return CreateNewFolder(hwndOwner, m_pff, NULL, m_psfv, FALSE, pt);
}
/*****************************************************************************\
FUNCTION: _OnInvokeCommand
DESCRIPTION:
_UNDOCUMENTED_: This callback and its parameters are not documented.
_UNDOCUMENTED_: ShellFolderView_ReArrange is not documented.
PARAMETERS:
idc - Command being invoked
\*****************************************************************************/
HRESULT CFtpView::_OnInvokeCommand(UINT idc)
{
HRESULT hr = S_OK;
switch (idc)
{
case IDM_SORTBYNAME:
case IDM_SORTBYSIZE:
case IDM_SORTBYTYPE:
case IDM_SORTBYDATE:
ShellFolderView_ReArrange(m_hwndOwner, CONVERT_IDMID_TO_COLNAME(idc));
break;
case IDC_ITEM_ABOUTSITE:
_ShowMotdPsf(m_hwndOwner);
break;
case IDC_ITEM_FTPHELP:
_OnInvokeFtpHelp(m_hwndOwner);
break;
case IDC_LOGIN_AS:
_OnInvokeLoginAs(m_hwndOwner);
break;
case IDC_ITEM_NEWFOLDER:
_OnInvokeNewFolder(m_hwndOwner);
break;
#ifdef ADD_ABOUTBOX
case IDC_ITEM_ABOUTFTP:
hr = DisplayAboutBox(m_hwndOwner);
break;
#endif // ADD_ABOUTBOX
default:
ASSERT(0);
hr = E_NOTIMPL;
break;
}
return hr;
}
/*****************************************************************************\
FUNCTION: _OnGetHelpText
DESCRIPTION:
The shell want's the Help Text but they want it in their format (Ansi
vs. Unicode).
\*****************************************************************************/
HRESULT CFtpView::_OnGetHelpText(LPARAM lParam, WPARAM wParam)
{
HRESULT hres = E_FAIL;
UINT uiID = IDS_ITEM_HELP(LOWORD(wParam));
TCHAR szHelpText[MAX_PATH];
LPWSTR pwzHelpTextOut = (LPWSTR) lParam; // Only one of these is correct and fUnicodeShell indicates which one.
LPSTR pszHelpTextOut = (LPSTR) lParam;
pwzHelpTextOut[0] = L'\0'; // Terminate string. (Ok if it's ANSI)
szHelpText[0] = TEXT('\0');
// This will fail for some items that the shell will provide for us.
// These include View.ArrangeIcon.AutoArrange.
// BUGBUG: This currently doesn't work for everything in the View.ArrangeIcon
// menu except AutoArrange because uiID is 30-33,
// not 40-43 (IDS_HEADER_HELP(COL_NAME) - IDS_HEADER_HELP(COL_MODIFIED)).
// This will require changing the resource IDs but that will screw up
// the localizers and require changing IDS_HEADER_NAME().
if (LoadString(HINST_THISDLL, uiID, szHelpText, ARRAYSIZE(szHelpText)))
{
HMODULE hMod = GetModuleHandle(TEXT("shell32.dll"));
if (hMod)
{
BOOL fUnicodeShell = (NULL != GetProcAddress(hMod, "WOWShellExecute"));
// NOTE: This sucks, but DVM_GETHELPTEXT will want a UNICODE string if we are running
// on NT and an Ansi string if we are running on Win95. Let's thunk it to what
// they want.
if (fUnicodeShell)
SHTCharToUnicode(szHelpText, pwzHelpTextOut, HIWORD(wParam));
else
SHTCharToAnsi(szHelpText, pszHelpTextOut, HIWORD(wParam));
hres = S_OK;
}
}
return hres;
}
#define SZ_HELPTOPIC_FILEA "iexplore.chm > iedefault"
#define SZ_HELPTOPIC_FTPSECTIONA "ftp_over.htm"
#define SZ_HELPTOPIC_FILEW L"iexplore.chm"
#define SZ_HELPTOPIC_FTPSECTIONW L"ftp_over.htm"
/*****************************************************************************\
FUNCTION: _OnInvokeFtpHelp
DESCRIPTION:
The wants Help specific to FTP.
\*****************************************************************************/
HRESULT CFtpView::_OnInvokeFtpHelp(HWND hwnd)
{
HRESULT hr = E_INVALIDARG;
uCLSSPEC ucs;
QUERYCONTEXT qc = { 0 };
ucs.tyspec = TYSPEC_CLSID;
ucs.tagged_union.clsid = CLSID_IEHelp;
// ASSERT(m_hwndOwner && m_psfv); // Not available on browser only
IUnknown_EnableModless((IUnknown *)m_psfv, FALSE);
hr = FaultInIEFeature(m_hwndOwner, &ucs, &qc, FIEF_FLAG_FORCE_JITUI);
IUnknown_EnableModless((IUnknown *)m_psfv, TRUE);
HtmlHelpA(NULL, SZ_HELPTOPIC_FILEA, HH_HELP_FINDER, (DWORD_PTR) SZ_HELPTOPIC_FTPSECTIONA);
return hr;
}
/*****************************************************************************\
FUNCTION: _OnGetHelpTopic
DESCRIPTION:
Remove "Help.FTP Help" because we will have that work done
in "Help.Help Topics" on NT5 and after. We don't do this for
earlier versions of shell32 because shell32 in NT5 is the
first version to support "HtmlHelp" over WinHelp. This is
needed because FTP's help is stored in IE's HTML Help files.
\*****************************************************************************/
HRESULT CFtpView::_OnGetHelpTopic(SFVM_HELPTOPIC_DATA * phtd)
{
HRESULT hr = E_NOTIMPL;
// Remove "Help.FTP Help" because we will have that work done
// in "Help.Help Topics" on NT5 and after. We don't do this for
// earlier versions of shell32 because shell32 in NT5 is the
// first version to support "HtmlHelp" over WinHelp. This is
// needed because FTP's help is stored in IE's HTML Help files.
if (SHELL_VERSION_IE4 < GetShellVersion())
{
StrCpyNW(phtd->wszHelpFile, SZ_HELPTOPIC_FILEW, ARRAYSIZE(phtd->wszHelpFile));
StrCpyNW(phtd->wszHelpTopic, SZ_HELPTOPIC_FTPSECTIONW, ARRAYSIZE(phtd->wszHelpTopic));
hr = S_OK;
}
return hr;
}
/*****************************************************************************\
FUNCTION: _OnGetZone
DESCRIPTION:
\*****************************************************************************/
HRESULT CFtpView::_OnGetZone(DWORD * pdwZone, WPARAM wParam)
{
HRESULT hr = E_INVALIDARG;
DWORD dwZone = URLZONE_INTERNET; // Default
LPCITEMIDLIST pidl = m_pff->GetPrivatePidlReference();
if (pidl)
{
WCHAR wzUrl[MAX_URL_STRING];
// NT #277100: This may fail if TweakUI is installed because
// they abuse us.
hr = UrlCreateFromPidlW(pidl, SHGDN_FORPARSING, wzUrl, ARRAYSIZE(wzUrl), ICU_ESCAPE | ICU_USERNAME, FALSE);
if (SUCCEEDED(hr))
{
IInternetSecurityManager * pism;
if (EVAL(SUCCEEDED(CoCreateInstance(CLSID_InternetSecurityManager, NULL, CLSCTX_INPROC_SERVER,
IID_IInternetSecurityManager, (void **) &pism))))
{
pism->MapUrlToZone(wzUrl, &dwZone, 0);
pism->Release();
}
}
}
if (pdwZone)
{
*pdwZone = dwZone;
hr = S_OK;
}
return hr;
}
/*****************************************************************************\
FUNCTION: _OnGetPane
DESCRIPTION:
\*****************************************************************************/
HRESULT CFtpView::_OnGetPane(DWORD dwPaneID, DWORD * pdwPane)
{
HRESULT hr = E_INVALIDARG;
DWORD dwPane = PANE_NONE; // Default unknown
switch (dwPaneID)
{
case PANE_NAVIGATION:
dwPane = STATUS_PANE_STATUS;
break;
case PANE_ZONE:
dwPane = STATUS_PANE_ZONE;
break;
default:
break;
}
if (pdwPane)
{
*pdwPane = dwPane;
hr = S_OK;
}
return hr;
}
/*****************************************************************************\
FUNCTION: _OnRefresh
DESCRIPTION:
We need to purge the cache and force our selves to hit the server again.
\*****************************************************************************/
HRESULT CFtpView::_OnRefresh(BOOL fReload)
{
if (EVAL(m_pff) && fReload)
m_pff->InvalidateCache();
return S_OK;
}
/*****************************************************************************\
FUNCTION: _OnBackGroundEnumDone
DESCRIPTION:
Our enum happens on the background. Sometimes we decide that we want
to do a redirect during the enumeration because the UserName/Password
didn't allow access to the server but the user provided a pair that does.
Since we can't access the ComDlgBrowser's IShellBrowser::BrowseObject()
on the background, we need to call it on the forground. In order to do
that, we need an event that happens on the forground. Well this is that
even baby.
\*****************************************************************************/
HRESULT CFtpView::_OnBackGroundEnumDone(void)
{
HRESULT hr = S_OK;
if (m_pidlRedirect)
{
LPITEMIDLIST pidlRedirect = NULL;
ENTERCRITICAL;
if (m_pidlRedirect)
{
pidlRedirect = m_pidlRedirect;
m_pidlRedirect = NULL;
}
LEAVECRITICAL;
if (pidlRedirect)
{
IShellBrowser * psb;
hr = IUnknown_QueryService(_punkSite, SID_SCommDlgBrowser, IID_IShellBrowser, (LPVOID *) &psb);
if (SUCCEEDED(hr))
{
hr = psb->BrowseObject(pidlRedirect, 0);
AssertMsg(SUCCEEDED(hr), TEXT("CFtpView::_OnBackGroundEnumDone() defview needs to support QS(SID_ShellFolderViewCB) on all platforms that hit this point"));
psb->Release();
}
ILFree(pidlRedirect);
}
}
return hr;
}
/*****************************************************************************\
FUNCTION: _OnGetNotify
DESCRIPTION:
\*****************************************************************************/
HRESULT CFtpView::_OnGetNotify(LPITEMIDLIST * ppidl, LONG * lEvents)
{
if (EVAL(lEvents))
*lEvents = FTP_SHCNE_EVENTS;
if (EVAL(ppidl))
{
// Normally I would use pidlRoot to get ChangeNotify messages but since
// that doesn't work, it's necessary to broadcast ChangeNotify messages
// using pidlTarget and receive them using pidlTarget. This is the later
// case.
if (EVAL(m_pff))
*ppidl = (LPITEMIDLIST) m_pff->GetPublicTargetPidlReference();
else
*ppidl = NULL;
}
return S_OK;
}
/*****************************************************************************\
FUNCTION: _OnSize
DESCRIPTION:
\*****************************************************************************/
HRESULT CFtpView::_OnSize(LONG x, LONG y)
{
RECT rcCurrent;
HRESULT hr = S_OK;
ASSERT(m_hwndOwner);
GetWindowRect(m_hwndOwner, &rcCurrent);
// Has the size really changed?
if ((m_rcPrev.bottom != rcCurrent.bottom) ||
(m_rcPrev.top != rcCurrent.top) ||
(m_rcPrev.left != rcCurrent.left) ||
(m_rcPrev.right != rcCurrent.right))
{
// yes, so update the StatusBar.
if (m_psb)
hr = m_psb->Resize(x, y);
m_rcPrev = rcCurrent;
}
else
{
// No, so ignore it because we may stomp on some other
// active view. (Because we get this message even after
// another view took over the brower).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -