Application.Caption Issue

Hi,

I've just started looking to test what can be displayed in the title bar and I am finding that I am getting additional numbers with brackets after at the end of the information I want displayed. I'm running dual screens and the Left monitor by default has a (1) in the title bar and the right a (2). Now I'm getting (1) (2) (1) on the left and (1) (2) (1) (2) on the right but I cant figure out why these are appearing. I would prefer that none were visible at all if possible. The code I have been using is :

Public Sub hooks_OnDesignFileOpened(ByVal fileName As String)
Dim UsersName As String
Dim FullPath As String
Const str_USTN_USERNAME As String = "$(_USTN_USERNAME)"
Const str_DGNFILE As String = "$(_DGNFILE)"
UsersName = ActiveWorkspace.ExpandConfigurationVariable(str_USTN_USERNAME)
FullPath = ActiveWorkspace.ExpandConfigurationVariable(str_DGNFILE)
Application.Caption = FullPath & " : " & UsersName & " : "
Debug.Print "Application.Caption"
End Sub


 In addition to this:

  1. is it possible to display the date in the title bar? 
  2. Where can I find what else I can put in the title bar, I know about Microstation variables but is there other objects/things?

Thanks

Parents
  • A workaroud is as below:

    Declare Function mdlNativeWindow_getMainHandle Lib "stdmdlbltin.dll" (ByVal iScreen As Long) As Long
    Declare Function SetWindowTextA Lib "user32.dll" (ByVal hwnd As Long, ByVal lpString As String) As Boolean
    Sub SetDualScreenAppTitle(iScreen As Long, title As String)
       Dim winHandle As Long
       winHandle = mdlNativeWindow_getMainHandle(iScreen)
       SetWindowTextA winHandle, title
    End Sub
    Sub Test()
       SetDualScreenAppTitle 0, "Screen 0"
       SetDualScreenAppTitle 1, "Screen 1"
    End Sub

    HTH, Yongan.Fu



  • Thanks

    It might sound a simple question but how do I use this code along with my custom title?

  • Copy and paste Fu's example code into a VBA module.  Place your cursor in the 'Test' subroutine, and run.  You should see the Window captions change.  If that does what you want, then change 'Screen 0' and 'Screen 1' to your title.  

     
    Regards, Jon Summers
    LA Solutions

  • Thanks Jon

    I did as you said and sure enough the monitor titles do change to Screen 0 and Screen 1.

    So I've now tried to get this to load each time I open a file so I've merged Fu's code with some of my former code so its now all in a single Code Module and looks like:

    Option Explicit
    Private m_oOpenClose As clsOpenClose
    ' ---------------------------------------------------------------------
    Const strMODULE_NAME As String = "modMain"
    Declare Function mdlNativeWindow_getMainHandle Lib "stdmdlbltin.dll" (ByVal iScreen As Long) As Long
    Declare Function SetWindowTextA Lib "user32.dll" (ByVal hwnd As Long, ByVal lpString As String) As Boolean
    Sub SetDualScreenAppTitle(iScreen As Long, title As String)
    Dim winHandle As Long
    winHandle = mdlNativeWindow_getMainHandle(iScreen)
    SetWindowTextA winHandle, title
    End Sub
    Public Sub OnProjectLoad()
    Set m_oOpenClose = New clsOpenClose
    Dim UsersName As String
    Dim File As String
    Const strUsers_Full_Name As String = "$(_FullName)"
    Const str_DGNFILE As String = "$(_DGNFILE)"
    UsersName = ActiveWorkspace.ExpandConfigurationVariable(strUsers_Full_Name)
    File = ActiveWorkspace.ExpandConfigurationVariable(str_DGNFILE)
    SetDualScreenAppTitle 0, File
    SetDualScreenAppTitle 1, "Current User: " & UsersName & " - Todays Date: " & Date
    End Sub

    The problem is that its not changing the title automatically as it was previously. If I run it manually it does work so I can't understand why its not working when I open a drawing but then again I know nothing about VBA so I'm probably making an obvious error.

    Also, I've been trying to understand IModelActivateEvents as per Roberts suggestion. Can you script it so that the same code used in the openclose class is run each time a model change is activated? The end result I want is a custom title bar that remains visible in all models.

Reply
  • Thanks Jon

    I did as you said and sure enough the monitor titles do change to Screen 0 and Screen 1.

    So I've now tried to get this to load each time I open a file so I've merged Fu's code with some of my former code so its now all in a single Code Module and looks like:

    Option Explicit
    Private m_oOpenClose As clsOpenClose
    ' ---------------------------------------------------------------------
    Const strMODULE_NAME As String = "modMain"
    Declare Function mdlNativeWindow_getMainHandle Lib "stdmdlbltin.dll" (ByVal iScreen As Long) As Long
    Declare Function SetWindowTextA Lib "user32.dll" (ByVal hwnd As Long, ByVal lpString As String) As Boolean
    Sub SetDualScreenAppTitle(iScreen As Long, title As String)
    Dim winHandle As Long
    winHandle = mdlNativeWindow_getMainHandle(iScreen)
    SetWindowTextA winHandle, title
    End Sub
    Public Sub OnProjectLoad()
    Set m_oOpenClose = New clsOpenClose
    Dim UsersName As String
    Dim File As String
    Const strUsers_Full_Name As String = "$(_FullName)"
    Const str_DGNFILE As String = "$(_DGNFILE)"
    UsersName = ActiveWorkspace.ExpandConfigurationVariable(strUsers_Full_Name)
    File = ActiveWorkspace.ExpandConfigurationVariable(str_DGNFILE)
    SetDualScreenAppTitle 0, File
    SetDualScreenAppTitle 1, "Current User: " & UsersName & " - Todays Date: " & Date
    End Sub

    The problem is that its not changing the title automatically as it was previously. If I run it manually it does work so I can't understand why its not working when I open a drawing but then again I know nothing about VBA so I'm probably making an obvious error.

    Also, I've been trying to understand IModelActivateEvents as per Roberts suggestion. Can you script it so that the same code used in the openclose class is run each time a model change is activated? The end result I want is a custom title bar that remains visible in all models.

Children
No Data