Solved

Closing a window based on caption

Posted on 2004-08-11
2
346 Views
Last Modified: 2010-04-17
I need a clean way of closing a window based on the caption of the window.
For instance, if I want to close a window that has the word "DELETE" in it, how do I set that up?
0
Comment
Question by:robbperk
2 Comments
 
LVL 4

Accepted Solution

by:
cg_medistox earned 50 total points
ID: 11778886
Dim lHandle As Long
Dim lRez As Long

   Do
         ' Find the Menu window id.
      lHandle = FindWindow(vbNullString, "*Microsoft Outlook*")
         ' Kill it once
      If lHandle Then
         lRez = SendMessage(lHandle, WM_CLOSE, 0, 0)
         ' Kill it again in case didnt close
         lRez = SendMessage(lHandle, WM_DESTROY, 0, 0)
      End If 'lHandle
   Loop While lHandle <> 0

Change the Microsoft Outlook with what you need in there. This code is based on VB6 SP6
0
 
LVL 22

Expert Comment

by:cookre
ID: 11779860
You may need:

Private Const WM_DESTROY = &H02
Private Const WM_CLOSE = &H10
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

Suggested Solutions

Title # Comments Views Activity
Export Table to CSV - Access to CSV - using python 18 166
VBSCRIPT string remove all characters to the right after extension 4 66
Help Required 2 39
Help Required 3 108
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

839 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