Advertisement
FlyFar

main.cpp

Jul 25th, 2023
795
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | Cybersecurity | 0 0
  1. #include <flutter/dart_project.h>
  2. #include <flutter/flutter_view_controller.h>
  3. #include <windows.h>
  4.  
  5. #include "flutter_window.h"
  6. #include "utils.h"
  7.  
  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.  
  16.   // Initialize COM, so that it is available for use in the library and/or
  17.   // plugins.
  18.   ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
  19.  
  20.   flutter::DartProject project(L"data");
  21.  
  22.   std::vector<std::string> command_line_arguments =
  23.       GetCommandLineArguments();
  24.  
  25.   project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
  26.  
  27.   FlutterWindow window(project);
  28.   Win32Window::Point origin(10, 10);
  29.   Win32Window::Size size(1280, 720);
  30.   if (!window.CreateAndShow(L"client", origin, size)) {
  31.     return EXIT_FAILURE;
  32.   }
  33.   window.SetQuitOnClose(true);
  34.  
  35.   ::MSG msg;
  36.   while (::GetMessage(&msg, nullptr, 0, 0)) {
  37.     ::TranslateMessage(&msg);
  38.     ::DispatchMessage(&msg);
  39.   }
  40.  
  41.   ::CoUninitialize();
  42.   return EXIT_SUCCESS;
  43. }
Tags: cpp main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement