Adding a New Menu Item to PS/Workshop   

<<< The PS/Workshop Interfaces Chapters Registering Handlers for Different Filetypes >>>

Contents

You can add a new menu item to PS/Workshop using IPSWApp::AddMenuItem or IPSWApp::AddMenuItem2. Typically this is done in CAddonMain::StartModule, which is called when the module is first loaded.

In order to add a new menu item you need to do the following:

 

HRESULT CAddonDoc::OnCmdMsg(UINT nID, void* lpparm )
{
HRESULT hr = S_FALSE;

  // either handle the event here...
  switch( nID )
  {
  case ID_COMMAND_ON_BLEND:
    OnBlend();    
    hr = S_OK;
    break;
  default:
    break;
  }

// check if the message has already been handled
  if ( hr == S_FALSE)
  {
    // try routing this to the active view
    CAddonView* pView = GetActiveView();
    if ( pView )
      hr = pView->OnCmdMsg( nID, lpparm );
  }
  
  return hr;
}

 

CComBSTR bstrMenuItem( OLESTR("&Operations\nBlend") );
HRESULT hr = m_pAppInterface->AddMenuItem(pApp, bstrMenuItem,
                   ID_COMMAND_ON_BLEND, PSW_Menu_Doc);

IPSWApp::AddMenuItem2 provides additional functionality to AddMenuItem, so that you can specify the precise position of any menu or menu item in the PS/Workshop menu bar.

[back to top]

<<< The PS/Workshop Interfaces Chapters Registering Handlers for Different Filetypes >>>