CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Stay On Top

  1. #1
    Join Date
    Sep 2000
    Posts
    58

    Stay On Top

    Does anyone know how to make an MDIChild form stay on top of other MDIChild forms.

    Thanks,
    Patrick.


  2. #2
    Join Date
    Apr 2001
    Posts
    95

    Re: Stay On Top

    Not at all sure on this but you might want to investigate the BringWindowToTop API function.


  3. #3
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Stay On Top

    this function will force a window to always be on top. It doesn't obey the MDI child rules though,


    public Const SWP_NOMOVE = 2
    public Const SWP_NOSIZE = 1
    public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
    public Const HWND_TOPMOST = -1
    public Const HWND_NOTOPMOST = -2

    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 MakeTopMost(hwnd as Long, optional Topmost as Boolean = true)

    If Topmost = true then 'Make the window topmost
    Call SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
    else
    Call SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
    End If

    End Sub




    call it like this to turn it on:

    Call MakeTopMost(Form1.hwnd, true)




    and to turn it off:

    Call MakeTopMost(Form1.hwnd, false)




    hope this helps,

    john

    John Pirkey
    MCSD
    http://www.ShallowWaterSystems.com
    http://www.stlvbug.org
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

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

Featured