Solved

Closing a window based on caption

Posted on 2004-08-11
2
345 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about problems I had with the new location API and permissions in Marshmallow
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

776 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