Results 1 to 8 of 8

Thread: Always on top

  1. #1
    Guest

    Wink

    What's the best way to keep a single form always on top of my VB app? I don't want it to be on top of other apps (like with HWND_TOPMOST), just mine.

  2. #2
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535

    Talking

    Private Sub Timer1_Timer()
    Form1.zorder
    End Sub

    Private Sub Form_Load()
    Timer1.Interval=250
    End Sub

    Hope this solves your problem.

    Good luck

    Kinjal

  3. #3
    Guest
    you could do
    Code:
    Form2.Show Vbmodal
    but that wont let you have acess to any other form, will form2 is closed

  4. #4
    Guest
    Dennis- Thx, but I've got to use the other forms. This is sort of an "advertisement"

    kinjalgp- Isn't there a more graceful way to do this? If I do it this way, the user will be able to "flash" the form under another and then back up.

    Anyone?

  5. #5
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    This will definitely keep your form on top of all.

    Public Sub AlwaysOnTop(Form1 As Form, SetOnTop As Boolean)
    If SetOnTop Then
    lFlag = HWND_TOPMOST
    Else
    lFlag = HWND_NOTOPMOST
    End If

    SetWindowPos Form3.hwnd, lFlag, Form1.Left / Screen.TwipsPerPixelX, _
    Form1.Top / Screen.TwipsPerPixelY, Form1.Width / Screen.TwipsPerPixelX, _
    Form1.Height / Screen.TwipsPerPixelY, SWP_NOACTIVATE Or SWP_SHOWWINDOW
    End Sub

    Private Sub Form_load()
    AlwaysOnTop Form1, True
    End Sub

    Good Luck
    Kinjal

  6. #6
    Lively Member
    Join Date
    Mar 2000
    Posts
    82
    try - form.show ,me
    VB 6.0 Pro | VC++ 6.0

  7. #7
    Guest
    OK, let me clarify my question:

    I have an app with about a dozen forms which open and close at various points in the application. I want one form to be on top of all of this (so I can't give it a distinct owner, _bman_) However, if my app is sent to the background I want this window to go with.


  8. #8
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    If you send your app to background then you can also set Form1's property somewhat like this
    Private Sub Form1_LostFocus()
    AlwaysOnTop Form1, False
    End Sub

    This will send Form1 behind other forms.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width