Solved

Closing a window

Posted on 1998-08-10
5
147 Views
Last Modified: 2010-04-30
Im having trouble closing certain windows with vb5. By closing I mean like right clicking x top right of window.

This closes notepad  but not internet explorer?
 lRes = SendMessage(CleanHousehWnd, WM_CLOSE, 0, 0)
How could I close internet explorer?
 
This only minimizes windows
 lRes = SendMessageLong(CleanHousehWnd, WM_QUIT, 0, 0)  

I am trying to automate quiting all applications.
0
Comment
Question by:harryq
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:peterwest
ID: 1468502
Hi there,

Try using PostMessage instead of SendMessage

Pete

0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1468503
Where is the reference to "CleanHousehWnd" ?

Shay.
0
 

Author Comment

by:harryq
ID: 1468504
pete, postmessage does it, finally, thanks,
answer for points.
0
 

Author Comment

by:harryq
ID: 1468505
Shay, just the name for the hwnd to close, thanks for help
0
 
LVL 2

Accepted Solution

by:
peterwest earned 50 total points
ID: 1468506
Hi,

Glad to hear that it worked - it took me a while to figure out how to achieve this aim; when I was looking into the problem the manuals said I needed to send a WM_CLOSE to the window - unfortunately they didn't explain which command to use to send the message.

Glad to hear it works for you.

Pete
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now