Retrieves a Boolean value that indicates the open or closed state of the window. Scriptable.

Syntax

HRESULT IsClosed(
   [out,
   retval] VARIANT_BOOL* pBoolClose
);

Parameters

pBoolClose

Pointer to a VARIANT_BOOL that defines the open and closed state for the messenger window with one of the following possible values in the following table.

VARIANT_TRUE

The Office Communicator UI window is closed. This means that it has no HWND or window handle either numerically or on a system level. Attempts to reference some functions in the Microsoft® Win32® API against the window fails. The client can continue to exist as a running executable and can potentially be seen in process lists and in minimized form in the notification area or system tray.

VARIANT_FALSE

The application window is either visible or minimized and has a valid HWND or window handle.

Return Value

Returns one of the following values. For managed code applications, these return values are received in the form of a COMException

S_OK

Success.

RPC_X_NULL_REF_POINTER

pBoolClose is a null pointer.

E_FAIL

The conversation window on which this method is called is an IMessengerConversationWnd object and is closed but not released.

Remarks

This method is useful when this interface is called against the application window. The method can be called against a conversation window, but returns false for any case in which a valid MessengerWindow object existed to call the method against. If the conversation window that corresponds to the object is closed by client action, a COMExeption E_FAIL is raised.

When the user closes a conversation window, Office Communicator Automation API raises an DMessengerEvents::OnIMWindowDestroyed event. It is a good practice to make the event handler release the IMessengerConversationWnd representing the conversation using the following syntax where pIMWindow is the argument passed to the event handler.

Copy Code
Marshal.ReleaseComObject(pIMWindow);

When the conversation window is released using this code, any references to it raises a NULLException error.

Calling IsClosed on the Office Communicator window itself returns true or false. A minimized window is considered to be closed or not closed based on the visibility settings through Show, Close, or equivalent UI settings.

Example

The following code example reads the IsClosed property of the ImessengerWindow interface object messengerWindow. If the Office Communicator UI window is open or minimized, the code writes "Window is Open" to the console window. If the Office Communicator UI window is closed to the system tray, the code writes "Window is Closed" to the console window.

If the messengerWindow object is an IM window rather than an application window, the object raises an exception that is caught by the code. The exception error code is written to the console window.

Copy Code
try
{
   if (messengerWindow.IsClosed == true)
	 Console.WriteLine("Window is closed");
   else
	 Console.WriteLine("Window is Open");
 }
 catch (COMException CMIC)
 {
	Console.WriteLine(CMIC.ErrorCode.ToString());
 }

Requirements

Client

Requires Microsoft DirectX 9.0, C Runtime libraries (msvcm80.dll) on Microsoft Windows© Vista, Microsoft Windows XP Service Pack 1 (SP1) or later, or Microsoft Windows 2000 with Service Pack 4 (SP4). Any Communicator-imposed restrictions apply. .

Server

Requires Microsoft Office Communications Server 2007, AV MCU (for Media Support), Media Relay (for NAT/Firewall traversal) on Microsoft Office Communications Server 2007.

Product

Microsoft Office Communicator 2007 Automation API

IDL file

Msgrua.idl

See Also

Reference

IMessengerWindow::Show