title: Winapi . TrackPopupMenuEx equivalent in CreateWindow
body: <p>When we create a pop up menu we call a function TrackPopupMenuEx  . It displays a shortcut menu at the specified location and tracks the selection of items on the shortcut menu .
  If you specify TPM_RETURNCMD in the fuFlags parameter, the return value is the menu-item identifier of the item that the user selected. If the user cancels the menu without making a selection, or if an error occurs, the return value is zero.
  This command is blocking ie unless we click on menu or outside we are blocked.</p>
  <p>I have created a window which has various static items which acts like a popup menu. Is there some function equalient to  (TrackPopupMenuEx with TPM_RETURNCMD ) which can tell me which was the last WM_COMMAND CLICKED which is blocking . If a function does not exist , how can we create a good blocking in the view that  it doesn't eat up the CPU in wait cycle.</p>
  <p>What I did :</p>
  <p>In the WM_COMAND I initialize the global variable which is whatIsLastClicked.  In my function i wait till this variable is set but it seems to eat cpu.</p>
  <p>Some code</p>
  <pre><code>    WNDCLASSW wc = { 0 };
      wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
      wc.hCursor = LoadCursor(NULL, IDC_ARROW);
      wc.hInstance = hInst;
      wc.lpszClassName = L&quot;mywindowsclass&quot;;
  
      wc.lpfnWndProc = windowprocedure;
  //&lt;== all handlers WM_COMMAND defined in this fucntion 
   
      if (!RegisterClassW(&amp;wc))
      {
          return -1; // registration failed
      }
  
   
      HWND hWnd = CreateWindowW(L&quot;mywindowsclass&quot;,
   L&quot;My window&quot;, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 
   100, 100,   500, 500, NULL, NULL, NULL, NULL);
   
   //POINT : need some blocking code here which is efficient to find what i clicked
  </code></pre>