.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Toolbar Enable/Disable via .net?

8 REPLIES 8
Reply
Message 1 of 9
elliottpd1
809 Views, 8 Replies

Toolbar Enable/Disable via .net?

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

8 REPLIES 8
Message 2 of 9
kean.walmsley
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
Message 3 of 9
elliottpd11
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

Message 4 of 9


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

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


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

Message 5 of 9
kean.walmsley
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
Message 6 of 9

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)

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


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

Message 7 of 9

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
Message 8 of 9

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);

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


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

Message 9 of 9

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost