Ryan's District
November 22, 2008, 02:54:19 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: You are not allowed to view links.
Register or Login
How to Unlock Nokia mobile Phones

You are not allowed to view links.
Register or Login
Request any TV Show / series / Episodes / movie and we will get it for you for free

 
   Home   Help Search Chat Calendar Chess Shop Login Register  
Digg This!
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: How to Kill an Application with System Menu Using Visual Basic  (Read 3297 times)
0 Members and 1 Guest are viewing this topic.
ben2ong2
Quality Poster
Paid
Hero Member
*****

Reputation: 17
Offline Offline

Gender: Male
Posts: 2374
9976.80 RD$

View Inventory
Send Money to ben2ong2

View Profile Awards
« on: October 07, 2006, 03:59:49 PM »

PRODUCT :Microsoft Visual Basic for Windows
PROD/VER:4.00
OPER/SYS:WINDOWS
KEYWORDS:kbprg kbcode kbhowto

---------------------------------------------------------------------
The information in this article applies to:

 - Professional and Enterprise Editions of Microsoft Visual Basic,
   16-bit only, for Windows, version 4.0
--------------------------------------------------------------------

SUMMARY
=======

Microsoft Visual Basic for Windows can use the Microsoft Windows API
SendMessage function to close any active window that has a system menu
(referred to as the Control Box within Visual Basic for Windows) with the
Close option.

MORE INFORMATION
================

You can use the Windows API SendMessage function to post a message to any
window in the environment as long as the handle to the window is known. You
can use the API FindWindow function to determine the handle associated with
the window the user wants to close.

Query on the following words in the Microsoft Knowledge Base for more
information on the FindWindow function:

   FindWindow and Visual Basic

To create a program to close an occurrence of the Microsoft Windows version
3.0 Calculator program, do the following:

1. Create a form called Form1.

2. Create two command buttons called Command1 and Command2.

3. Within the Command1 Click event, add the following code:

   Private Sub Command1_Click()
      X% = Shell("Calc.exe")
   End Sub

4. Within the Command2 Click event, add the following code:

   Private Sub Command2_Click()
      Const NILL = 0&
      Const WM_SYSCOMMAND = &H112
      Const SC_CLOSE = &HF060

      lpClassName$ = "SciCalc"
      lpCaption$ = "Calculator"

      '* Determine the handle to the Calculator window.
      Handle = FindWindow(lpClassName$, lpCaption$)

      '* Post a message to Calc to end its existence.
      X& = SendMessage(Handle, WM_SYSCOMMAND, SC_CLOSE, NILL)

   End Sub

5. In the Declarations section, declare the following two API functions:

   ' Enter each of the following Declare statements on one, single line:
   Private Declare Function FindWindow% Lib "user" _
      (ByVal lpClassName As Any, ByVal lpCaption As Any)
   Private Declare Function SendMessage& Lib "user" _
      (ByVal hwnd%, ByVal wMsg%, ByVal wParam%, ByVal lParam As Long)

6. Run the program. Click the Command1 button to bring up an instance of
   the Calculator program. Click the Command2 button to close the window.

Additional reference words: 1.00 2.00 3.00 4.00 vb4win vb416
KBCategory: kbprg kbcode kbhowto
KBSubcategory: APrgOther

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS
PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.  MICROSOFT DISCLAIMS
ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO
EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR
ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF
MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.  SOME STATES DO NOT ALLOW THE EXCLUSION
OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES
SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1996.
Logged

You are not allowed to view links.
Register or Login
Free Paid Survey & Home Business Resources.

You are not allowed to view links.
Register or Login
Free Article Directory | Quality Content
Ryan's District
« on: October 07, 2006, 03:59:49 PM »

 Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Archive - WAP2 - WAP - imode
Sponsors: RAYAN.tv
-

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.212 seconds with 31 queries.

Google visited last this page Today at 08:20:55 AM