<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Adding items to the right click context menu in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6886699#M8724</link>
    <description>&lt;P&gt;I figured out the error I was getting with the example file. &amp;nbsp;I was making changes to the release config but then building in debug. &amp;nbsp;The attached sample will work for anyone who wants to use it, just switch the build type to release.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still wondering if there is an easier way to add a single menu item without all the MFC overhead?&lt;/P&gt;</description>
    <pubDate>Fri, 17 Feb 2017 20:17:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-02-17T20:17:38Z</dc:date>
    <item>
      <title>Adding items to the right click context menu</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6883964#M8721</link>
      <description>&lt;P&gt;I'm trying to add items to the context menu that is present when the user right clicks. &amp;nbsp;I found the&amp;nbsp;AcEdUIContext class and it looks to be what I need but it seems like a lot of overhead just to add a single text item to the menu. &amp;nbsp;Is there a simpler way to add text items to the menu?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was struggling to get it into my solution properly so I went looking for examples online as there were none in the 2014/2016 SDK but I was unable to find any out in the wild. &amp;nbsp;I did find that there was an example in the 2007 SDK, which I was able to download. &amp;nbsp;I attempted to convert it over to the newer SDKs using both 32 bit and 64 bit releases but I am getting&amp;nbsp;error LNK1104: cannot open file 'acad.lib' &amp;nbsp;I've tried using relative paths, absolute paths, and even defining acad.lib in the additional dependencies as "C:\ObjectARX 2016\lib-x64\acad.lib" &amp;nbsp;I did this both with and without quotation marks. &amp;nbsp;I have attached the modified sample projects. &amp;nbsp;The 2007 SDK is available at&amp;nbsp;&lt;SPAN&gt;&lt;A href="http://download.autodesk.com/esd/objectarx/2007/Arx_All.exe" target="_blank"&gt;http://download.autodesk.com/esd/objectarx/2007/Arx_All.exe&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 21:07:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6883964#M8721</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-02-16T21:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: Adding items to the right click context menu</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6884359#M8722</link>
      <description>&lt;P&gt;Derive your menu class from&amp;nbsp;&lt;STRONG&gt;AcEdUIContext&lt;/STRONG&gt; and implement these functions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;//------------------------------------------------------------------------------
MyMenu::MyMenu(MyTool* pTool)
//------------------------------------------------------------------------------
{
    HINSTANCE hOldResHandle = AfxGetResourceHandle();
    AfxSetResourceHandle(pApp-&amp;gt;GetResourceHandle());

    m_cMenu = new CMenu;
    BOOL res = m_cMenu-&amp;gt;LoadMenu(IDR_MYMENU_POPUP);
    VERIFY(res);
    if (!res)
    {
        delete m_cMenu;
        m_cMenu = NULL;
    }

    AfxSetResourceHandle(hOldResHandle);

    m_pTool = pTool;
}

//------------------------------------------------------------------------------
MyMenu::~MyMenu()
//------------------------------------------------------------------------------
{
    if (m_cMenu)
    {
        delete m_cMenu;
    }
}

//------------------------------------------------------------------------------
void* MyMenu::getMenuContext(const AcRxClass* classtype, const AcDbObjectIdArray&amp;amp; selectedObjs)
//------------------------------------------------------------------------------
{
    m_hMenu = m_cMenu-&amp;gt;GetSubMenu(0)-&amp;gt;GetSafeHmenu();
    return &amp;amp;m_hMenu;
}

//------------------------------------------------------------------------------
void MyMenu::onCommand(Adesk::UInt32 cmdId)
//------------------------------------------------------------------------------
{
    m_pTool-&amp;gt;OnCommand(cmdId);
}

//------------------------------------------------------------------------------
void MyMenu::OnUpdateMenu()
//------------------------------------------------------------------------------
{
}&lt;/PRE&gt;
&lt;P&gt;Then use &lt;STRONG&gt;acedAddObjectContextMenu&lt;/STRONG&gt; and &lt;STRONG&gt;acedRemoveObjectContextMenu&lt;/STRONG&gt; , something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;m_pContextMenu = new MyMenu(this);

if ((m_pContextMenu-&amp;gt;isValid() == false) || (acedAddObjectContextMenu(AcDbBlockReference::desc(), m_pContextMenu, pApp-&amp;gt;GetAppPointer()) == false))
{
    ASSERT(0);
    delete m_pContextMenu;
    m_pContextMenu = NULL;
}

....

if (m_pContextMenu != NULL)
{
    BOOL b = acedRemoveObjectContextMenu(AcDbBlockReference::desc(), m_pContextMenu);
    delete m_pContextMenu;
    m_pContextMenu = NULL;
}&lt;/PRE&gt;
&lt;P&gt;Also be aware of&amp;nbsp;&lt;STRONG&gt;acedAddDefaultContextMenu&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;acedRemoveDefaultContextMenu&lt;/STRONG&gt; if you don't want to attach the menu to a specific class.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 00:03:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6884359#M8722</guid>
      <dc:creator>Kyudos</dc:creator>
      <dc:date>2017-02-17T00:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Adding items to the right click context menu</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6884372#M8723</link>
      <description>&lt;P&gt;Also remember, if your are just wanting to operate a pre-existing tool or function from the menu you can do that by specifying Shortcut Menus in your CUI file.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 00:09:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6884372#M8723</guid>
      <dc:creator>Kyudos</dc:creator>
      <dc:date>2017-02-17T00:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: Adding items to the right click context menu</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6886699#M8724</link>
      <description>&lt;P&gt;I figured out the error I was getting with the example file. &amp;nbsp;I was making changes to the release config but then building in debug. &amp;nbsp;The attached sample will work for anyone who wants to use it, just switch the build type to release.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still wondering if there is an easier way to add a single menu item without all the MFC overhead?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 20:17:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6886699#M8724</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-02-17T20:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Adding items to the right click context menu</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6886707#M8725</link>
      <description>&lt;P&gt;This appears to be what is being done in the example file? &amp;nbsp;I'm not an expert in MFC so maybe I'm missing something that's different in your code?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 20:20:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6886707#M8725</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-02-17T20:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Adding items to the right click context menu</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6888374#M8726</link>
      <description>&lt;P&gt;No, you are right - I almost certainly got my code from that example too. If it still seems like a lot of trouble though, it is easier to use the CUI menu configuration - especially to run a function or command you have already written.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll probably want to make sure your command can use the PICKFIRST selection set though, so that it can run straightaway (provided it needs to operate on an object of course)&lt;/P&gt;</description>
      <pubDate>Sun, 19 Feb 2017 07:29:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/adding-items-to-the-right-click-context-menu/m-p/6888374#M8726</guid>
      <dc:creator>Kyudos</dc:creator>
      <dc:date>2017-02-19T07:29:17Z</dc:date>
    </item>
  </channel>
</rss>

