CoreWindow class
TOC
Collapse the table of content
Expand the table of content

CoreWindow class

Represents the Windows Store app with input events and basic user interface behaviors.

Syntax


Public NotInheritable Class CoreWindow
    Implements ICoreWindow

Members

The CoreWindow class has these types of members:

Events

The CoreWindow class has these events.

EventDescription
Activated Is fired when the window completes activation or deactivation.
AutomationProviderRequested Is fired when a request for an automation handler is generated.
CharacterReceived Is fired when a new character is received by the input queue.
Closed Is fired when the app terminates.
ClosestInteractiveBoundsRequested Occurs when a framework input manager requests the bounding rectangle of an interactive element within a specific bounding rectangle and closest to a specific pointer.
InputEnabled Occurs when input is enabled or disabled for the app.
KeyDown Is fired when a non-system key is pressed.
KeyUp Is fired when a non-system key is released after a press.
PointerCaptureLost Occurs when a pointer moves to another app.
PointerEntered Occurs when a pointer moves into the bounding box of the app.
PointerExited Occurs when the pointer moves outside the bounding box of the app.
PointerMoved Occurs when a pointer moves within the bounding box of the app.
PointerPressed Occurs when a mouse button is clicked, or the digitizer surface has been touched by a finger or pen, within the bounding rectangle of the app.
PointerReleased Occurs when a pressed mouse button is released, or a touch or pen contact is lifted from the digitizer surface, within the bounding rectangle of the app (or outside the bounding rectangle, if the pointer is captured).
PointerRoutedAway Occurs on the process receiving input when the pointer input is routed to another process.
PointerRoutedReleased Occurs on a process associated with, but not currently receiving input from, a pointer that fires a PointerReleased event on a different process.
PointerRoutedTo Occurs on the process not currently receiving input, but designated to begin receiving input from another process.
PointerWheelChanged Occurs when the wheel button is rotated.
SizeChanged Occurs when the window size is changed.
TouchHitTesting Occurs when a touch contact area intersects the bounding rectangle (or polygon) of a window that is registered for touch hit testing.
VisibilityChanged Is fired when the window visibility is changed.

 

Methods

The CoreWindow class has these methods. It also inherits methods from the Object class.

MethodDescription
Activate Activates the window.
Close Closes a secondary window and exits the message loop.
GetAsyncKeyState Asynchronously retrieves the state of a virtual key.
GetCurrentKeyEventDeviceId Retrieves the unique ID for the input device that generated this key event.
GetForCurrentThread Gets the CoreWindow instance for the currently active thread.
GetKeyState Retrieves the state of a virtual key.
ReleasePointerCapture Dissociates pointer input from the app, if previously associated through SetPointerCapture, and restores normal pointer input processing.
SetPointerCapture Associates pointer input with the app. Once a pointer is captured, all subsequent events associated with that pointer are fired by the app.

 

Properties

The CoreWindow class has these properties.

PropertyAccess typeDescription

AutomationHostProvider

Read-only

Gets the automation provider assigned to this window.

Bounds

Read-only

Gets the bounding rectangle of the window.

CustomProperties

Read-only

Gets the set of custom properties for the window.

Dispatcher

Read-only

Gets the event dispatcher for the window.

FlowDirection

Read/write

Gets or sets the horizontal origin of the window's reading order alignment.

IsInputEnabled

Read/write

Gets or sets a value that indicates whether input is enabled for the app.

IsKeyboardInputEnabled

Read/write

Windows Phone Silverlight only: Gets or sets whether the touch keyboard is displayed to the user for text input.

KeyboardInputBuffer

Read/write

Windows Phone Silverlight only: Gets or sets the KeyboardInputBuffer object that is used to receive buffered text input.

PointerCursor

Read/write

Gets or sets the cursor used by the app.

PointerPosition

Read-only

Gets the client coordinates of the pointer.

Visible

Read-only

Gets a value that indicates whether the window is visible.

 

Remarks

New instances of this class are obtained by calling CoreApplication.CreateNewView and then inspecting the CoreWindow property on the returned CoreApplicationView instance. Or you can obtain existing CoreWindow instances for a running app from the CoreApplication.Views property, or by calling CoreWindow.GetForCurrentThread, as seen in the following example.


void MyCoreWindowEvents::Run() // this is an implementation of IFrameworkView::Run() used to show context
{
    CoreWindow::GetForCurrentThread()->Activate();

    /...

    CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit);
}

Note  : This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX).
 

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0
Desktop, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.UI.Core
Windows::UI::Core [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.UI.Core
Windows::UI::Core [C++]

Metadata

Windows.winmd

Attributes

[MarshalingBehavior(Standard)]
[Muse()]
[Version(0x06020000)]
[WebHostHidden()]

See also

Object
ICoreWindow
CoreApplicationView
CoreApplication.CreateNewView
CoreApplication.Views
Direct2D custom image effects sample (Windows 10)

 

 

Show:
© 2016 Microsoft