Compartir a través de


IXRWin32Control (Compact 2013)

3/28/2014

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

Syntax

class IXRWin32Control : public IXRControl

Inheritance Hierarchy

IXRDependencyObject

    IXRUIElement

        IXRFrameworkElement

            IXRControl

                IXRWin32Control

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.

Thread Safety

Members of this class are thread-safe if you previously called IXRApplication::CreateHostFromXaml and supplied it with an XRWindowCreateParams structure that has AllowsMultipleThreadAccess set to true.

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.

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, XAML for Windows Embedded 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. XAML for Windows Embedded handles the TAB event for the Win32 control by giving the UI focus back to the main window.

When you create a class instance, use an IXRWin32ControlPtr smart pointer instead of a raw interface pointer. For more information, see XRPtr<Interface>.

To create an IXRWin32Control object in XAML for Windows Embedded 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 3 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 XAML for Windows Embedded displays it within a parent element, such as a panel control or an items control.

IXRControl::SetIsTabStop

Sets a value that indicates whether XAML for Windows Embedded 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 XAML for Windows Embedded renders the Win32 control.

IXRFrameworkElement::SetVerticalAlignment

Sets the new vertical-alignment characteristics that determine the position of the Win32 control when XAML for Windows Embedded 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.

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

#include "windows.h"
#include "XamlRuntime.h"
#include "XRPtr.h"

void CreateControl(IXRApplication* pApplication, IXRPanel* pPanel, HWND HandleToWindowControl)
{
  IXRWin32ControlPtr pWin32Control;
  pApplication->CreateObject(&pWin32Control);

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

  IXRUIElementCollectionPtr pChildCollection;
  pPanel->GetChildren(&pChildCollection);
  pChildCollection->Add(pWin32Control, NULL);
}

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

.NET Framework Equivalent

None.

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

Classes for UI Element Management