main.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <flutter/dart_project.h>
  2. #include <flutter/flutter_view_controller.h>
  3. #include <windows.h>
  4. #include "flutter_window.h"
  5. #include "run_loop.h"
  6. #include "utils.h"
  7. #include "window_configuration.h"
  8. int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
  9. _In_ wchar_t *command_line, _In_ int show_command) {
  10. // Attach to console when present (e.g., 'flutter run') or create a
  11. // new console when running with a debugger.
  12. if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
  13. CreateAndAttachConsole();
  14. }
  15. // Initialize COM, so that it is available for use in the library and/or
  16. // plugins.
  17. ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
  18. RunLoop run_loop;
  19. flutter::DartProject project(L"data");
  20. FlutterWindow window(&run_loop, project);
  21. Win32Window::Point origin(kFlutterWindowOriginX, kFlutterWindowOriginY);
  22. Win32Window::Size size(kFlutterWindowWidth, kFlutterWindowHeight);
  23. if (!window.CreateAndShow(kFlutterWindowTitle, origin, size)) {
  24. return EXIT_FAILURE;
  25. }
  26. window.SetQuitOnClose(true);
  27. run_loop.Run();
  28. ::CoUninitialize();
  29. return EXIT_SUCCESS;
  30. }