Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. // You said this dialogs parent is you app window, so you can use
  2. // its hwnd as a parent where you will be searching for dialogs to close
  3. // hwnds
  4. HWND hApp = .....;
  5.  
  6. // iterate all childs of hApp windows
  7. HWND hwnd = ::GetWindow( hApp, GW_CHILD | GW_HWNDFIRST );
  8. while( hwnd ) {
  9.  
  10. // Now check if this is the one you are looking for.
  11. // Instead of checking its class name you may check its window text,...
  12. // For checking class name / window name, you may use spy++
  13. CString sOut;
  14. GetClassName( hwnd , sOut.GetBuffer( 100 ), 100 );
  15. sOut.ReleaseBuffer();
  16. if ( sOut == .... ) {
  17. // it was found so, Post message to close it,
  18. PostMessage(hwnd, WM_CLOSE, 0, 0)
  19. // maybe SC_CLOSE
  20. // PostMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE,0);
  21. // ... other way to close it? see here:
  22. // http://stackoverflow.com/a/12676807/471160
  23. }
  24.  
  25. hwnd = ::GetWindow( hwnd, GW_HWNDNEXT );
  26. }
  27.  
  28. do
  29. {
  30. hWnd = FindWindow(NULL /*class name?*/, /*windows name?*/);
  31. if(hWnd != NULL)
  32. PostMessage(hWnd, WM_CLOSE,NULL,NULL);
  33. }while(hWnd != NULL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement