Ryan's District
November 22, 2008, 03:22:05 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 Get a Handle to MS-DOS Application and Change Title  (Read 3348 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, 04:00:12 PM »

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

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

- Standard and Professional Editions of Microsoft Visual Basic for
  Windows, version 3.0
---------------------------------------------------------------------

SUMMARY
=======

This article shows by example how to get the handle to a MS-DOS
application, and then use that handle to change the MS-DOS Window title or
automatically unload the MS-DOS Window from Visual Basic.

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

Step-by-Step Example
--------------------

1. Start a new project in Visual Basic. Form1 is created by default.

2. Add two command buttons (Command1 and Command2) to Form1.

3. Enter the following code in the General Declarations of a form or
   module:

   ' Enter each of the following Declare statements on one, single line:
   Declare Function PostMessage Lib "User"
      (ByVal hWnd As Integer, ByVal wMsg As Integer,
      ByVal wParam As Integer, lParam As Any) As Integer
   Declare Sub SetWindowText Lib "User"
      (ByVal hWnd As Integer, ByVal lpString As String)
   Declare Function GetActiveWindow Lib "User" () As Integer
   Dim MhWnd as Integer
   Const WM_CLOSE = &H10

4. Enter the following code in the Click Event of Command1:

   Sub Command1_Click()
      Dim X as Integer
      X = Shell("c:\windows\dosprmpt.pif", 1) ' Open an MS-DOS Window
      For X = 0 To 100
         DoEvents
         ' a bunch of DOEVENTS to wait for the MS-DOS Window to open.
      Next X

      ' Get the handle when the MS-DOS Window has the focus:
      Mhwnd = GetActiveWindow()

      ' Now pass the handle to the window with a new title:
      Call SetWindowText(Mhwnd, "My Application!")
   End Sub

5. Place the following code in the Click Event of Command2:

   Sub Command2_Click()
      Dim X as Integer
      ' Note: In order for this to work on a MS-DOS Window, you have
      ' to have a PIF setup that will allow an MS-DOS Window to be closed.
      ' In the PIF editor, select "Advanced", then click "Close When
      ' Active". This allows MS-DOS applications to be closed
      ' programatically
      X = PostMessage(MhWnd, WM_CLOSE, 0, 0) ' Return greater than zero
                                             ' if successful.
      If X = 0 Then
         MsgBox "Application did not close!"
      End If
   End Sub

6. Start the program, or press the F5 key.

7. Click the Command1 button to see the title change.

Additional reference words: 2.00 3.00
KBCategory: kbprg kbcode
KBSubcategory: PrgOther

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

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 1995.
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, 04:00:12 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.247 seconds with 30 queries.

Google visited last this page Yesterday at 07:20:39 AM