Library tutorials & articles
API Programming Series #3 - Bring a Window to Top
- Introduction
- The code
- Analysis
- Conclusion
The code
As usual we start with the API declaration.
Create a new VB Standard EXE project.
When you created the project, a form Form1 should have been added to the project by default. Add another form to the project. Since this is only an example to illustrate the above API call, we'll not change the properties of the forms. So now we have two forms named Form1 and Form2 in the project. Add a command button each to both the forms. Leave their names as Command1 itself.
In the General | Declarations section of both the forms, type in the following code
Private Declare Function BringWindowToTop Lib "user32"
Alias "BringWindowToTop" (ByVal hwnd As Long) As Long
In the Click event procedure of the button on Form1 add the following code:
Private Sub Command1_Click ()
BringWindowToTop Form2.hwnd
End Sub
In the Click event procedure of the button on Form2 add the following code:
Private Sub Command1_Click ()
BringWindowToTop Form1.hwnd
End Sub
Now in the load event of Form1 (which should be the default form of the project add the following code.
Private Sub Form_Load ()
Form2.Show
End Sub
Related articles
Related discussion
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
-
Can you describe Above simple VB6 code?
by pramodmca09 (0 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
Are you using IE?
Using VB6 in Windows 2000 this function brings my window to the top of other application windows, but will not bring it above a browser window. Any suggestions?
This thread is for discussions of API Programming Series #3 - Bring a Window to Top.