Autocad.net (1): Change the title and icon of the AutoCAD window

Source: Internet
Author: User
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
}

:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.