.NET

.NET

Reply
Post 1 of 9

Toolbar Enable/Disable via .net?

388 Views, 8 Replies
10-26-2015 09:39 AM

When AutoCAD is loading (using Autocad 2015), I see that my toolbars are disabled (grayed-out) until the loading has finished.  Our company does some additional data loading after AutoCAD has become idle.  But if the user clicks certain custom toolbar buttons while our additional data is loading, AutoCAD fatal errors.  Is there a way we can disable the toolbars (like AutoCAD does) until our loading is finished, and then enable them?  I haven't been able to locate an API that provides this capability.  Any suggestions greatly appreciated!

Kind Regards,

Pete Elliott

Post 2 of 9

Re: Toolbar Enable/Disable via .net?

02-15-2016 07:29 AM in reply to: elliottpd1

Hi Pete,

 

Does this post help? I assumed you meant the ribbon, rather than toolbars, but let me know if that's not the case:

 

http://through-the-interface.typepad.com/through_the_interface/2016/02/disabling-the-autocad-ribbon-...


Regards,

 

Kean



Kean Walmsley

Platform Architect & Evangelist, Autodesk Research

Blog | Twitter
Post 3 of 9

Re: Toolbar Enable/Disable via .net?

02-15-2016 09:23 AM in reply to: kean.walmsley

Yes, that helps a great deal and we will use it!  But I did mean the toolbars.  We have both available via our Enterprise menu plus through code. Thanks for your efforts, they are very much appreciated.

Best Regards,

Pete Elliott

Re: Toolbar Enable/Disable via .net?

02-15-2016 02:47 PM in reply to: elliottpd11

elliottpd11 написано:

Yes, that helps a great deal and we will use it!  But I did mean the toolbars.  We have both available via our Enterprise menu plus through code. Thanks for your efforts, they are very much appreciated.

Best Regards,

Pete Elliott


If I understand you correctly, you can use ActiveX/COM API to do your's toolbar visible/invisible


Alexander Rivilis / Александр Ривилис
Programmer & Teacher & Helper / Программист - Учитель - Помощник
Facebook | Twitter | LinkedIn

Post 5 of 9

Re: Toolbar Enable/Disable via .net?

02-16-2016 12:42 AM in reply to: elliottpd11

Glad if it was of some use, at least. :-)

 

Here's a follow-up attempt, which should cover both the ribbon and any visible toolbars:

 

http://through-the-interface.typepad.com/through_the_interface/2016/02/disabling-autocads-toolbars-u...

 

Best,

 

Kean



Kean Walmsley

Platform Architect & Evangelist, Autodesk Research

Blog | Twitter

Re: Toolbar Enable/Disable via .net?

02-16-2016 12:53 AM in reply to: kean.walmsley

Hi, Kean!

It seems to me that there is no need to turn off all the visible toolbars. Maybe just enough to turn off own toolbars (e.g. create list of their names and off/on with this list)


Alexander Rivilis / Александр Ривилис
Programmer & Teacher & Helper / Программист - Учитель - Помощник
Facebook | Twitter | LinkedIn

Post 7 of 9

Re: Toolbar Enable/Disable via .net?

02-16-2016 01:01 AM in reply to: Alexander.Rivilis

Hi Alexander,

 

True - that's certainly an option, depending on your needs. I personally like this approach, but the basic technique could certainly be adapted to do what you've suggested.

 

Best,

 

Kean



Kean Walmsley

Platform Architect & Evangelist, Autodesk Research

Blog | Twitter
Highlighted

Re: Toolbar Enable/Disable via .net?

02-16-2016 02:51 PM in reply to: kean.walmsley

With help of ObjectARX and Win32/MFC it possible to temporary disable all UI elements:

 

static void DisableUI () 
{
    CMDIFrameWnd *frame = acedGetAcadFrame();
    // Disable AutoCAD Frame, Ribbon, Toolbars, etc.
    frame->EnableWindow(FALSE);
    // Invoke progressbar
    acedSetStatusBarProgressMeter(_T("Loading My Critical Data"), 0, 10);
    for (int i = 0; i < 10; i++)
    {
     Sleep(1000); // Only for testing 
     acedSetStatusBarProgressMeterPos(i);
    }
    acedRestoreStatusBar();
    // Enable AutoCAD Frame, Ribbon, Toolbars, etc.
    frame->EnableWindow(TRUE);
}

 

Other possibility is using BlockInput function:

[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern bool BlockInput([In, MarshalAs(UnmanagedType.Bool)] bool fBlockIt);

To block keyboard and mouse input:

BlockInput(true);

To unblock keyboard and mouse input:

BlockInput(false);

 


Alexander Rivilis / Александр Ривилис
Programmer & Teacher & Helper / Программист - Учитель - Помощник
Facebook | Twitter | LinkedIn

Post 9 of 9

Re: Toolbar Enable/Disable via .net?

02-16-2016 11:49 PM in reply to: Alexander.Rivilis

Excellent suggestion, Alexander!

 

I took the first MFC snippet and used the same approach using P/Invoke from C#:

 

http://through-the-interface.typepad.com/through_the_interface/2016/02/disabling-autocads-complete-u...

 

Kean



Kean Walmsley

Platform Architect & Evangelist, Autodesk Research

Blog | Twitter
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post