title: Select all text in edit contol by clicking Ctrl+A
body: <p>How to select all text in edit control by pressing <kbd>Ctrl</kbd>+<kbd>A</kbd>?
  I can catch <kbd>Ctrl</kbd>+<kbd>A</kbd>  for parent window in WndProc.
  But I don't know how to catch <kbd>ctrl</kbd>+<kbd>a</kbd> which are applied for edit control.
  Also I tried to use accelerators, but again it applies only for parent window.
  Thanks.
  EDIT: 1-st the simplest method 
  This method Based on @phord's answers in this question:
  <a href="https://stackoverflow.com/questions/291792/win32-select-all-on-edit-ctrl-textbox/315720#315720">win32 select all on edit ctrl (textbox)</a></p>
  
  <pre><code>while( (bRet = GetMessage( &amp;msg, NULL, 0, 0 )) != 0)
  { 
      if (bRet == -1)
      {
          // handle the error and possibly exit
      }
      else
      {
          if (msg.message == WM_KEYDOWN &amp;&amp; msg.wParam == 'A' &amp;&amp; GetKeyState(VK_CONTROL) &lt; 0)
      {
          HWND hFocused = GetFocus();
          wchar_t className[6];
          GetClassName(hFocused, className, 6);
          if (hFocused &amp;&amp; !wcsicmp(className, L"edit"))
              SendMessage(hFocused, EM_SETSEL, 0, -1);
      }
      TranslateMessage(&amp;msg);
      DispatchMessage(&amp;msg);
      }
  }
  </code></pre>
  
  <p>EDIT: 2-nd method
  Need to use CreateAcceleratorTable + TranslateAccelerator functions:</p>
  
  <p>//global variables:</p>
  
  <pre><code>enum {ID_CTRL_A = 1};
  HACCEL accel;
  </code></pre>
  
  <p>//main procedure</p>
  
  <pre><code>ACCEL ctrl_a;
  ctrl_a.cmd = ID_CTRL_A; // Hotkey ID
  ctrl_a.fVirt = FCONTROL | FVIRTKEY;
  ctrl_a.key = 0x41; //'A' key
  accel = CreateAcceleratorTable(&amp;ctrl_a, 1); //we have only one hotkey
  </code></pre>
  
  <p>//How GetMessage loop looks</p>
  
  <pre><code>while( (bRet = GetMessage( &amp;msg, NULL, 0, 0 )) != 0)
  { 
      if (bRet == -1)
      {
          // handle the error and possibly exit
      }
      else
      {
          if (!TranslateAccelerator(hWnd, accel,  &amp;msg))
          {
              TranslateMessage(&amp;msg); 
              DispatchMessage(&amp;msg); 
          }
      }
  }
  </code></pre>
  
  <p>//in WndProc we must add next cases</p>
  
  <pre><code>case WM_COMMAND:
  {
      if (LOWORD(wParam) == ID_CTRL_A &amp;&amp; HIWORD(wParam) == 1)
      {
          //on which control there was pressed Ctrl+A
          //there is no way of getting HWND through wParam and lParam
          //so we get HWND which currently has focus.
          HWND hFocused = GetFocus();
          wchar_t className[6];
          GetClassName(hFocused, className, 6);
          if (hFocudsed &amp;&amp; !wcsicmp(className, L"edit"))
              SendMessage(hFocused, EM_SETSEL, 0, -1);
      }
  }
  break;
  case WM_DESTROY:
  {
     DestroyAcceleratorTable(accel);
     PostQuitMessage(0);
  }
  break;
  </code></pre>
  
  <p>As you can see this is pretty simple.</p>