Give Focus To Another 16-Bit Application In NT

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:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as