⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 copiermenu.cpp

📁 一个不同目录中多个文件拷贝的助手程序
💻 CPP
字号:
//-----------------------------------------------------------------------//
// This is a part of the Multicopier.									 //	
// Autor  :  Ahmed Ismaiel Zakaria										 //
// (C) 2002 FCIS Egypt  All rights reserved								 //
// This code is provided "as is", with absolutely no warranty expressed  //
// or implied. Any use is at your own risk.								 //		
// You must obtain the author's consent before you can include this code //
// in a software library.												 //
// If the source code in  this file is used in any application			 //
// then acknowledgement must be made to the author of this program		 //	
// ahmed_ismaiel@hotmail.com											 //
//-----------------------------------------------------------------------//

// CopierMenu.cpp : Implementation of CCopierMenu
#include "stdafx.h"
#include "Copier.h"
#include "CopierMenu.h"
#include "AboutDlg.h"
#include "options.h"
/////////////////////////////////////////////////////////////////////////////
// CCopierMenu


HRESULT CCopierMenu::Initialize(LPCITEMIDLIST pidlFolder,LPDATAOBJECT lpdobj, HKEY hkeyProgID)
{
	// Get the file associated with this object, if applicable.

	STGMEDIUM   medium;
	FORMATETC   fe = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
	UINT        uCount;      
	TCHAR szPath[MAX_PATH];    // path to file or folder in question

	if(SUCCEEDED(lpdobj->GetData(&fe, &medium)))
	{         
		// Get the file name from the HDROP.
		uCount = DragQueryFile((HDROP)medium.hGlobal, (UINT)-1, NULL, 0);

		// store a list of filenames
		for (UINT i=0;i<uCount;i++)
		{
			DragQueryFile((HDROP)medium.hGlobal, i, szPath, sizeof(szPath));
			m_listPaths.Add (szPath);
		}

		ReleaseStgMedium(&medium);      
	}
	return NOERROR;
}

HRESULT CCopierMenu::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
    if ( (uFlags & CMF_DEFAULTONLY))
	{
        return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 0 );
	}
	LoadFile(&source);
	int uCmd=idCmdFirst;
	CMenu main;main.Attach (hmenu);
	CMenu menu,*menu2;
	HMENU m=::LoadMenu (_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_COPIER));
	if(m!=NULL)
	{
		menu.Attach (m);
		CString s;
		menu2=menu.GetSubMenu (0);
		menu.Detach ();
		UINT state = menu2->GetMenuState(2, MF_BYPOSITION);
		CString empty;
		menu2->GetMenuString(2,empty,MF_BYPOSITION);
		empty.Format ("%s (%d)",(LPSTR)(LPCSTR)empty,source.GetSize ());
		menu2->ModifyMenu (2,state|MF_BYPOSITION|MF_STRING,0,empty);

		//Modify the menu
		int mcount=menu2->GetMenuItemCount ();
		for(int i=0;i<mcount;i++)
		{
			//	MENUITEMINFO info;
			//menu2->GetMenuItemInfo(i,&info,TRUE);
			UINT state = menu2->GetMenuState(i, MF_BYPOSITION);
			ASSERT(state != 0xFFFFFFFF);
			if(!(state & MF_SEPARATOR))
			{
				CString menustring="";
			menu2->GetMenuString(i,menustring,MF_BYPOSITION);
			menu2->ModifyMenu (i,state|MF_BYPOSITION ,uCmd++,menustring);
			}
		}

		//////////////////
		main.InsertMenu (indexMenu,MF_SEPARATOR|MF_BYPOSITION,0);
		indexMenu++;
		main.InsertMenu (indexMenu,MF_STRING|MF_POPUP|MF_BYPOSITION,(UINT)menu2->Detach (),"MultiCopier");
		indexMenu++;//nAdd++;
		main.InsertMenu (indexMenu,MF_SEPARATOR|MF_BYPOSITION,0);
		indexMenu++;
		menu.Detach ();main.Detach ();
	}
	return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL,uCmd- idCmdFirst+1 );
}

HRESULT CCopierMenu::InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
{
	if (!HIWORD(lpici->lpVerb))    
	{      
		int n=LOWORD(lpici->lpVerb);
		switch (n)       
		{ 
		case 0:
			{
			//	::AfxMessageBox ("cool",MB_OK);
				int uCount = m_listPaths.GetSize();
				
				// store a list of filenames
				for (UINT i=0;i<uCount;i++)
				{
					source.Add (m_listPaths.GetAt(i) );
				}
				SaveFile(&source);
			}
			break;
		case 1:
			source.RemoveAll ();
			SaveFile(&source);
			break;
		case 2:
			{
				COptions dlg;
				dlg.DoModal ();
			}
		break;
		case 3:
				::AfxBeginThread(SendMail,0,
			THREAD_PRIORITY_NORMAL, 0, 0);
					break;
		case 4:
			{
				CString file;
				::GetModuleFileName(::GetModuleHandle ("Copier"),file.GetBuffer (256),255);
				file.ReleaseBuffer (256);
				LPSTR folder=file.GetBuffer (file.GetLength ());
				PathRemoveFileSpec(folder);
				CString f=folder;
				
				ShellExecute(NULL,"open",f+"\\MultiCopier Help.chm",NULL,NULL,SW_MAXIMIZE );
			}
			break;
		case 5:
		CAboutDlg dlg;
			dlg.DoModal ();
			break;
		}
	}

	return NOERROR;
}

HRESULT CCopierMenu::GetCommandString(UINT idCmd, UINT uType,UINT* pwReserved,LPSTR pszName,UINT cchMax)
{
	return NOERROR;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -