main.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <flutter/dart_project.h>
  2. #include <flutter/flutter_view_controller.h>
  3. #include <windows.h>
  4. #include "flutter_window.h"
  5. #include "utils.h"
  6. int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
  7. _In_ wchar_t *command_line, _In_ int show_command) {
  8. // Attach to console when present (e.g., 'flutter run') or create a
  9. // new console when running with a debugger.
  10. if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
  11. CreateAndAttachConsole();
  12. }
  13. // Initialize COM, so that it is available for use in the library and/or
  14. // plugins.
  15. ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
  16. flutter::DartProject project(L"data");
  17. std::vector<std::string> command_line_arguments =
  18. GetCommandLineArguments();
  19. project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
  20. FlutterWindow window(project);
  21. Win32Window::Point origin(10, 10);
  22. Win32Window::Size size(1280, 720);
  23. if (!window.Create(L"vnoteapp", origin, size)) {
  24. return EXIT_FAILURE;
  25. }
  26. window.SetQuitOnClose(true);
  27. ::MSG msg;
  28. while (::GetMessage(&msg, nullptr, 0, 0)) {
  29. ::TranslateMessage(&msg);
  30. ::DispatchMessage(&msg);
  31. }
  32. ::CoUninitialize();
  33. return EXIT_SUCCESS;
  34. }