Quick Search for:  in language:    
   Code/Articles ╗ |  Newest/Best ╗ |  Community ╗ |  Jobs ╗ |  Other ╗ |  Goto ╗ | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,290,928. lines
 Jobs: 207. postings

 How to support the site

Sponsored by:

You are in:

Does your code think in ink?

Latest Code Ticker for Visual Basic
Click here to see a screenshot of this code!How to use 32 Bit Icons in a VB App
By Zpage on 12/30

(Screen Shot)

Click here to see a screenshot of this code!Database Film's with ListBox
By Diego Corti˝as on 12/30

(Screen Shot)

Click here to see a screenshot of this code!MP3 class with ID3v2 and ID3v1 support
By Vesa Piittinen on 12/30

(Screen Shot)

Control By Browser
By Priyan R on 12/30

Stealth Exchange SFX
By dvchaos on 12/30

Click here to see a screenshot of this code!Mini Tetris
By Code Toad on 12/30

(Screen Shot)

Click here to see a screenshot of this code!NTMessager Network Message Utility
By B.Cem HANER on 12/30

(Screen Shot)

By Angelica Courtin on 12/30

Click here to see a screenshot of this code!Encryptor Xor Version 3
By DISTS on 12/30

(Screen Shot)

Click here to put this ticker on your site!

Add this ticker to your desktop!

Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites


Close Program By Caption


Submitted on: 11/28/2003 12:14:31 PM
By: Morpheous Dreams 
Level: Beginner
User Rating: By 1 Users
Compatibility:VB 6.0

Users have accessed this code 428 times.

(About the author)
     I did a fast search on P-S-C and couldnt find anyway to close windows by a caption but 1 so I did one fast... here is how easy it is for anyone who wants/needs it

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

'Windows API/Global Declarations for :Cl
'     ose Program By Caption

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SendMessageLong& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
    Public Const WM_CLOSE = &H10;
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

' Name: Close Program By Caption
' Description:I did a fast search on P-S
'     -C and couldnt find anyway to close wind
'     ows by a caption but 1 so I did one fast
'     ... here is how easy it is for anyone wh
'     o wants/needs it
' By: Morpheous Dreams
' Returns:Close any window by its captio
'     n
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/vb/scripts/Sho
'     wCode.asp?txtCodeId=50170&lngWId;=1'for details.'**************************************

Public Sub CWBC(Caption As String)

Dim CloseWindows As Long CloseWindows = FindWindow(vbNullString, Caption) Call SendMessageLong(CloseWindows, WM_CLOSE, 0, 0) 'Just somthing to let you know its been ' closed 'If CloseWindows = 0 Then ' MsgBox "Window is not open", vbInforma ' tion, "Morpheous" 'Else ' MsgBox Caption & " - has been closed", ' vbInformation, "Morpheous" 'End If End Sub

Other 23 submission(s) by this author


Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
Other User Comments

 There are no comments on this submission.
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.


Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyrightę 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.