.NET

Reply
Active Member
Avadhut.Khavare
Posts: 6
Registered: ‎02-01-2011
Message 1 of 7 (1,064 Views)

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

1064 Views, 6 Replies
04-05-2011 03:49 AM

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

*Expert Elite*
norman.yuan
Posts: 1,016
Registered: ‎04-27-2009
Message 2 of 7 (1,047 Views)

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

04-05-2011 07:01 AM in reply to: Avadhut.Khavare

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.

 

 

Active Member
Avadhut.Khavare
Posts: 6
Registered: ‎02-01-2011
Message 3 of 7 (1,042 Views)

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

04-05-2011 07:17 AM in reply to: norman.yuan

Thanks for reply,

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

*Expert Elite*
norman.yuan
Posts: 1,016
Registered: ‎04-27-2009
Message 4 of 7 (1,039 Views)

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

04-05-2011 07:24 AM in reply to: Avadhut.Khavare

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

 

Active Member
Avadhut.Khavare
Posts: 6
Registered: ‎02-01-2011
Message 5 of 7 (1,036 Views)

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

04-05-2011 07:35 AM in reply to: norman.yuan

OK.

Thanks I will try it in AutoCAD 2011 64 bit.

Valued Mentor
stevenelliott3894
Posts: 474
Registered: ‎06-14-2010
Message 6 of 7 (993 Views)

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

04-07-2011 05:36 AM in reply to: Avadhut.Khavare

Now there's a go-getter type of person!  :smileyhappy:

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!
Valued Contributor
celsoven
Posts: 80
Registered: ‎06-25-2009
Message 7 of 7 (807 Views)

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

08-03-2011 07:27 AM 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

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.