If the method succeeds, the return value is the length of the document
title in characters, not including the terminating null. If the
document does not have a title or the method fails, the return value
is zero. To get extended error information, call GetLastError.
The GetDocumentTitle method returns the current
title of the document loaded in the browser. This corresponds to the
contents of the <title> element in the document's
<head> section, if one is defined.
The title is not fixed at the time the page is first loaded. A
script running in the document can modify the <title>
element dynamically, and some web applications use this technique
to reflect state changes (for example, to indicate new messages or status
updates). Because of this, the value returned by this method may
change over the lifetime of the page. If the document does not
explicitly define a title, the method may return an empty string.
Applications that display document titles should be prepared to handle
this case.
If the browser window was created using Create
without a specific title, the
application title will be automatically changed to reflect the current
document title. This does not happen if the browser window is attached
to an existing window or if an application title was specified when
the window was created. If you wish to manually update a top-level
window title with the current document title, call this method in
response to a WEBVIEW_EVENT_NAVIGATION_COMPLETED event
and then call the SetWindowText function to change the text in
the window's title bar.
If the current document does not have a title, this method will
return zero and the last error code will be set to NO_ERROR.
If the lpszTitle parameter is not NULL, it will be set to an
empty string when the method returns. This is not uncommon if the
SetDocumentText method is called to change the current
document and the text does not contain HTML markup or does not
include a <title> tag.