Author Topic: Is control of the Active Window Title possible in AutoCAD?  (Read 5785 times)

0 Members and 1 Guest are viewing this topic.

KewlToyZ

  • Guest
Is control of the Active Window Title possible in AutoCAD?
« on: August 29, 2006, 03:37:53 PM »
I was curious if this could be done from a profile identification perspective?
Since this is an OS specific would it have to be an ARX app to handle on start-up?
Any feedback would be appreciated  :-)

nivuahc

  • Guest
Re: Is control of the Active Window Title possible in AutoCAD?
« Reply #1 on: August 29, 2006, 03:57:02 PM »
I believe Keith wrote something a while back that did exactly that... but I may be wrong. :)

KewlToyZ

  • Guest
Re: Is control of the Active Window Title possible in AutoCAD?
« Reply #2 on: August 29, 2006, 06:12:35 PM »
Thanks Nivuahc, My aplogies but is Keith's username Keith? I haven't quite gotten familiar with first names and nicknames yet  :|

Oops found posts under the username, now to narrow the search :-)
« Last Edit: August 29, 2006, 06:16:45 PM by KewlToyZ »

LE

  • Guest
Re: Is control of the Active Window Title possible in AutoCAD?
« Reply #3 on: August 29, 2006, 06:19:52 PM »
If what you are asking is to change autocad window title - that is possible with ObjectARX

KewlToyZ

  • Guest
Re: Is control of the Active Window Title possible in AutoCAD?
« Reply #4 on: August 29, 2006, 07:09:31 PM »
Here is the post from Keith:

Quote
Ok ... this is a VBA app so ....
In a new module paste the following code

Code:

Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal HWND As Long, ByVal lpString As String) As Long

Sub SetText()
 Dim RetVal As Long
 RetVal = SetWindowText(Application.HWND, Interaction.InputBox("Please enter new name for AutoCAD application"))
End Sub


When you run the code it will request a new name which you can type in, then it will change the name to what you entered.

If you want to make it set to a preset value, simply remove this portion

Code:

Interaction.InputBox("Please enter new name for AutoCAD application")
and replace it with a string enclosed in quotes.. like so...

Code:

Sub SetText()
 Dim RetVal As Long
 RetVal = SetWindowText(Application.HWND, "Dommy2HottyCAD"))
End Sub

Now to go through and learn how to build the module for each profile  :ugly:
Is this a module or a module class?

I'm leery of ObjectARX because of the changes with every build of AutoCAD.

MickD

  • King Gator
  • Posts: 3663
  • (x-in)->[process]->(y-out) ... simples!
Re: Is control of the Active Window Title possible in AutoCAD?
« Reply #5 on: August 29, 2006, 07:28:56 PM »
The vb/a code will work fine if you don't want to use arx.
Quote
I'm leery of ObjectARX because of the changes with every build of AutoCAD.

The AutoCAD part may change but anything to do with the window showing it will not change, SetWindowText/A()  is a function (imported into vba in this case) straight from the win32 api and can be used in any language that can import dll functions in this way.
To set the text of the mdi windows you will need to get a handle of the active window, in acad possibly through the document object(?).
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

KewlToyZ

  • Guest
Re: Is control of the Active Window Title possible in AutoCAD?
« Reply #6 on: August 29, 2006, 07:30:07 PM »
Wow that is sweeeet thanks to Keith for that bit of code and to nivuahc for remembering it!

Thanks for the response as well LE & MickD!
How would I do that with ObjectARX?
Actually how hard is it to learn? I have found very very little in text to learn it using Visual studio.
I have not gotten the configuration of it down yet?
Can I use the new Visual Studio Express 2005 for it with 2007 to program full applications?
I was considering using it since I'm dabbling with some web development with an SQL database and tracking issues in house in C#.

MickD

  • King Gator
  • Posts: 3663
  • (x-in)->[process]->(y-out) ... simples!
Re: Is control of the Active Window Title possible in AutoCAD?
« Reply #7 on: August 29, 2006, 07:55:11 PM »
C# would be your easiest bet and you can learn the arx api as you go, a bit of knowledge in C/C++ wouldn't go astray though to fully understand the api methods and parameters.
VS2005ee will be fine for all C# development, you just have to make sure you are using the correct .net lib version for your target. For ARX you would need VS2002 for acad 2005-6 and VS2005 will be for acad 2007.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

KewlToyZ

  • Guest
Re: Is control of the Active Window Title possible in AutoCAD?
« Reply #8 on: August 30, 2006, 10:34:16 AM »
Kewl! Thanks MickD. I have the arx library. I just started to touch base with it and found it too much of a nightmare to approach with versions 04, 06, 07 all running. Now everyone should be up to 07 with a few stragglers blaming the world for 07 and trying to run 04 still. Change can be a difficult thing for people, so I do tend to let them get in the water at their own pace. Part of it is because their projects are their priority, not re-learning how to do their tasks. Habits are important to productivity etc...

I'm also trying to introduce 48 seats of AutoDesk Building Systems in the next month as I find time to initialize the templates.
Somewhere in between I'm going to get my own feet wet with the 2007 ARX. Hell I'm still trying to adjust to the 2.0 framework and they have the 3.0 framework in beta lol!

KewlToyZ

  • Guest
Re: Is control of the Active Window Title possible in AutoCAD?
« Reply #9 on: August 30, 2006, 11:43:35 AM »
Is there a way to enable the macro without bringing up the Enable Macro's dialog during startup?
More or less can I give permission for this specific macro for all users without them dealing with it?
« Last Edit: August 30, 2006, 12:19:01 PM by KewlToyZ »

KewlToyZ

  • Guest
Re: Is control of the Active Window Title possible in AutoCAD?
« Reply #10 on: August 30, 2006, 01:41:32 PM »
Hmm it seems using the macro in the AutoCAD initial startup has some failure points.
If I open multiple drawings from windows explorer it leaves the command prompt with:
Open VBA Project:

And hangs there unable to enter.
The way I placed it into the start-up was by placing a line in the acad.mnl file:
Code: [Select]
(if (findfile "ActiveTitle.dvb")
    (progn
      (command "-vbaload" (findfile "ActiveTitle.dvb"))
      (command "-vbarun" "Module1.ActiveTitle")
      (command "vbaunload" "ActiveTitle")
    )
    (princ
      "\nThe file 'ActiveTtile.dvb was not found in your search path."
    )
  )
(autoload "ActiveTitle" '("ActiveTitle"))

Added a lisp routine:

Code: [Select]
(defun c:ActiveTitle ()
  (setup)
 
  (if (findfile "ActiveTitle.dvb")
    (progn
      (command "-vbaload" (findfile "ActiveTitle.dvb"))
      (command "-vbarun" "Module1.ActiveTitle")
      (command "vbaunload" "ActiveTitle")
    )
    (princ
      "\nThe file 'ActiveTtile.dvb was not found in your search path."
    )
  )
  (end)
)

It works fine opening CAD from a desktop shortcut but not opening a drawing from windows explorer.
I stand corrected it fails opening multiple files from a session already started as well.
I need to clean up the multiple references and start over again.
« Last Edit: August 30, 2006, 03:46:08 PM by KewlToyZ »

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Is control of the Active Window Title possible in AutoCAD?
« Reply #11 on: September 02, 2006, 02:07:43 PM »
It is entirely possible to have the vba snippet automagically deduce who the user is and update the title bar based on the user. You could put it in a single dvb file and load it at startup. It would automatically execute if you put it into the proper event handler.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie