|
-
Apr 4th, 2000, 08:52 AM
#1
My Condition:
I have 2 application running at the same time on my window. Both was created using VB6.
My Problem;
I just want one of my application remain on top all the time even when I use Alt+Tab key to select active application.
My Question:
Is form has the hidden object property on stay on top. Anyway how can I overcome the problem above. I prefer code reply but any method goes...?
Thank You
-
Apr 4th, 2000, 09:05 AM
#2
Here's what you can do, use API, I'll give you the code to do it:
'declaration part
'API DECLARATION
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
'Code
Const SWP_NOMOVE = 2
Const SWP_NOSIZE = 1
Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
SetWindowPos(Form1.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
This will make your form stay on top.... HOpe this helps...
-
Apr 4th, 2000, 01:39 PM
#3
Thank you I'll try on now...
-
Apr 4th, 2000, 01:50 PM
#4
By putting:
Private Sub Form_Load()
Const SWP_NOMOVE = 2
Const SWP_NOSIZE = 1
Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
SetWindowPos(Wall.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
End Sub
and instead of using private on the form i'm using public on the module:
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
------------------
But it seems to have problem at the end of :
SetWindowPos(Wall.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS) ??
The message need = to add to the ?? as above...
Thank you..
-
Apr 4th, 2000, 05:01 PM
#5
transcendental analytic
:) (: :) (:
Remove those ()
-
Apr 4th, 2000, 09:52 PM
#6
Yea you can remove that, or what you can do is make a whole new sub with that and make it work with any form you want too, here's an example... Make this whole thing in a module, Exactly like I show you...
in a module:
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 Sub StayOnTop(frmID as form, ontop as integer)
Const SWP_NOMOVE = 2
Const SWP_NOSIZE = 1
Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
If OnTop = -1 Then
OnTop = SetWindowPos(FrmID.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
Else
OnTop = SetWindowPos(FrmID.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
End If
End Sub
And then use this sub from anyform you want to stay on top, for example...
StayOnTop(Wall.hWnd, -1)
and that window will stay on top, if you make the "-1" to whatever other number, it'll make the form NOT stay on top anymore... if you use it exactly as I got it above, it should work without errors, you don't need to make the API declaration public because the sub is in the module so no need for it to be public... oh and the reason it gave you errors at the end was one, that you used ( ) and the other is that you can simpy put "CALL" before the function and it will work, but the above method will give you a permanent ONTOP funtion,
HAPPY CODING
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
|