main.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. {
  9. // Attach to console when present (e.g., 'flutter run') or create a
  10. // new console when running with a debugger.
  11. if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent())
  12. {
  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. flutter::DartProject project(L"data");
  19. std::vector<std::string> command_line_arguments =
  20. GetCommandLineArguments();
  21. project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
  22. FlutterWindow window(project);
  23. Win32Window::Point origin(10, 10);
  24. Win32Window::Size size(1280, 720);
  25. if (!window.CreateAndShow(L"AppFlowy", origin, size))
  26. {
  27. return EXIT_FAILURE;
  28. }
  29. window.SetQuitOnClose(true);
  30. ::MSG msg;
  31. while (::GetMessage(&msg, nullptr, 0, 0))
  32. {
  33. ::TranslateMessage(&msg);
  34. ::DispatchMessage(&msg);
  35. }
  36. ::CoUninitialize();
  37. return EXIT_SUCCESS;
  38. }