Forum Migration Notice
We're transitioning to a more modern community platform by the end of this year. Learn about the upcoming changes and what to expect.
Disable Close Button in TP Application
in RobotStudio
Hey all,
I'm trying to disable the close button on my robot application and add my own close button within the application itself. I want to do this so i am able to ask the operator with a gtpumessagebox if he/she really wants to close the application (because doing so results in the robot system going into a controlled shutdown state and subsequently shutting down).
The trouble i am having is not knowing how to disable the close button.
Can anyone please help.
0
Comments
-
Hi,
here is a VSTA macro that could solve your problem:
using System.Runtime.InteropServices;
[DllImport("user32.dll", EntryPoint = "GetSystemMenu")]
private static extern IntPtr GetSystemMenu(IntPtr hwnd, int revert);
[DllImport("user32.dll", EntryPoint = "GetMenuItemCount")]
private static extern int GetMenuItemCount(IntPtr hmenu);
[DllImport("user32.dll", EntryPoint = "RemoveMenu")]
private static extern int RemoveMenu(IntPtr hmenu, int npos, int wflags);
[DllImport("user32.dll", EntryPoint = "DrawMenuBar")]
private static extern int DrawMenuBar(IntPtr hwnd);
public void Macro_DisableCloseButton()
{
const int MF_BYPOSITION = 0x0400;
const int MF_DISABLED = 0x0002;
IntPtr win = ABB.Robotics.RobotStudio.Environment.UIEnvironment.MainWindo w.Handle;
IntPtr hmenu = GetSystemMenu(win, 0);
int cnt = GetMenuItemCount(hmenu);
// remove close action and extra menu line
RemoveMenu(hmenu, cnt-1, MF_DISABLED | MF_BYPOSITION);
RemoveMenu(hmenu, cnt-2, MF_DISABLED | MF_BYPOSITION);
}
Don't forget to add the refernce System.Windows.Forms.
0 -
Thanks for your help!0
Categories
- All Categories
- 5.7K RobotStudio
- 401 UpFeed
- 21 Tutorials
- 16 RobotApps
- 306 PowerPacs
- 407 RobotStudio S4
- 1.8K Developer Tools
- 251 ScreenMaker
- 2.9K Robot Controller
- 366 IRC5
- 88 OmniCore
- 8 RCS (Realistic Controller Simulation)
- 857 RAPID Programming
- 42 AppStudio
- 4 RobotStudio AR Viewer
- 19 Wizard Easy Programming
- 111 Collaborative Robots
- 5 Job listings
