I am engaged in secondary development of AutoCAD. net, and now. net + ObjectARX has formed a perfect combination. Unfortunately, it is currently available in China. net has too few materials for ObjectARX development. I will continue to share my learning experience with you and hope to pay attention to it.
Winapi reference: Public Class Winapi
{
# Region Macro definition
Public Const Int Wm_seticon = 0x80 ;
Public Const Int Imagw_icon = 1 ;
Public Const Int Lr_loadfromfile = 0x10 ;
# Endregion
# Region Winapi Definition
[Dllimport ( " User32.dll " , Entrypoint = " Sendmessage " )]
Public Static Extern Int Sendmessage (
Int Hwnd, // Handle to destination window
Int MSG, // Message
Int Wparam, // First message Parameter
Int Lparam // Second Message Parameter
);
[Dllimport ( " USER32 " , Entrypoint = " LoadImage " )]
Public Static Extern Int Loadimagea ( Int Hinst, String Lpsz, Int Un1, Int N1, Int N2, Int Un2 );
[Dllimport (" USER32 " , Entrypoint = " Setwindowtext " )]
Public Static Extern Int Setwindowtexta ( Int Hwnd, String Lpstring );
# Endregion
}
UsingSystem;
UsingSystem. IO;
//Using Microsoft. Win32;
UsingSystem. collections;
UsingSystem. Windows. forms;
UsingSystem. Resources;
Using Autodesk. AutoCAD. applicationservices;
Using Acadapp = Autodesk. AutoCAD. applicationservices. Application;
Using Autodesk. AutoCAD. colors;
Using Autodesk. AutoCAD. databaseservices;
Using Autodesk. AutoCAD. editorinput;
Using Autodesk. AutoCAD. geometry;
Using Autodesk. AutoCAD. runtime;
Using Autodesk. AutoCAD. windows;
UsingAutodesk. AutoCAD. InterOP;
UsingAutodesk. AutoCAD. InterOP. Common;
UsingAutodesk. AutoCAD. customization;
Public Class Asdkclass1: iextensionapplication
{
# Region Implement interface functions to complete Initialization
// To implement this interface, you must implement the initialize () and terminate () functions.
/// <Summary>
/// Initialization
/// </Summary>
Public Void Initialize ()
{
// --------------------
// Addcontextmenu ();
// Addtoolbar ();
// Addmenubar ();
Settitle ();
Seticon ();
// --------------------
}
/// <Summary>
/// Clear operation
/// </Summary>
Public Void Terminate ()
{
}
# Endregion
# Region Change the title and icon of the AutoCAD window
/// <Summary>
/// Change the title name of the AutoCAD window
/// </Summary>
Private Void Settitle ()
{
Acadapplication acadapp = Acadapp. acadapplication As Acadapplication;
Int Acadhwnd = Acadapp. hwnd; // Obtain the AutoCAD applicationProgramWindow handle
Winapi. setwindowtexta (acadhwnd, " Mingxin Power Supply CAD 2.0 " );
}
/// <Summary>
/// Change the icon of the AutoCAD window
/// </Summary>
Private Void Seticon ()
{
Acadapplication acadapp = Acadapp. acadapplication As Acadapplication;
Int Acadhwnd = Acadapp. hwnd; // Obtain the window handle of the AutoCAD application
String Path = Acadapp. path;
// Load icon from file (16*16 size)
String Filename = " G: \ CAD. ICO " ;
If (File. exists (filename ))
{
Int Hicon = Winapi. loadimagea ( 0 , Filename, winapi. imagw_icon, 16 , 16 , Winapi. lr_loadfromfile );
If (Hicon ! = 0 )
{
Winapi. sendmessage (acadhwnd, winapi. wm_seticon, 0 , Hicon );
}
}
}
# Endregion
}
: