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

Customize AutoCAD icon coming at the extreme top of AUTOCAD applicatio​n.

6 REPLIES 6
Reply
Message 1 of 7
Avadhut.Khavare
1574 Views, 6 Replies

Customize AutoCAD icon coming at the extreme top of AUTOCAD applicatio​n.

Hi,

 

I want to programatically remove the AutoCAD icon coming at the extreme top of AUTOCAD application

(I am using C# to customize the AutoCAD application)

 

Is there any API where i can show customized icon instead of AUTOCAD icon.

 

If above is not possible is there any way to reduce the size of that icon?

 

Thanks in advance!

 

Regards,

Avadhut K

6 REPLIES 6
Message 2 of 7

Prior to AutoCAD 2009 (e.g. before the ribbon and the big icon button at top left of Acad main window were introduced), you can use Windows API to set AutoCAD's main window icon and title. See the picture below were the icon and title of AutoCAD's main window has been changed to custom icon and text:

 

untitled.GIF

 

However, since AutoCAD 2009, the same Window API code that changes Window's icon has no effect any more, though the windows title can still be changed. I guess, because of the AUtoCAD main windows icon is not just an icon, it is a function button. I do not think you can change it, nor Autodesk wamts you to change it.

 

 

Message 3 of 7

Thanks for reply,

Can you share the API name so that i can verify if it is possible to change the icon?

Message 4 of 7

As I said, changing icon with Win API only works with Acad2008 or older. The picture shown in my previous reply is with Acad2008. I have Acad2006/2008/2009/2011 installed with my various computers. I have tried it with Acad2009 and later. Here is the code anyway:

 

public class WinAPI
    {
        public const int WM_SETICON = 0x80;
        public const int IMAGW_ICON = 1;
        public const int LR_LOADFROMFILE = 0x10;

        [DllImport("User32.dll", EntryPoint = "SendMessage")]
        public static extern int SendMessage(
            int hWnd, int Msg, int wParam, int IParam);

        [DllImport("User32.dll", EntryPoint = "LoadImage")]
        public static extern int LoadImageA(int hInst, string Ipsz, int un1, int n1, int n2, int un2);

        [DllImport("User32.dll", EntryPoint = "SetWindowText")]
        public static extern int SetWindowTextA(int hwnd, string IpString);
    }

 

public class MyClass : IExtensionApplication
    {
        #region IExtensionApplication Members

        public void Initialize()
        {
            try
            {
                SetAcadWindowTitleAndIcon();
            }
            catch { }
        }

        public void Terminate()
        {
            
        }

        #endregion

        private static void SetAcadWindowTitleAndIcon()
        {
            AcadApplication app = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as AcadApplication;
            int wHnd = app.HWND;

            //Set title
            string title = "AutoCAD with XXXX Tool";
            WinAPI.SetWindowTextA(wHnd, title);

            //Set icon
            string iconFile = "E:\\Work\\Acad\\OIcon.ico";
            if (System.IO.File.Exists(iconFile))
            {
                int hIcon = WinAPI.LoadImageA(0, iconFile, WinAPI.IMAGW_ICON, 16, 16, WinAPI.LR_LOADFROMFILE);
                if (hIcon != 0)
                {
                    WinAPI.SendMessage(wHnd, WinAPI.WM_SETICON, 0, hIcon);
                }
            }
        }

 

Message 5 of 7

OK.

Thanks I will try it in AutoCAD 2011 64 bit.

Message 6 of 7

Now there's a go-getter type of person!  Smiley Happy

Steven Elliott

When I was a little bitty boy, my grandmother bought me a cute little toy. Silver bells hangin' on a string... she told me it was my ding-a-ling-a-ling!
Message 7 of 7
celsoven
in reply to: norman.yuan

Hello

 

I'm looking for a program that do it, i'm using AutoCAD 2008

 

I copy your code and paste in a C# but i have some questions

 

I add references

 

autodesk.autocad.interop.

autodesk.autocad.interop.common

acmgdinternal

acmgd

dotnetarx

 

what else i need to run this routine and where i need to place the program

 

thanks a lot.

 

you're so intelligent

 

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