|
-
Aug 1st, 2000, 08:27 AM
#1
Thread Starter
Lively Member
Hi,
I'm building a one form application to work alongside a SCADA system.
I need the for to remain on top of this SCADA system at all times (I don't want it to be modal as the users of the SCADA need to be able to perform functions), I just need it to sit on top of this other window.
Does anyone know how to do this?
Best Regards,
Rob Brown.
-
Aug 1st, 2000, 08:30 AM
#2
_______
<?>
Code:
'to make form stay topmost
'put this in a bas 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
Global Const SWP_NOMOVE = 2
Global Const SWP_NOSIZE = 1
Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2
'=============================================
'
'put this in events click or load or whatever
'or hardcopy
'To set Form1 as a TopMost form, do the following:
res& = SetWindowPos (Form1.hWnd, HWND_TOPMOST, _
0, 0, 0, 0, FLAGS)
'if res&=0, there is an error
'To turn off topmost (make the form act normal again):
res& = SetWindowPos (Form1.hWnd, HWND_NOTOPMOST, _
0, 0, 0, 0, FLAGS)
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 1st, 2000, 09:03 AM
#3
Hyperactive Member
Note:
Just something to add to that, with some stayontop codes, alt + esc makes it loose priority. If yours does this can be a flaw like ive found out the hard way. To avoid that either set a loop or timer that everytime that form is visible to stayontop.
-RaY
VB .Net 2010 (Ultimate)
-
Aug 1st, 2000, 09:06 AM
#4
_______
<?>
not so much a flaw as an override by windows..
Alt/tab switches screens...yes this one falls to that as well.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 1st, 2000, 09:30 AM
#5
Fanatic Member
put the ontop statment if the form_activate sub
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Aug 1st, 2000, 09:43 AM
#6
Thread Starter
Lively Member
Thanks,
the code keeps the window on top, however:
The window is resized and part of it (title bar) is missing (off the top of the screen).
I've tried playing around with the x,y,cx,cy co-ordinates but it makes no difference.
Is there some way to set the Z-order without moving or sizing the window?
Best regards,
Rob Brown.
-
Aug 1st, 2000, 10:17 AM
#7
_______
<?>
You might want to look up SetWindowPos in API functions and set your windows in compatible spaces.
I've used it(don't fully understand it) by putting my app at top 0 left 0 (top right) and then position Notepad directly below it(bottom right)
Maybe it might apply to your situtation.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
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
|