Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Closing a window from an external process

Posted on 2004-10-30
5
Medium Priority
?
190 Views
Last Modified: 2013-11-20
I am writing a VC++ 6.0 monitor program which monitors the graphics of a third party application window.  This application periodically pops up advertising dialog boxes which mess up the graphics monitoring and I would like to automatically close those dialogs.  I can enumerate the windows on the screen and get the handle to the dialog window, but when I send a WM_CLOSE message to that window nothing happens.  Is there another message or window method I could use to cause the dialog to go away?

If I can't close this window directly, then I have thought I could get the window handle for the OK button and send that button a mouse click event to simulate the user closing the dialog manually.

Any suggestions would be appreciated.
0
Comment
Question by:MugWumpBW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 600 total points
ID: 12452826
Try this:

::PostMessage(hWnd, WM_COMMAND, IDOK, 0);
0
 

Author Comment

by:MugWumpBW
ID: 12453182
Thanks - that worked.  For some reason neither WM_CLOSE or WM_DESTROY worked.
0
 
LVL 4

Accepted Solution

by:
Skonen earned 400 total points
ID: 12457935
IDOK isn't the safest way to do this, as a lot of windows applications do not include a handler for IDOK. It is a safer bet to send a system message to close the window:

::PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE);

This is equal to clicking the "X" (Close symbol) for a window.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 12816700
My answer os OK (IDOK).
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question