-api-id | -api-type |
---|---|
T:Windows.UI.Core.CoreWindow |
winrt class |
Represents the UWP app with input events and basic user interface behaviors.
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.
// App.cpp
...
// An implementation of IFrameworkView::Run.
void Run()
{
CoreWindow window{ CoreWindow::GetForCurrentThread() };
window.Activate();
CoreDispatcher dispatcher{ window.Dispatcher() };
dispatcher.ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit);
}
// The CoreApplication::Run call indirectly calls the App::Run function above.
int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
{
CoreApplication::Run(App());
}
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).
Windows version | SDK version | Value added |
---|---|---|
1511 | 10586 | PointerRoutedAway |
1511 | 10586 | PointerRoutedReleased |
1511 | 10586 | PointerRoutedTo |
1607 | 14393 | ClosestInteractiveBoundsRequested |
1607 | 14393 | GetCurrentKeyEventDeviceId |
1703 | 15063 | ResizeCompleted |
1703 | 15063 | ResizeStarted |
1709 | 16299 | ActivationMode |
1709 | 16299 | DispatcherQueue |
1903 | 18362 | UIContext |
CoreApplicationView, CoreApplication.CreateNewView, CoreApplication.Views, Direct2D custom image effects sample (Windows 10)