   creating window issues
  Hi all!Now i was creating a WM_POPUP style window, and i want to add some button by my self ,i create a close button and a minimized button.I find something i can not figure out. That is,when i run my program and not set focus on it(it means it is minimized(showwindow(hwnd,SW_MINIMIZE)).The cpu busy ration is too hight,about 50%.I just want to know why?And the other problem,when my program is minimized,it hides at the bottom of taskbar,i want to add the event of mouse right button.How can i do this?Thank you!!!   
  You probably have some sort of bug... but if you want me to help you I'll need you to post your code.   ;  Most likely you are still drawing into the window. Just minimizing the window doesn't affect the program execution, so the main loop still runs. Therefore your game is still updated and rendered, explaining the CPU-busyness (if that's a word).Emiel1   ;  oh,thank you,emiel1 and VirtualProgrammer.first, the main loop: if(InitializeD3D(hWnd, false)) {    // Enter the message loop    MSG msg;    ZeroMemory(&msg, sizeof(msg));    while(msg.message != WM_QUIT)  {if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))   { TranslateMessage(&msg; DispatchMessage(&msg;   }else   RenderScene();  } }I think,may be I should use the function(PostQuitMessage) to send a message to my window to reduce the CPU_busyness.IS it right?I would try it.;  wrong! not PostQuitMessage, is PostMessage.   ;  As emiel1 said: You are always drawing, even when your app is not active. Another point: You're only processing one message and then render a frame. This causes events to get handled with quite a lag if there are more than one.A suggestion:while ( msg.message != WM_QUIT ){  while ( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )  {    TranslateMessage( &msg );    DispatchMessage( &msg );  }  if ( ApplicationIsActive )  {    RenderScene();  }}Make ApplicationIsActive a bool that get's set accordingly while handling WM_ACTIVATEAPP. For proper redrawing you also should call RenderScene while WM_PAINT is received (so your non-active app only draws if it needs to, thusly reducing CPU consumption).   ;  I think i can solve the problem.THANK YOU ,Endurion.I find out if i write the program like this:while ( msg.message != WM_QUIT ){  while ( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )  {    TranslateMessage( &msg );    DispatchMessage( &msg );  }  Sleep(10);  //very important.  if ( ApplicationIsActive )  {    RenderScene();  }}The cause of the cpu_busyness is the while loop is a infinity loop.And i should add the time counter to control how long to run one loop.Is my explain correct? Thanks.   ;  Not really. When your window is minimized, your program continues drawing your scene. You can avoid this behaviour by setting the bool ApplicationIsActive. That variable is always true, except when your application is minimized.You can also respond to messages: the message WM_ACTIVATE is fired when your application is minimized. Here is an example how to react on this message.case WM_ACTIVATE:  ApplicationIsActive = (LOWORD(wParam) != WA_INACTIVE);  break;The tight while-loop is important, but you don't want to sleep when your application is active, so we put the sleep in the else of the ApplicationIsActive, like so.while (msg.message != WM_QUIT){  while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))  {    TranslateMessage(&msg);    DispatchMessage(&msg);  }  if (ApplicationIsActive)  {    RenderScene();  }  else  {    Sleep(10);  }}Emiel1[Edited by - emiel1 on May 3, 2009 7:18:36 AM]