1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: MIT
3
4#ifndef UNICODE
5# define UNICODE
6#endif
7
8#include "appwindow.h"
9#include <slint-platform.h>
10
11#if defined(_WIN32) || defined(_WIN64)
12# include "windowadapter_win.h"
13#endif
14
15struct MyPlatform : public slint::platform::Platform
16{
17 std::unique_ptr<MyWindowAdapter> the_window;
18 std::unique_ptr<slint::platform::WindowAdapter> create_window_adapter() override
19 {
20 return std::move(the_window);
21 }
22};
23
24AppView::AppView() { }
25
26void AppView::setGeometry(int x, int y, int width, int height)
27{
28 myWindow->setGeometry(x, y, width, height);
29}
30
31void AppView::attachToWindow(WINDOW_HANDLE winId)
32{
33 auto p = std::make_unique<MyPlatform>();
34 p->the_window = std::make_unique<MyWindowAdapter>(winId);
35 myWindow = p->the_window.get();
36 slint::platform::set_platform(std::move(p));
37
38 // AppWindow is the auto-generated slint code
39 static auto app = AppWindow::create();
40 app->show();
41}
42

source code of slint/examples/cpp/platform_native/appview.cpp