Change caption of document window

M

Markus Breugst

Hi all,

we have a stand-alone application that interacts with Visio via the Visio
object model.
Among others, the application creates Visio documents. We would like to use
global unique identifiers (GUIDs) as filenames of the Visio documents.
However, this does not look very nice, since the filename is shown in the
titlebar of the document window, and GUIDs are not really made to be read by
humans.

Therefore, we tried to modify the caption of the document windows via the
SetWindowText method (user32) in order to substitute the GUID by a
human-readable document name:

IntPtr hwnd = (IntPtr) this.visioApplication.ActiveWindow.WindowHandle32; //
or WindowHandle
SetWindowText( hwnd, "NEW DOCUMENT NAME" )

Unfortunately, it does not work. The caption remains unchanged.
However, it does work for the application's main window, where the window
handle is
this.visioApplication.WindowHandle32.

So, if the document window is maximized, the document file name appears in
the main window title bar, and everything's fine (we can change the
caption). But if we have multiple documents open and cascaded or tiled, each
document has its own window, and the titlebars show the GUID filenames and
cannot be changed.

Does anybody have an idea how to solve this problem?

Thanks a lot in advance,
Markus
 
M

Mark Nelson [MS]

Unfortunately, Visio does not enable this functionality and using
SetWindowText is not recommended. Visio will overwrite the caption whenever
it needs to refresh its UI.
 
M

Markus Breugst

Hi Mark,

thank you for your answer.

Instead of renaming the window, we now rename the visio files. After opening
a file, we save it with a temporary (human-readable) file name, and when
closing the file, we save it back to the original name which has a GUID
format.

Best regards,
Markus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top