Give Focus To Another 16-Bit Application In NT

Note that in writing in VB3.0, Visual Basic’s AppActivate statementfails to make a 32-bit application the active window under Windows NT.For example:

 Sub Form_Load ()	AppActivate "Notepad - (Untitled)"End Sub

Visual Basic fails to give focus to the Notepad session because the16-bit Windows subsystems may not be fully available to other 16-bit programs.To work around this, use the FindWindow and SetWindowPos Windows API functionslike this: 1. Start a new project in Visual Basic. Form1 is created by default.2. Double-click on the form to open the code window. Select (general)from the Object box. Enter the following in the (general) (declarations)window:

 Declare Function FindWindow% Lib "USER" _	(ByVal Class&, ByVal Caption$)' The following Declare statement must be on one line:Declare Sub SetWindowPos Lib "user" _	(ByVal hwnd%, ByVal hwndAfter%, _	ByVal x%, ByVal y%, ByVal cx%, _	ByVal cy%, ByVal swp%)

3. Select Form from the Object box. Add the following code to the FormClick event:

 Sub Form_Click ()	Const SWP_NOSIZE% = &H1	Const SWP_NOMOVE% = &H2	AppActivate "Notepad - (Untitled)"	x = FindWindow(0, "Notepad - (Untitled)")	SetWindowPos x, 0, 0, 0, 0, 0, _		SWP_NOSIZE Or SWP_NOMOVE	Debug.Print Hex$(x) 	' Print return code from 	' FindWindow API function.End Sub

4. Start Notepad in Windows NT. 5. Start the Visual Basic program, or press the F5 key. Click on theform to activate Notepad. When finished, close the form to end the VisualBasic program.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may