dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Advanced
Aug 7, 1998

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Make a Form Stay on Top

You can make a form always remain above others, even when it does not have focus. Use this code in a BAS module:

 #If Win16 Then
	Declare Sub SetWindowPos Lib "User" ( _
		ByVal hWnd As Integer, _
		ByVal hWndInsertAfter As Integer, _
		ByVal X As Integer, ByVal Y As Integer, _
		ByVal cx As Integer, ByVal cy As Integer, _
		ByVal wFlags As Integer)
#Else
	Declare Function SetWindowPos Lib _
		"user32" (ByVal hwnd As Long, _
		ByVal hWndInsertAfter As Long, _
		ByVal x As Long, ByVal y As Long, _
		ByVal cx As Long, ByVal cy As Long, _
		ByVal wFlags As Long) As Long
#End If
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2

Use this code to make the form stay on top in the form module:

 SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, _
	SWP_NOMOVE + SWP_NOSIZE

Use this code to make the form no longer stay on top in the form module:

 SetWindowPos Parent.hwnd, HWND_NOTOPMOST, _
	 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE

In 16-bit systems, use the 16-bit equivalents.

Rod Stephens
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date