Avoiding Visible User Interface Elements

Windows Media Center prevents unauthorized applications from executing in a Windows Media Center Extender session. If any process other than Ehshell.exe tries to display UI elements in a Windows Media Center Extender session, Windows Media Center ends the session and displays an error message. To prevent this, ensure that your application does not display any UI elements at run time. If your application needs to create a window (for example, for inter-process communication purposes), be sure the window is hidden.

Windows applications developed with Microsoft Visual Basic 6.0 require special code to ensure that all windows are hidden. All form properties developed in the Visual Basic development environment must have their form properties set to hidden, and at run time the parent window for the application must be hidden. This is because the Visual Basic Runtime processes events by using a window with a height of zero and a width of zero. To hide this window, add the following code to your application:

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

Const GWL_HWNDPARENT = (-8)

Private Sub HideVBParent()

Dim hWnd As Long
Dim hParent As Long
Dim lRtn As Long

hWnd = Me.hWnd
hParent = GetWindowLong(hWnd, GWL_HWNDPARENT)
lRtn = ShowWindow(hParent, 0)

End Sub

If you call the HideVBParent subroutine from within your application's Form_Load event handler, the parent window will be hidden.

See Also