BOOL COXShellNamespaceNavigator::InvokeDefaultCommand(const LPSHELLFOLDER lpParentFolder, 
													  const LPITEMIDLIST lpRelativeIDL) const
{
	// retrieve the default command ID
	HMENU hMenu=GetObjectContextMenu(lpParentFolder,lpRelativeIDL,CMF_DEFAULTONLY);
	if(hMenu==NULL)
	{
		TRACE(_T("COXShellNamespaceNavigator::InvokeDefaultCommand: GetObjectContextMenu() failed\n"));
		return FALSE;
	}

	CMenu menuPopup;
	VERIFY(menuPopup.Attach(hMenu));
	if(menuPopup.GetMenuItemCount()==0)
	{
		TRACE(_T("COXShellNamespaceNavigator::InvokeDefaultCommand: there is no context menu for the specified object\n"));
		return FALSE;
	}

	int nDefaultCmdID=-1;
#if _MFC_VER > 0x0421
	nDefaultCmdID=menuPopup.GetDefaultItem(GMDI_GOINTOPOPUPS,FALSE);
#else
	nDefaultCmdID=::GetMenuDefaultItem(menuPopup.GetSafeHmenu(),
		FALSE,GMDI_GOINTOPOPUPS);
#endif
	if(nDefaultCmdID==-1)
	{
		TRACE(_T("COXShellNamespaceNavigator::InvokeDefaultCommand: there is no default menu item for the specified object\n"));
		return FALSE;
	}
	VERIFY(menuPopup.DestroyMenu());

	return InvokeCommand(lpParentFolder,lpRelativeIDL,nDefaultCmdID,CMF_DEFAULTONLY);
}
UINT CShellContextMenu::ShowContextMenu(QWidget * pParentWidget, QPoint pt, QMenu* pMenu )
{
        HWND hWnd = pParentWidget->winId();
        int iMenuType = 0;	// to know which version of IContextMenu is supported
	LPCONTEXTMENU pContextMenu;	// common pointer to IContextMenu and higher version interface
   
	if (!GetContextMenu ((void**) &pContextMenu, iMenuType))	
		return (0);	// something went wrong

	if (!m_hMenu)
	{
		DestroyMenu( m_hMenu );
		m_hMenu = CreatePopupMenu ();
	}

        int i;
        QList<QAction*> actionList = pMenu->actions();
        for( i=0; i<actionList.count(); ++i )
        {
           QString s = actionList.at(i)->text();
           if (!s.isEmpty())
              AppendMenuW( m_hMenu, MF_STRING, i+1, (LPCWSTR)s.utf16() );
        }
        AppendMenuW( m_hMenu, MF_SEPARATOR, i+1, L"" );

	// lets fill the our popupmenu  
	pContextMenu->QueryContextMenu (m_hMenu, GetMenuItemCount (m_hMenu), MIN_ID, MAX_ID, CMF_NORMAL | CMF_EXPLORE);
 
	// subclass window to handle menurelated messages in CShellContextMenu 
	WNDPROC OldWndProc;
	if (iMenuType > 1)	// only subclass if its version 2 or 3
	{
		OldWndProc = (WNDPROC) SetWindowLongPtr (hWnd, GWLP_WNDPROC, (LONG_PTR) HookWndProc);
		if (iMenuType == 2)
			g_IContext2 = (LPCONTEXTMENU2) pContextMenu;
		else	// version 3
			g_IContext3 = (LPCONTEXTMENU3) pContextMenu;
	}
	else
		OldWndProc = NULL;

	UINT idCommand = TrackPopupMenu (m_hMenu,TPM_RETURNCMD | TPM_LEFTALIGN, pt.x(), pt.y(), 0, pParentWidget->winId(), 0);

	if (OldWndProc) // unsubclass
		SetWindowLongPtr (hWnd, GWLP_WNDPROC, (LONG_PTR) OldWndProc);

	if (idCommand >= MIN_ID && idCommand <= MAX_ID)	// see if returned idCommand belongs to shell menu entries
	{
		InvokeCommand (pContextMenu, idCommand - MIN_ID);	// execute related command
		idCommand = 0;
	}
	
	pContextMenu->Release();
	g_IContext2 = NULL;
	g_IContext3 = NULL;

	return (idCommand);
}
bool MyUPnP::deletePortmap(int eport, const CString& type)
{
	CString args;

	args.Empty();
	args.Append(GetArgString(_T("NewRemoteHost"), _T("")));
	args.Append(GetArgString(_T("NewExternalPort"), eport));
	args.Append(GetArgString(_T("NewProtocol"), type));

	return InvokeCommand(UPNPDELPORTMAP, args);
}
Example #4
0
    HRESULT DebuggerProxy::ResumeLaunchedProcess( IProcess* process )
    {
        HRESULT             hr = S_OK;
        ResumeLaunchedProcessParams params( mExec );

        params.Process = process;

        hr = InvokeCommand( params );
        if ( FAILED( hr ) )
            return hr;

        return params.OutHResult;
    }
Example #5
0
    HRESULT DebuggerProxy::AsyncBreak( IProcess* process )
    {
        HRESULT             hr = S_OK;
        AsyncBreakParams    params( mExec );

        params.Process = process;

        hr = InvokeCommand( params );
        if ( FAILED( hr ) )
            return hr;

        return params.OutHResult;
    }
Example #6
0
    HRESULT DebuggerProxy::Execute( IProcess* process, bool handleException )
    {
        HRESULT         hr = S_OK;
        ExecuteParams   params( mExec );

        params.Process = process;
        params.HandleException = handleException;

        hr = InvokeCommand( params );
        if ( FAILED( hr ) )
            return hr;

        return params.OutHResult;
    }
Example #7
0
UINT CShellContextMenu::ShowContextMenu(HWND hWnd, CPoint pt)
{
	int iMenuType = 0;	// to know which version of IContextMenu is supported
	LPCONTEXTMENU pContextMenu;	// common pointer to IContextMenu and higher version interface

	if(!GetContextMenu((LPVOID*)&pContextMenu, iMenuType))	
		return 0;	// something went wrong

	if(!m_Menu)
	{
		delete m_Menu;
		m_Menu = NULL;
		m_Menu = new CMenu;
		m_Menu->CreatePopupMenu();
	}

	// lets fill the popupmenu 
	pContextMenu->QueryContextMenu(m_Menu->m_hMenu, m_Menu->GetMenuItemCount(), ID_SHELLCONTEXTMENU_MIN, ID_SHELLCONTEXTMENU_MAX, CMF_NORMAL | CMF_EXPLORE);

	// subclass window to handle menurelated messages in CShellContextMenu 
	WNDPROC OldWndProc;
	if(iMenuType > 1)	// only subclass if its version 2 or 3
	{
		OldWndProc = (WNDPROC) SetWindowLong(hWnd, GWL_WNDPROC, (DWORD) HookWndProc);
		if(iMenuType == 2)
			g_IContext2 = (LPCONTEXTMENU2) pContextMenu;
		else	// version 3
			g_IContext3 = (LPCONTEXTMENU3) pContextMenu;
	}
	else
		OldWndProc = NULL;

	UINT idCommand = m_Menu->TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, hWnd);

	if(OldWndProc) // unsubclass
		SetWindowLong(hWnd, GWL_WNDPROC, (DWORD) OldWndProc);

	if(idCommand >= ID_SHELLCONTEXTMENU_MIN && idCommand <= ID_SHELLCONTEXTMENU_MAX)
	{
		InvokeCommand(pContextMenu, idCommand - ID_SHELLCONTEXTMENU_MIN);
		idCommand = 0;
	}

	pContextMenu->Release();
	g_IContext2 = NULL;
	g_IContext3 = NULL;

	return idCommand;
}
Example #8
0
    HRESULT DebuggerProxy::StepOut( IProcess* process, Address targetAddr, bool handleException )
    {
        HRESULT                 hr = S_OK;
        StepOutParams           params( mExec );

        params.Process = process;
        params.TargetAddress = targetAddr;
        params.HandleException = handleException;

        hr = InvokeCommand( params );
        if ( FAILED( hr ) )
            return hr;

        return params.OutHResult;
    }
Example #9
0
    HRESULT DebuggerProxy::StepInstruction( IProcess* process, bool stepIn, bool handleException )
    {
        HRESULT                 hr = S_OK;
        StepInstructionParams   params( mExec );

        params.Process = process;
        params.StepIn = stepIn;
        params.HandleException = handleException;

        hr = InvokeCommand( params );
        if ( FAILED( hr ) )
            return hr;

        return params.OutHResult;
    }
UINT CShellContextMenu::ShowContextMenu(HWND hWnd, const POINT &pt, UINT uIdMin, UINT uIdMax)
{
	ASSERT(hWnd);
	ASSERT(uIdMin < uIdMax);

	SCONTEXTMENU SContextMenu;

	if (!GetContextMenu((void**) &SContextMenu.pContextMenu, SContextMenu.iMenuVer))
		return 0; // something went wrong

	if (!m_hMenu)
	{
		DestroyMenu(m_hMenu);
		m_hMenu = CreatePopupMenu();
	}

	// lets fill the our popupmenu  
	SContextMenu.pContextMenu->QueryContextMenu(m_hMenu, GetMenuItemCount(m_hMenu), uIdMin, uIdMax, CMF_NORMAL | CMF_EXPLORE);
 
	// subclass window to handle menurelated messages in CShellContextMenu 
	WNDPROC OldWndProc;
	if (SContextMenu.iMenuVer > 1)	// only subclass if its version 2 or 3
	{
		OldWndProc = (WNDPROC) SetWindowLongPtr (hWnd, GWLP_WNDPROC, (LONG_PTR) HookWndProc);
		SetProp(hWnd, S_OLDPROC, (HANDLE) OldWndProc);
		SetProp(hWnd, S_CONTEXTMENU, (HANDLE) &SContextMenu);
	}
	else
		OldWndProc = NULL;

	UINT idCommand = ::TrackPopupMenu(m_hMenu, TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, 0, hWnd, NULL);

	if (OldWndProc) {// unsubclass
		SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) OldWndProc);
		RemoveProp(hWnd, S_OLDPROC);
		RemoveProp(hWnd, S_CONTEXTMENU);
	}

	if (idCommand >= uIdMin && idCommand <= uIdMax)	// see if returned idCommand belongs to shell menu entries
	{
		InvokeCommand(SContextMenu.pContextMenu, idCommand - uIdMin);	// execute related command
		idCommand = 0;
	}

	SContextMenu.pContextMenu->Release();

	return idCommand;
}
UINT CShellContextMenu::ShowContextMenu(CWnd *pWnd, CPoint pt)
{
	int iMenuType = 0;	// to know which version of IContextMenu is supported
	LPCONTEXTMENU pContextMenu;	// common pointer to IContextMenu and higher version interface
   
	if (!GetContextMenu ((void**) &pContextMenu, iMenuType))	
		return (0);	// something went wrong

	if (m_Menu)
	{
		delete m_Menu;
		m_Menu = NULL;
	}
	m_Menu = new CMenu;
	m_Menu->CreatePopupMenu ();
	// lets fill the our popupmenu  
	pContextMenu->QueryContextMenu (m_Menu->m_hMenu, m_Menu->GetMenuItemCount (), MIN_ID, MAX_ID, CMF_NORMAL | CMF_EXPLORE);
 
	// subclass window to handle menurelated messages in CShellContextMenu 
	WNDPROC OldWndProc;
	if (iMenuType > 1)	// only subclass if its version 2 or 3
	{
		OldWndProc = (WNDPROC) SetWindowLong (pWnd->m_hWnd, GWL_WNDPROC, (DWORD) HookWndProc);
		if (iMenuType == 2)
			g_IContext2 = (LPCONTEXTMENU2) pContextMenu;
		else	// version 3
			g_IContext3 = (LPCONTEXTMENU3) pContextMenu;
	}
	else
		OldWndProc = NULL;

	UINT idCommand = m_Menu->TrackPopupMenu (TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, pWnd);

	if (OldWndProc) // unsubclass
		SetWindowLong (pWnd->m_hWnd, GWL_WNDPROC, (DWORD) OldWndProc);

	if (idCommand >= MIN_ID && idCommand <= MAX_ID)	// see if returned idCommand belongs to shell menu entries
	{
		InvokeCommand (pContextMenu, idCommand - MIN_ID);	// execute related command
		idCommand = 0;
	}
	
	pContextMenu->Release();
	g_IContext2 = NULL;
	g_IContext3 = NULL;

	return (idCommand);
}
bool MyUPnP::addPortmap(int eport, int iport, const CString& iclient, const CString& descri, const CString& type)
{
	CString args;

	args.Empty();
	args.Append(GetArgString(_T("NewRemoteHost"), _T("")));
	args.Append(GetArgString(_T("NewExternalPort"), eport));
	args.Append(GetArgString(_T("NewProtocol"), type));
	args.Append(GetArgString(_T("NewInternalPort"), iport));
	args.Append(GetArgString(_T("NewInternalClient"), iclient));
	args.Append(GetArgString(_T("NewEnabled"), _T("1")));
	args.Append(GetArgString(_T("NewPortMappingDescription"), descri));
	args.Append(GetArgString(_T("NewLeaseDuration"), 0));

	return InvokeCommand(UPNPADDPORTMAP, args);
}
Example #13
0
    HRESULT DebuggerProxy::Launch( LaunchInfo* launchInfo, IProcess*& process )
    {
        HRESULT         hr = S_OK;
        LaunchParams    params( mExec );

        params.Settings = launchInfo;

        hr = InvokeCommand( params );
        if ( FAILED( hr ) )
            return hr;

        if ( SUCCEEDED( params.OutHResult ) )
            process = params.OutProcess.Detach();

        return params.OutHResult;
    }
Example #14
0
    HRESULT DebuggerProxy::Attach( uint32_t id, IProcess*& process )
    {
        HRESULT         hr = S_OK;
        AttachParams    params( mExec );

        params.ProcessId = id;

        hr = InvokeCommand( params );
        if ( FAILED( hr ) )
            return hr;

        if ( SUCCEEDED( params.OutHResult ) )
            process = params.OutProcess.Detach();

        return params.OutHResult;
    }
Example #15
0
UINT CShellContextMenu::ShowContextMenu(CWnd *pWnd, POINT pt)
{
	int iMenuType = 0;	// to know which version of IContextMenu is supported
	LPCONTEXTMENU pContextMenu;	// common pointer to IContextMenu and higher version interface
   
	if (!GetContextMenu ((void**) &pContextMenu, iMenuType))	
		return (0);	// something went wrong

    if (!m_Menu)
    {
        delete m_Menu;
        m_Menu = NULL;
        m_Menu = new CMenu;
        m_Menu->CreatePopupMenu ();
        m_Menu->AppendMenu(MF_STRING, WM_MENU_FILE,_T("打开文件所在目录"));

        // lets fill the our popupmenu
        pContextMenu->QueryContextMenu(m_Menu->m_hMenu, m_Menu->GetMenuItemCount(), MIN_ID, MAX_ID, CMF_NORMAL | CMF_EXPLORE);
    }

	if (iMenuType > 1)	// only subclass if its version 2 or 3
	{
		if (iMenuType == 2)
			g_IContext2 = (LPCONTEXTMENU2) pContextMenu;
		else	// version 3
			g_IContext3 = (LPCONTEXTMENU3) pContextMenu;
	}


	UINT idCommand = m_Menu->TrackPopupMenu (TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, pWnd);

	if (idCommand >= MIN_ID && idCommand <= MAX_ID)	// see if returned idCommand belongs to shell menu entries
	{
		InvokeCommand (pContextMenu, idCommand - MIN_ID);	// execute related command
		idCommand = 0;
	}
	
	pContextMenu->Release();
	g_IContext2 = NULL;
	g_IContext3 = NULL;

	return (idCommand);
}
bool CShellContextMenu::CloseShellMenu(CShellMenu *pShellMenu, UINT idCommand, bool bInvoke/* = true*/)
{
	if (pShellMenu) {
		if (bInvoke && idCommand >= pShellMenu->m_uIdMin && idCommand <= pShellMenu->m_uIdMax) {
			InvokeCommand(pShellMenu->m_ContextMenu.pContextMenu, idCommand - pShellMenu->m_uIdMin);
			bInvoke = false;
		}

		if (pShellMenu->m_WndProc) {// unsubclass
			SetWindowLongPtr(pShellMenu->m_hWnd, GWLP_WNDPROC, (LONG_PTR) pShellMenu->m_WndProc);
			RemoveProp(pShellMenu->m_hWnd, S_OLDPROC);
			RemoveProp(pShellMenu->m_hWnd, S_CONTEXTMENU);
		}

		if (bInvoke)
			SendMessage(pShellMenu->m_hWnd, WM_COMMAND, idCommand, 0);

		delete pShellMenu;

		return true;
	}

	return false;
}
Example #17
0
    HRESULT DebuggerProxy::WriteMemory( 
        IProcess* process, 
        Address address,
        uint32_t length, 
        uint32_t& lengthWritten, 
        uint8_t* buffer )
    {
        HRESULT             hr = S_OK;
        WriteMemoryParams   params( mExec );

        params.Process = process;
        params.Address = address;
        params.Length = length;
        params.Buffer = buffer;

        hr = InvokeCommand( params );
        if ( FAILED( hr ) )
            return hr;

        if ( SUCCEEDED( params.OutHResult ) )
            lengthWritten = params.OutLengthWritten;

        return params.OutHResult;
    }