Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // You said this dialogs parent is you app window, so you can use
- // its hwnd as a parent where you will be searching for dialogs to close
- // hwnds
- HWND hApp = .....;
- // iterate all childs of hApp windows
- HWND hwnd = ::GetWindow( hApp, GW_CHILD | GW_HWNDFIRST );
- while( hwnd ) {
- // Now check if this is the one you are looking for.
- // Instead of checking its class name you may check its window text,...
- // For checking class name / window name, you may use spy++
- CString sOut;
- GetClassName( hwnd , sOut.GetBuffer( 100 ), 100 );
- sOut.ReleaseBuffer();
- if ( sOut == .... ) {
- // it was found so, Post message to close it,
- PostMessage(hwnd, WM_CLOSE, 0, 0)
- // maybe SC_CLOSE
- // PostMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE,0);
- // ... other way to close it? see here:
- // http://stackoverflow.com/a/12676807/471160
- }
- hwnd = ::GetWindow( hwnd, GW_HWNDNEXT );
- }
- do
- {
- hWnd = FindWindow(NULL /*class name?*/, /*windows name?*/);
- if(hWnd != NULL)
- PostMessage(hWnd, WM_CLOSE,NULL,NULL);
- }while(hWnd != NULL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement