📄 urlfview.cpp
字号:
/*-------------------------------------------------------------------*/
// Procedure....: SetStatusText()
// Description..: Writes a line on the status bar
/*-------------------------------------------------------------------*/
STDMETHODIMP CUrlfView::SetStatusText( UINT uID )
{
CHAR szText[MAX_PATH];
WCHAR wszText[2*MAX_PATH];
DWORD dwSize;
szText[0] = 0;
ZeroMemory( wszText, 2*MAX_PATH );
LoadString( g_hInstance, uID, szText, MAX_PATH );
dwSize = MultiByteToWideChar( CP_ACP, 0, szText, lstrlen(szText),
NULL, 0 );
MultiByteToWideChar( CP_ACP, 0, szText, lstrlen(szText),
wszText, dwSize );
m_pShellBrowser->SetStatusTextSB( wszText );
return NOERROR;
}
// UNIMPLEMENTED
// IShellView methods
//
// - GetWindow
// - ContextSensitiveHelp
// - EnableModeless
// - UIActivate
// - AddPropertySheetPages
// - SelectItem
// - GetItemObject
// - SaveViewState
// - TranslateAccelerator
// - GetCurrentInfo
//
/*-------------------------------------------------------------------*/
// Procedure....: SaveViewState()
// Description..:
/*-------------------------------------------------------------------*/
STDMETHODIMP CUrlfView::SaveViewState()
{
return E_NOTIMPL;
}
/*-------------------------------------------------------------------*/
// Procedure....: TranslateAccelerator()
// Description..:
/*-------------------------------------------------------------------*/
STDMETHODIMP CUrlfView::TranslateAccelerator( LPMSG lpmsg )
{
return E_NOTIMPL;
}
/*-------------------------------------------------------------------*/
// Procedure....: GetCurrentInfo()
// Description..:
/*-------------------------------------------------------------------*/
STDMETHODIMP CUrlfView::GetCurrentInfo( LPFOLDERSETTINGS lpfs )
{
return E_NOTIMPL;
}
/*-------------------------------------------------------------------*/
// Procedure....: GetWindow()
// Description..:
/*-------------------------------------------------------------------*/
STDMETHODIMP CUrlfView::GetWindow( HWND *lphwnd )
{
*lphwnd = m_hwndView;
return E_NOTIMPL;
}
/*-------------------------------------------------------------------*/
// Procedure....: ContextSensitiveHelp()
// Description..:
/*-------------------------------------------------------------------*/
STDMETHODIMP CUrlfView::ContextSensitiveHelp( BOOL fEnterMode )
{
return E_NOTIMPL;
}
/*-------------------------------------------------------------------*/
// Procedure....: EnableModeless()
// Description..:
/*-------------------------------------------------------------------*/
STDMETHODIMP CUrlfView::EnableModeless( BOOL fEnable )
{
return E_NOTIMPL;
}
/*-------------------------------------------------------------------*/
// Procedure....: AddPropertySheetPages()
// Description..:
/*-------------------------------------------------------------------*/
STDMETHODIMP CUrlfView::AddPropertySheetPages( DWORD dwReserved,
LPFNADDPROPSHEETPAGE lpfn, LPARAM lParam )
{
return E_NOTIMPL;
}
/*-------------------------------------------------------------------*/
// Procedure....: SelectItem()
// Description..:
/*-------------------------------------------------------------------*/
STDMETHODIMP CUrlfView::SelectItem( LPCITEMIDLIST pidlItem,
UINT uFlags )
{
return E_NOTIMPL;
}
/*-------------------------------------------------------------------*/
// Procedure....: GetItemObject()
// Description..:
/*-------------------------------------------------------------------*/
STDMETHODIMP CUrlfView::GetItemObject( UINT uItem, REFIID riid,
LPVOID *ppv )
{
return E_NOTIMPL;
}
/*-------------------------------------------------------------------*/
// Procedure....: UIActivate()
// Description..: The folder has the focus
/*-------------------------------------------------------------------*/
STDMETHODIMP CUrlfView::UIActivate( UINT uState )
{
if( m_uState==uState )
return S_OK;
m_pShellBrowser->OnViewWindowActive( this );
m_uState = uState;
OnDeactivate();
if( uState==SVUIA_ACTIVATE_FOCUS || uState==SVUIA_ACTIVATE_NOFOCUS )
{
SetMenu();
SetToolbar();
}
return NOERROR;
}
/*-------------------------------------------------------------------*/
// Procedure....: OnDeactivate()
// Description..: Remove UI changes
/*-------------------------------------------------------------------*/
VOID CUrlfView::OnDeactivate( VOID )
{
// clear menus
m_pShellBrowser->SetMenuSB( NULL, NULL, NULL );
m_pShellBrowser->RemoveMenusSB( m_hMenu );
DestroyMenu( m_hMenu );
// clear toolbar
TBBUTTON tbb;
m_pShellBrowser->SendControlMsg( FCW_TOOLBAR, TB_GETBUTTON,
0, (LPARAM) &tbb, NULL );
if( tbb.idCommand==IDM_FILE_RUN )
m_pShellBrowser->SendControlMsg( FCW_TOOLBAR,
TB_DELETEBUTTON, 0, TRUE, NULL );
SetWindowLong( m_hwndToolbar, GWL_WNDPROC, (LONG) g_pfn );
}
//////////////////////////////////////////
//
// View dialog proc
//
/*-------------------------------------------------------------------*/
// Procedure....: View_DlgProc()
// Description..: Dialog procedure for the folder view
/*-------------------------------------------------------------------*/
LRESULT CALLBACK View_DlgProc( HWND hwnd, UINT uiMsg, WPARAM wParam,
LPARAM lParam )
{
HICON hIcon;
CHAR szBrowser[MAX_PATH];
HFILE hfile;
switch( uiMsg )
{
case WM_MENUSELECT:
g_pUrlfView->SetStatusText(LOWORD(wParam));
break;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDC_LINK:
case IDM_FILE_RUN:
hfile = _lcreat("any.htm",0);
_lclose( hfile );
FindExecutable( "any.htm", NULL, szBrowser );
ShellExecute( hwnd, NULL, szBrowser, "http://www.wrox.com", NULL, SW_SHOW );
DeleteFile( "any.htm" );
break;
case IDM_HELP_ABOUT:
hIcon = LoadIcon( g_hInstance,
MAKEINTRESOURCE(IDI_WROX) );
ShellAbout( hwnd,
"URL Folder#NameSpace Extension",
"'Pro Shell Programming for Windows', Dino Esposito", hIcon );
DestroyIcon( hIcon );
break;
}
break;
case WM_NOTIFY: // only if not Active Desktop
View_ShowTooltips( lParam );
break;
case WM_SIZE:
View_ResizeControls( hwnd, lParam );
break;
}
return 0;
}
/*-------------------------------------------------------------------*/
// Procedure....: View_ResizeControls()
// Description..: Resizes the inner treeview
/*-------------------------------------------------------------------*/
VOID View_ResizeControls( HWND hwnd, LPARAM lParam )
{
HWND hwndBmp, hwndBtn;
hwndBmp = GetDlgItem( hwnd, IDC_BITMAP );
MoveWindow( hwndBmp, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE );
hwndBtn = GetDlgItem( hwnd, IDC_LINK );
RECT rc;
GetClientRect( hwndBtn, &rc );
SetWindowPos( hwndBtn, NULL, (LOWORD(lParam)-rc.right)/2,
(HIWORD(lParam)-rc.bottom)/2, 0, 0, SWP_NOSIZE|SWP_NOZORDER|
SWP_SHOWWINDOW );
}
/*-------------------------------------------------------------------*/
// Procedure....: View_ShowTooltips()
// Description..: Responds to tooltips notifications
/*-------------------------------------------------------------------*/
VOID View_ShowTooltips( LPARAM lParam )
{
LPTOOLTIPTEXT lpToolTipText;
static UINT s_wButtonID=0;
switch( ((LPNMHDR)lParam)->code )
{
case TTN_NEEDTEXT:
lpToolTipText = (LPTOOLTIPTEXT)lParam;
LoadString( g_hInstance, TIP_TEXT(lpToolTipText->hdr.idFrom), lpToolTipText->lpszText, 30 );
s_wButtonID = lpToolTipText->hdr.idFrom;
break;
// tooltip is about to be shown: update the status window
case TTN_SHOW:
g_pUrlfView->SetStatusText( s_wButtonID );
return;
// tooltip is about to be hidden: clear the status window
case TTN_POP:
g_pUrlfView->SetStatusText( 0 );
return;
}
return;
}
/*-------------------------------------------------------------------*/
// Procedure....: MyToolbarProc()
// Description..: Custom toolbar wndproc
/*-------------------------------------------------------------------*/
LRESULT CALLBACK MyToolbarProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
if( msg==WM_LBUTTONUP )
{
// new IE40 specific message
INT i = SendMessage( hwnd, TB_GETHOTITEM, 0, 0 );
// retrieve the hot button and post it to the view window
TBBUTTON tb;
SendMessage( hwnd, TB_GETBUTTON, i, (LPARAM) &tb );
PostMessage( g_pUrlfView->GetViewHandle(), WM_COMMAND,
MAKEWPARAM(tb.idCommand,0), 0 );
}
return CallWindowProc( g_pfn, hwnd, msg, wParam, lParam );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -