windows shell program(3)

来源:互联网 发布:淘宝评价发图片 编辑:程序博客网 时间:2024/06/05 02:25

Drag and Drop

If you have read windows shell program(1), it will be easy. Only a reg script:
NoRemove Drive
 {
  NoRemove shellex
  {
    NoRemove DragDropHandlers
    {
    ForceRemove ......
    }
  }
 }
 NoRemove Directory
 {
  NoRemove shellex
  {
    NoRemove DragDropHandlers
    {
    ForceRemove ......
    }
  }
 }
 NoRemove Folder
 {
  NoRemove shellex
  {
   NoRemove DragDropHandlers
   {
    ForceRemove ........   }
  }
 }  

OK, We can drop and drag now!

Shell PropPage Sheet
IShellExtInit is used to select some files as above.
IShellPropSheetExt is used to add or modify property sheet of files.
There are two methods in interface of IShellPropSheetExt:
STDMETHOD(AddPages)(LPFNADDPROPSHEETPAGE lpfnAddPageProc, LPARAM lParam);
STDMETHOD(ReplacePage)(UINT, LPFNADDPROPSHEETPAGE, LPARAM);
ReplacePage
method only be used to extend the control panel's property page sheet .So, sometimes wo don't use it.
AddPages method parameters have a method pointer and a LPARAM variable.They all are used by shell.The lpfnAddpageProc points to inner function of shell proces to add pages. lParam is a very important value that is used by shell. Now we only talk about the lpfnAddpageProc.
In the AddPages function, there is a important Variable--PROPSHEETPAGE.
HRESULT CFileTimeShlExt::AddPages ( LPFNADDPROPSHEETPAGE lpfnAddPageProc, LPARAM lParam )
{
PROPSHEETPAGE psp;
TCHAR szPageTitle [MAX_PATH];
string_list::const_iterator it, itEnd;

for ( it = m_lsFiles.begin(), itEnd = m_lsFiles.end(); it != itEnd; it++ )
{
// 'it' 指向下一个文件名. 分配一个给页面使用的字符串拷贝.
LPCTSTR szFile = _tcsdup ( it->c_str() );

// 从文件名中截去路径和扩展名 – 用其作为页面标题. 该名称截取为 24 个字符以适合Tab的大小.
lstrcpy ( szPageTitle, it->c_str() );
PathStripPath ( szPageTitle );
PathRemoveExtension ( szPageTitle );
szPageTitle[24] = '/0';
psp.dwSize = sizeof(PROPSHEETPAGE);
psp.dwFlags = PSP_USEREFPARENT | PSP_USETITLE | PSP_DEFAULT | PSP_USEICONID | PSP_USECALLBACK;
psp.hInstance = _Module.GetModuleInstance();
psp.pszTemplate = MAKEINTRESOURCE(IDD_FILETIME_PROPPAGE);
psp.pszIcon = MAKEINTRESOURCE(IDI_ICON);
psp.pszTitle = szPageTitle;
psp.pfnDlgProc = PropPageDlgProc;
psp.lParam = (LPARAM) szFile;
psp.pfnCallback = PropPageCallbackProc;
psp.pcRefParent = (UINT*) &_Module.m_nLockCnt;
hPage = CreatePropertySheetPage ( &psp );
if ( NULL != hPage )
{
if ( !if ( NULL != hPage )
{
if ( !lpfnAddPageProc ( hPage, lParam ))
{ DestroyPropertySheetPage ( hPage ); }
}

} // end for
return S_OK;
}( hPage, lParam ))
{ DestroyPropertySheetPage ( hPage ); }
}

} // end for
return S_OK;
}

 
原创粉丝点击