title: How to SendMessage
body: <p>I have a problem. I want in my program(follow code) have 2 windows: console and empty form to output graphics. And from my func main send messages to form to draw shapes. Input data to console. But func SendMessage() doesn't work. What wrong?</p>
  
  <pre><code>int main()
  {
   char szClassName[] = "CG_WAPI_Template";
   HWND hWnd = GetConsoleWindow();
   HINSTANCE hInstance = NULL;
   MSG lpMsg;
  
   if(!AllocConsole())
    MessageBox(NULL, "Failed to create the console!", "Ошибка", MB_ICONEXCLAMATION|MB_OK);
  
    void *h_inc = GetStdHandle(STD_INPUT_HANDLE);
    void *h_out = GetStdHandle(STD_OUTPUT_HANDLE);
  
    WNDCLASS wc;
   /*wc.style       = CS_HREDRAW | CS_VREDRAW;
   wc.lpfnWndProc   = WndProc;
   ...
  */
  
  
   if(!RegisterClass(&amp;wc))
   {MessageBox(NULL, "Не могу зарегистрировать класс окна!", "Ошибка", MB_OK);
    return 0;
   }
  
   hWnd = CreateWindow(...); 
  
   ShowWindow(hWnd, SW_MAXIMIZE); 
   UpdateWindow(hWnd);
  
   char buf[2];
   unsigned long lengh;
   ReadConsole(h_inc,buf,1,&amp;lengh,NULL);
  
   SendMessage(hWnd, WM_USER+2, 0, 0); 
  
   if(GetMessage(&amp;lpMsg, NULL, 0, 0))  
   {
    TranslateMessage(&amp;lpMsg);
    DispatchMessage(&amp;lpMsg);
   }
  
   ReadConsole(h_inc,buf,1,&amp;lengh,NULL);
  
   if (!FreeConsole())
    MessageBox(NULL, "Could not free the console!", "Ошибка", MB_OK);
  
   return 0;
  }
  </code></pre>
  
  <p>Thank you.</p>