Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Always on top


Reply
 
Thread Tools Display Modes
  #1  
Old 03-25-2003, 10:09 AM
Pogo Pogo is offline
Centurion
 
Join Date: Jan 2003
Posts: 185
Default Always on top


How is this achieved?
Reply With Quote
  #2  
Old 03-25-2003, 10:15 AM
Robse's Avatar
Robse Robse is offline
Senior Contributor

* Expert *
 
Join Date: Sep 2002
Location: Karlsruhe, Germany
Posts: 1,319
Default

Add this code to a module

Code:
Private 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 Public Const HWND_TOPMOST = -1 Public Const HWND_NOTOPMOST = -2 Public Sub SetTop(OnOff As Boolean) If OnOff Then Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, 3) Else Call SetWindowPos(Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, 3) End If

Make a call like this to set always on top
Code:
SetTop(True)
__________________
Posting Guidelines MSDN-VB API List Use [vb]...[/vb] tags for code!

Last edited by Robse; 03-25-2003 at 10:20 AM.
Reply With Quote
  #3  
Old 03-25-2003, 10:21 AM
Mikecrosoft's Avatar
Mikecrosoft Mikecrosoft is offline
Mexican Coder
 
Join Date: Jun 2002
Location: Monterrey, N.L., Mexico
Posts: 2,793
Default

I think this code can't be added to a module because Me.Hwnd will not works !!!

May be need to add the function in the form code
__________________
Mikecrosoft.NET
* If I stop to ask I will stop to learn
* Just I know that I don't know nothing
Reply With Quote
  #4  
Old 03-25-2003, 10:26 AM
Robse's Avatar
Robse Robse is offline
Senior Contributor

* Expert *
 
Join Date: Sep 2002
Location: Karlsruhe, Germany
Posts: 1,319
Default

Quote:
Originally Posted by Mikecrosoft
I think this code can't be added to a module because Me.Hwnd will not works !!!

May be need to add the function in the form code



Mikecrosoft is right.

So forget the above code and just call The Function
from wherever you want to like this

Code:
Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, 3)

to set the window on top.
__________________
Posting Guidelines MSDN-VB API List Use [vb]...[/vb] tags for code!
Reply With Quote
  #5  
Old 03-25-2003, 10:54 AM
Pogo Pogo is offline
Centurion
 
Join Date: Jan 2003
Posts: 185
Default

Ok, thanks
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->