Jump to content
Hash, Inc. Forums

Archived

This topic is now archived and is closed to further replies.

nemyax

Plugin availability in context menus

Recommended Posts

I can't work out how to make a plugin's menu entry visible when CPs are selected. Presumably this is determined by the HxtLoadCommandEntry function, but the entry gets hidden whenever any CPs are selected. Even an always-true definition like the one below doesn't make a difference:

extern "C" __declspec(dllexport) BOOL HxtOnAddCommandMenu(
    HTreeObject *htreeobject,
    UINT index,
    String &menuname,
    MenuCategory &mc,
    BOOL &disabled)
{
	menuname = g_str_menu_name;
	disabled = FALSE;
	mc = MC_GENERAL;
	return TRUE;
}

How do I control availability correctly?

Share this post


Link to post
Share on other sites

Try this (entry.cpp)

#include "StdAfx.h"
#include "Resource.h"
#include "MeasureDist.h"

enum {CP,MGROUP};
extern "C" __declspec(dllexport) const BOOL HxtLoadCommandEntry(UINT index, ObjectType &objtype)
{
   switch (index) {
   case CP:
     objtype = HOT_CP;
     return TRUE;
   case MGROUP:
      objtype = HOT_GROUP;
      return TRUE;
  }
   return FALSE;
}

extern "C" __declspec(dllexport) BOOL HxtOnAddCommandMenu(HTreeObject *htreeobject, UINT index, String &menuname, MenuCategory &mc, BOOL &disabled)
{
   AFX_MANAGE_STATE(AfxGetStaticModuleState());

   CString string;
   string.LoadString(IDS_STRING1);
   menuname = (LPCTSTR)string;

   disabled = FALSE;
   mc = MC_WIZARD;

   switch (index) {
   case CP:
      return TRUE;
   case MGROUP:
      return TRUE;
   }
   return FALSE;
}

extern "C" __declspec(dllexport) BOOL HxtOnCommand(HTreeObject *htreeobject, UINT index)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
   switch (index) {
   case CP:
      return ((CMeasureDistApp *)AfxGetApp())->OnCP((HCP *)htreeobject);
   case MGROUP:
      return ((CMeasureDistApp *)AfxGetApp())->OnGroup((HGroup *)htreeobject);
	  break;
   }
   return FALSE;
}


Share this post


Link to post
Share on other sites

×