Search
 
SCRIPT & CODE EXAMPLE
 

CPP

flutter single instance app

// paste at the beginning of CreateAndShow at windows/runner/win32_window.cpp

HANDLE hMutexHandle = CreateMutex(NULL, TRUE, L"my.app.mutex");
  HWND handle = FindWindowA(NULL, "My App Name");

  hMutexHandle; // This line is required to supress "local variable is initialized but not referenced" error/warning.

  if (GetLastError() == ERROR_ALREADY_EXISTS)
  {
    WINDOWPLACEMENT place = {sizeof(WINDOWPLACEMENT)};
    GetWindowPlacement(handle, &place);
    switch (place.showCmd)
    {
    case SW_SHOWMAXIMIZED:
      ShowWindow(handle, SW_SHOWMAXIMIZED);
      break;
    case SW_SHOWMINIMIZED:
      ShowWindow(handle, SW_RESTORE);
      break;
    default:
      ShowWindow(handle, SW_NORMAL);
      break;
    }
    SetWindowPos(0, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
    SetForegroundWindow(handle);
    return 0;
  }
Comment

PREVIOUS NEXT
Code Example
Cpp :: find the graph is minimal spanig tree or not 
Cpp :: rethrow exception c++ 
Cpp :: vector::at() || Finding element with given position using vector in C++ 
Cpp :: three way comparison operator c++ 
Cpp :: c++ formatting 
Cpp :: google test assert exception 
Cpp :: add input in c++ 
Cpp :: Array declaration by specifying the size in C++ 
Cpp :: bit++ codeforces in c++ 
Cpp :: c++ split string 
Cpp :: cyclically rotate an array by once 
Cpp :: shortest path in unweighted graph bfs 
Cpp :: c++ define array with values 
Cpp :: __builtin_popcount 
Cpp :: what algorithm does bitcoin use 
Cpp :: the difference between i++ and ++i 
Cpp :: c++ pass function as argument 
Cpp :: pow c++ 
Cpp :: vector size c++ 
Cpp :: C++ insert character 
Cpp :: map of maps c++ 
Cpp :: cpp algorithm iota 
Cpp :: c++c 
Cpp :: faster solutions 
Cpp :: convert hex to decimal arduino 
Cpp :: c++ throe 
Cpp :: Summation of Natural Number Sequence with c and c++. 
Cpp :: int and char in c++ compiler 
Cpp :: TCA9548 I2CScanner Arduino 
Cpp :: c++ program to convert celsius to fahrenheit 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =