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

📄 hexshellmenu.cpp

📁 dos系统下的16进制文件内容察看器源码
💻 CPP
字号:
//---------------------------------------------------------------------------------------

// Quick Hex Shell extension
// Copyright (c) 2000 by Shanker.C
// All rights reserved
// Author's consent required if this program is to be used for commercial purposes
// No warranty of any kind, expressed or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the user.
// Please send comments/suggestions/criticisms to: Shanker@xlprint.com
// March 7, 2000

//---------------------------------------------------------------------------------------

// HexShellMenu.cpp : Implementation of CHexShellMenu

#include "stdafx.h"
#include "HexShell.h"
#include "HexShellMenu.h"
#include "hexdlg.h"
#include "resource.h"

//---------------------------------------------------------------------------------------

// Further info on this is available in Programming the Windows 95 User Interface, Nancy Cluts
// Available in MSDN CD
// Also check out the excellent book Visual C++ Windows Shell Programming
// by Dino Esposito, from Wrox Press.

//---------------------------------------------------------------------------------------

// Explorer calls this when filling in menus
HRESULT CHexShellMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
	UINT idCmd = idCmdFirst;
	InsertMenu(hMenu, indexMenu, MF_STRING | MF_BYPOSITION, idCmd++, "Show &Hex");
	HBITMAP hBitMap = LoadBitmap(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDB_HEXBMP)); 
    SetMenuItemBitmaps(hMenu, indexMenu++, MF_BYPOSITION, hBitMap, hBitMap);
    
	return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, idCmd - idCmdFirst);
}

//---------------------------------------------------------------------------------------

HRESULT CHexShellMenu::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
{
	CHexDlg* pHexDlg = new CHexDlg(m_szPath);  
	pHexDlg->Create(IDD_HEXDLG);
	pHexDlg->ShowWindow(SW_SHOW);
	pHexDlg->UpdateWindow();

	return S_OK;
}

//---------------------------------------------------------------------------------------

HRESULT CHexShellMenu::GetCommandString(UINT idCmd, UINT uFlags, UINT* pwReserved, LPSTR pszText, UINT cchMax)
{
	USES_CONVERSION;

	CString strText = _T("Displays selected file in hexadecimal.");
	
	if(uFlags & GCS_HELPTEXT)
	{
    	if (m_bOSNT)
            lstrcpynW((LPWSTR)pszText, T2CW((LPCTSTR)strText), cchMax);
       else
            lstrcpynA(pszText, T2CA((LPCTSTR)strText), cchMax );
	}
 
	return S_OK;
}

//---------------------------------------------------------------------------------------

HRESULT CHexShellMenu::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY hKeyProgID)
{
	if(lpdobj == NULL)
		return E_INVALIDARG;

	//Get the medium
	FORMATETC fmte = // General clipboard format struct
	{
			CF_HDROP, 
			NULL, // I don't care about the device 
			DVASPECT_CONTENT, // Get stuff from screen
			-1, 
			TYMED_HGLOBAL 
	};
	STGMEDIUM medium;
	// Get our medium resource
	HRESULT hr = lpdobj->GetData(&fmte, &medium);
	if(FAILED(hr))
		return E_INVALIDARG; 

	// If user did NOT select more than one file, proceed
	if(DragQueryFile((HDROP)medium.hGlobal, 0xFFFFFFFF, NULL, 0) == 1)
	{
		// Get the file we've currently selected, using the medium
		DragQueryFile((HDROP)(medium.hGlobal), 0, m_szPath, MAX_PATH);
		hr = NOERROR;
	}
	else
		hr = E_INVALIDARG;
	ReleaseStgMedium(&medium); // Release our medium resource
	return hr;
}

//---------------------------------------------------------------------------------------

⌨️ 快捷键说明

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