|
-
Feb 2nd, 2006, 02:23 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Form Always on top
how do make my form always on top of other form in my application without using modal
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Feb 2nd, 2006, 02:32 AM
#2
Re: Form Always on top
There is a way to do it Here
(I'm not sure if thats the best way)
-
Feb 2nd, 2006, 02:35 AM
#3
Re: Form Always on top
To keep a program window on top (always visible) in Visual Basic use a WINAPI function. Code in Main Module:
Code:
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)
Code in a Submodule:
Code:
SetWindowPos form1.hWnd, -1, 0, 0, 0, 0, &H50 'This will make the window always visible!
SetWindowPos form1.hWnd, -2, 0, 0, 0, 0, &H50 'This will put "Always Visible" off!
just give a try...coz I never used this
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Feb 2nd, 2006, 02:51 AM
#4
Thread Starter
Frenzied Member
Re: Form Always on top
its not working,
what i actually want is that my form will be placed on top of every form in my application without being on top of ther applications.
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Feb 2nd, 2006, 06:46 AM
#5
Re: Form Always on top
Try this
Code:
Form2.Show vbModeless, Me
-
Feb 2nd, 2006, 08:07 AM
#6
Re: Form Always on top
Module:
Code:
Option Explicit
Public Const HWND_TOPMOST = -1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public 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
Form
Code:
Private Sub Command1_Click() ' activate
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE
End Sub
Private Sub Command2_Click() ' deactivate
SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE
End Sub
-
Feb 2nd, 2006, 09:44 AM
#7
Addicted Member
Re: Form Always on top
if GetTopWindow(0) <> form1.hwnd then
'setwindowpos
end if
Rich
-
Mar 1st, 2006, 01:34 AM
#8
Thread Starter
Frenzied Member
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|