main.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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(0, 0);
  22. RECT workArea;
  23. SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
  24. Win32Window::Size size(workArea.right - workArea.left, workArea.bottom - workArea.top);
  25. if (!window.Create(L"conalep_pos", origin, size)) {
  26. return EXIT_FAILURE;
  27. }
  28. window.SetQuitOnClose(true);
  29. // Remove window title bar and borders.
  30. //SetWindowLongPtr(window.GetHandle(), GWL_STYLE, WS_VISIBLE | WS_POPUP);
  31. SetWindowPos(window.GetHandle(), HWND_TOP, workArea.left, workArea.top, size.width, size.height, SWP_SHOWWINDOW);
  32. ::MSG msg;
  33. while (::GetMessage(&msg, nullptr, 0, 0)) {
  34. ::TranslateMessage(&msg);
  35. ::DispatchMessage(&msg);
  36. }
  37. ::CoUninitialize();
  38. return EXIT_SUCCESS;
  39. }