main.cpp.tmpl 1.25 KB
Newer Older
1 2 3 4 5
#include <flutter/dart_project.h>
#include <flutter/flutter_view_controller.h>
#include <windows.h>

#include "flutter_window.h"
6
#include "utils.h"
7

8 9
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
                      _In_ wchar_t *command_line, _In_ int show_command) {
10 11 12
  // Attach to console when present (e.g., 'flutter run') or create a
  // new console when running with a debugger.
  if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
13
    CreateAndAttachConsole();
14 15
  }

16 17
  // Initialize COM, so that it is available for use in the library and/or
  // plugins.
18 19
  ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);

20
  flutter::DartProject project(L"data");
21 22 23 24 25 26

  std::vector<std::string> command_line_arguments =
      GetCommandLineArguments();

  project.set_dart_entrypoint_arguments(std::move(command_line_arguments));

27
  FlutterWindow window(project);
28 29 30
  Win32Window::Point origin(10, 10);
  Win32Window::Size size(1280, 720);
  if (!window.CreateAndShow(L"{{projectName}}", origin, size)) {
31 32 33 34
    return EXIT_FAILURE;
  }
  window.SetQuitOnClose(true);

35 36 37 38 39
  ::MSG msg;
  while (::GetMessage(&msg, nullptr, 0, 0)) {
    ::TranslateMessage(&msg);
    ::DispatchMessage(&msg);
  }
40

41
  ::CoUninitialize();
42 43
  return EXIT_SUCCESS;
}