Click here to Skip to main content
15,908,013 members

Comments by Ali Hojjati (Top 14 by date)

Ali Hojjati 2-Feb-18 9:18am View    
Hi, I checked my codes and It happens when I Add Bitmaps to menu items. How to prevent this issue
Ali Hojjati 2-Feb-18 8:53am View    
Deleted
Here is my code

#include "MyAdvancedMenuContextMenuHandler.h"
#include <iostream>
#include <fstream>
#include <atlstr.h>
#include <stdio.h>
#include "sqlite3.h"
#include <tchar.h>
#include <Windows.h>
#include <ShlObj.h>
#include <strsafe.h>
#include <direct.h>

using namespace std;

#define DB "C:\\ProgramData\\DataBase.db"
sqlite3 *dbfile;
bool isOpenDB = false;
UINT FirstID = 0;

#define IDM_DISPLAY             0  // The command's identifier offset

HDC hdcSrc, hdcDst;
HBITMAP hbmOld;
HBITMAP	hbmNew;
BITMAP bm;
COLORREF clrTP, clrBK;

MyAdvancedMenuContexthandler::~MyAdvancedMenuContexthandler()
{
	InterlockedDecrement(&g_cObjCount);
}

MyAdvancedMenuContexthandler::MyAdvancedMenuContexthandler() : m_ObjRefCount(1)
{
	InterlockedIncrement(&g_cObjCount);
}

ULONG MyAdvancedMenuContexthandler::AddRef()
{
	return InterlockedIncrement(&m_ObjRefCount);
}

ULONG MyAdvancedMenuContexthandler::Release()
{
	ULONG returnValue = InterlockedDecrement(&m_ObjRefCount);
	if (returnValue < 1)
	{
		delete this;
	}
	return returnValue;
}

HRESULT MyAdvancedMenuContexthandler::QueryInterface(REFIID riid, void **ppvObject)
{
	if (!ppvObject)
		return E_POINTER;
	*ppvObject = NULL;

	if (IsEqualIID(riid, IID_IUnknown))
	{
		*ppvObject = this;
		this->AddRef();
		return S_OK;
	}
	else if (IsEqualIID(riid, IID_IContextMenu))
	{
		*ppvObject = (IContextMenu*) this;
		this->AddRef();
		return S_OK;
	}
	else if (IsEqualIID(riid, IID_IShellExtInit))
	{
		*ppvObject = (IShellExtInit*) this;
		this->AddRef();
		return S_OK;
	}
	else
	{
		return E_NOINTERFACE;
	}
	return E_NOTIMPL;
}

HRESULT MyAdvancedMenuContexthandler::Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pDataObj, HKEY hkeyProgID)
{
	if (NULL == pDataObj)
    {
        return E_INVALIDARG;
    }

    HRESULT hr = E_FAIL;

    FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
    STGMEDIUM stm;

    // The pDataObj pointer contains the objects being acted upon. In this 
    // example, we get an HDROP handle for enumerating the selected files and 
    // folders.
    if (SUCCEEDED(pDataObj->GetData(&fe, &stm)))
    {
        // Get an HDROP handle.
        HDROP hDrop = static_cast<HDROP>(GlobalLock(stm.hGlobal));
        if (hDrop != NULL)
        {
            // Determine how many files are involved in this operation. This 
            // code sample displays the custom context menu item when only 
            // one file is selected. 
            UINT nFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
            if (nFiles == 1)
            {

                // Get the path of the file.
                if (0 != DragQueryFile(hDrop, 0, m_szSelectedFile, 
                    ARRAYSIZE(m_szSelectedFile)))
                {
					wchar_t szMessage[300];
					if (SUCCEEDED(StringCchPrintf(szMessage, ARRAYSIZE(szMessage), 
						L"The selected file is:\r\n\r\n%s", this->m_szSelectedFile)))
						{
							//MessageBox(NULL, szMessage, L"CppShellExtContextMenuHandler", MB_OK);
						}
                    hr = S_OK;
                }
            }

            GlobalUnlock(stm.hGlobal);
        }

        ReleaseStgMedium(&stm);
    } 

    // If any value other than S_OK is returned from the method, the context 
    // menu item is not displayed.
    return S_OK;
}

HRESULT MyAdvancedMenuContexthandler::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT * pwReserved, LPSTR pszName, UINT cchMax)
{
	return E_NOTIMPL;
}

HRESULT MyAdvancedMenuContexthandler::InvokeCommand(LPCMINVOKECOMMANDINFO pici)
{
	/*wchar_t szMessage[300];
	StringCchPrintf(szMessage, ARRAYSIZE(szMessage), L"The selected file is:\r\n\r\n%s", this->m_szSelectedFile);*/
	//MessageBox(NULL, m_szSelectedFile, L"CppShellExtContextM
Ali Hojjati 3-Oct-13 1:13am View    
the problem is "I don't have any code"
Ali Hojjati 18-Sep-13 9:54am View    
thanks
Ali Hojjati 18-Sep-13 9:26am View    
Thanks I'd take look at SQLite, and i know MySql but what about my opinion?
i just need a database with two tables