- UID
- 1
- 积分
- 16111
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Question
How can I change the text displayed in the AutoCAD title bar using VBA?
Answer
The text displayed in the AutoCAD title bar can be changed by using the Win32
API functions, GetActiveWindow and SetWindowText. Refer the MSDN CD for more
details on these functions.
The sample VBA code that follows extracts and changes the text in the AutoCAD
title bar. Enter the following lines of code in a general module:
Public Declare Function GetActiveWindow Lib "user32" () As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal
hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal
hwnd As Long, ByVal lpString As String) As Long
and the following lines of code in AutoCAD Objects Module
Sub ch_titlebar()
Dim acadhnd As Long
Dim titletxt As String
Dim curtxt As String
titletxt = "This is my version of AutoCAD."
curtxt = Space(256)
'Obtains the handle of AutoCAD window.
acadhnd = GetActiveWindow
'Obtain the current text in the titlebar.
GetWindowText acadhnd, curtxt, 125
MsgBox curtxt
'Set the desired text for the titlebar.
SetWindowText acadhnd, titletxt
End Sub |
|