Hi,
I'd like to replicate the PLINE grip menu on my custom entity : when grip is hovered, a menu is displayed (actions = Stretch Vertex, Add Vertex, Remove Vertex).
For now, I can display a context menu by:
BOOL result = pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, p.x + 15, p.y + 20, AfxGetMainWnd());(where p is a POINT representing the current cursor location)
I don't know if this is the right way because the point of the grip is blue (as if it was warm), while for the PLINE it becomes orange (see the image above).
And I like to know how to begin move grip process? The PLINE menu launches the command GRIP_STRETCH. I tried to use the same command but I was unable to execute it with:
acedCommand(RTSTR, _T("_.grip_stretch"), RTENAME, pickSet, RTNONE);
Maybe someone can provide an example? All suggestions are welcomed.
Regards,
Jonathan
Solved! Go to Solution.
Solved by fenton.webb. Go to Solution.
Check out the class AcDbMultiModesGripPE class in dbMultiModesGrip.h in the ObjectARX SDK
Thank you for your answer. It could be a good solution, but I'm using OARX 2010 and I guess AcDbMultiModesGripPE appeared in OARX 2012 or 2013. Is there another solution or it's only a new feature of next OARX?
Hello,
The API for multi-functional grips was introduced in ObjectARX 2012 although AutoCAD had it as a feature in 2011.
Sorry, there is no way to get it using 2010 SDK.
Ok. Thank you for your anwser. I was able to reproduce this feature with a little time and perseverance.
Regards,
Jonathan
I also encounter this problem, in the hover function, how to start movegrip process, could you share your solution? thanks
Hi,
I opted for the following solution : simulate a mouse click on the grip point using SendInput. Here is my function
void BcGripFunctions::makeGripHot(const POINT & pt) { POINT ptOriginal; GetCursorPos(&ptOriginal); //move mouse cursor (to simulate click on the right point INPUT Input = {0}; long fScreenWidth = GetSystemMetrics(SM_CXSCREEN) - 1; long fScreenHeight = GetSystemMetrics(SM_CYSCREEN) - 1; float fx = pt.x * (65535.0f / fScreenWidth); float fy = pt.y * (65535.0f / fScreenHeight); Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE; Input.mi.dx = (long)fx; Input.mi.dy = (long)fy; SendInput(1, &Input, sizeof(INPUT)); ZeroMemory(&Input, sizeof(INPUT)); //simulate mouse (left) click Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; SendInput(1, &Input, sizeof(INPUT)); ZeroMemory(&Input, sizeof(INPUT)); Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_LEFTUP; SendInput(1, &Input, sizeof(INPUT)); ZeroMemory(&Input, sizeof(INPUT)); //restore original position fx = ptOriginal.x * (65535.0f / fScreenWidth); fy = ptOriginal.y * (65535.0f / fScreenHeight); Input.type = INPUT_MOUSE; Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE; Input.mi.dx = (long)fx; Input.mi.dy = (long)fy; SendInput(1, &Input, sizeof(INPUT)); ZeroMemory(&Input, sizeof(INPUT)); }
The process is :
I'm aware this solution isn't a perfect solution, but it's the only one I found. I use it for a while and my customers did not report any issue.
I hope this will be helpful.
Regards,
Hi Jonathan,
Glad to know you have found a solution that works without any issues.
In future if you need to implement it using multi-mode grips you may find this useful :
http://adndevblog.typepad.com/autocad/2013/12/grip-context-menu-using-acdbmultimodesgrippe.html
Regards,
Balaji
I tried the solution of Balaji and If you have no need of using OARX 2010, I advice you use this easier and more confortable solution.
One question for Balaji : I have not been able to define a specific cursor for my GripMode. I use :
gripMode.CursorType = kcCrosshairPlus;
To obtain this:
In my solution, I use a transient entity with an AcEdInputPointMonitor to draw it near the cursor.
Can you help me?
Regards,
Thanks for your help first, but I encounter another problem, when I right click the grip point quickly enough, and before the hover menu shows(follow your method), CAD application may crash,perhaps, it is because CAD pop up its own right click menu when my hovergripfun executing,
Is this the true cause?
And is there a possible solution?
Regards
I find the reason. It is because I pass acedGetAcadFrame() to the menu's TrackPopupMenu() , I changed it to acedGetAcadDwgView(), then, CAD works well when pop my hover menu.
Thanks!