Share via


IXRWin32Control (Windows Embedded CE 6.0)

1/6/2010

This class represents a Win32 control in a Silverlight for Windows Embedded application.

Syntax

class IXRWin32Control : public IXRControl

Methods

Method Description

IXRWin32Control::GetClassName

Retrieves the name of the class that this IXRWin32Control object belongs to.

IXRWin32Control::GetHandle

Retrieves the handle to this IXRWin32Control object.

IXRWin32Control::SetClassName

Sets the name of the class that this IXRWin32Control object belongs to.

IXRWin32Control::SetHandle

Sets an existing window handle as the new handle for this IXRWin32Control object, so that the IXRWin32Control object represents a child window control of the visual host window.

Remarks

You can use a Win32 control to create a control that has a WndProc. The WndProc for the control has message-handling behavior that is separate from the message-handling behavior for the WndProc for the main window.

You can use this class to create an IXRWin32Control control, add it to the visual tree that is attached to the visual root of your application, and then set its handle to your own window control. For more information, see Add a Window Control to a Silverlight for Windows Embedded Application.

When the Win32 control receives UI focus, its WndProc processes all the input messages. When the user presses the TAB key, if you did not add custom event handling code for the TAB event in the WndProc for the Win32 control, Silverlight handles the TAB event by giving focus to the next object in the visual-host window.

Note

Do not implement custom event-handling code for the TAB event in the WndProc for the Win32 control. Silverlight handles the TAB event for the Win32 control by giving the UI focus back to the main window.

To create an IXRWin32Control object in Silverlight and associate it with the handle to a window control, you can use several methods in IXRControl and in other inherited classes. By using these methods, the window control can leverage qualities such as animation storyboards, position, and layout. You can set properties associated with the following inherited methods by calling these methods or by defining the associated XAML attributes in the source Microsoft Silverlight 2 XAML file.

Note

Calling any other methods in parent classes that set values results in an error.

Method Description

IXRFrameworkElement::SetHeight

Sets the height of the Win32 control.

IXRFrameworkElement::SetHorizontalAlignment

Sets the horizontal-alignment characteristics that determine the position of the Win32 control when Silverlight displays it within a parent element, such as a panel control or an items control.

IXRControl::SetIsTabStop

Sets a value that indicates whether Silverlight includes the Win32 control in the tab order for UI focus.

IXRFrameworkElement::SetMargin

Sets the width of the frame that surrounds the Win32 control.

IXRFrameworkElement::SetMaxHeight

Sets the maximum height constraint of the Win32 control.

IXRFrameworkElement::SetMaxWidth

Sets the maximum width constraint of the Win32 control.

IXRFrameworkElement::SetMinHeight

Sets the minimum height constraint of the Win32 control.

IXRFrameworkElement::SetMinWidth

Sets the minimum width constraint of the Win32 control.

IXRDependencyObject::SetName

Sets the identifying name of the Win32 control.

IXRUIElement::SetRenderTransform

Sets the transformation to apply when Silverlight renders the Win32 control.

IXRFrameworkElement::SetVerticalAlignment

Sets the new vertical-alignment characteristics that determine the position of the Win32 control when Silverlight displays it within a parent element, such as a panel control or an items control.

IXRFrameworkElement::SetWidth

Sets the new width of the Win32 control.

Note

The IXRFrameworkElement::FindName method searches for the name associated with the x:Name attribute for this Win32 control when it is in the object tree, not for the class name.

Example

The following example code creates an IXRWin32Control, sets its handle as the handle to a window control, and adds it to a panel object that is in the visual tree for the application.

#include "XamlRuntime.h"

CreateControl(IXRApplication* pApplication, IXRPanel* pPanel, HWND HandleToWindowControl)
{
  IXRWin32Control *pIWin32Ctl = NULL;
  pApplication->CreateObject(IID_IXRWin32Control, &pIWin32Ctl);

  pIWin32Ctl->SetClassName(L"MyControlClass");
  pIWin32Ctl->SetName(L"Win32CtlSample");
  pIWin32Ctl->SetHeight(80);
  pIWin32Ctl->SetWidth(200);
  pIWin32Ctl->SetHorizontalAlignment(XRHorizontalAlignment_Left);
  pIWin32Ctl->SetVerticalAlignment(XRVerticalAlignment_Top);
  pIWin32Ctl->SetHandle(&HandleToWindowControl, false);

  IXRUIElementCollection *pChildCollection;
  pPanel->GetChildren(&pChildCollection);
  pChildCollection->Add(&pIWin32Control, NULL);
}

For more information about the classes used in this example, see IXRApplication, IXRPanel and IXRUIElementCollection.

Inheritance Hierarchy

IXRDependencyObject

    IXRUIElement

        IXRFrameworkElement

            IXRControl

                IXRWin32Control

.NET Framework Equivalent

None.

Requirements

Header XamlRuntime.h
sysgen SYSGEN_XAML_RUNTIME
Windows Embedded CE Windows Embedded CE 6.0 R3

See Also

Tasks

Add a Window Control to a Silverlight for Windows Embedded Application

Reference

Classes for UI Element Management

Other Resources

Creating a Window