Results 1 to 9 of 9

Thread: Make your form stay on top, please look

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Cool

    Ok, I searched VBWORLD, and I know how to make one form stay on top. Now if my program has more than one form, how do I make both of the forms be on top(not at the same time)
    NXSupport - Your one-stop source for computer help

  2. #2
    Addicted Member Mih_Flyer's Avatar
    Join Date
    Mar 2000
    Location
    some place there
    Posts
    241
    what do you mean by not at the same time???
    and if you want to make both of them stay on top, just do the same function again but change the name of the form, thats it

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Unhappy

    ok, I guess I didn't explain it clearly, I need one form to be visible at a time, and the form that is visible to be on top of all the other programs. Only problem is that in the code that I got, only had room for one name, if I write the code 2 times, an error message comes up
    NXSupport - Your one-stop source for computer help

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    What code are you using? I think you could set several window on top but they will block each other as they all are on the same level. use setforegroundwindow api to put your window topmost
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I'm using the code that I found in a
    Visual Basic Programmer's Journal


    'paste this into a module:
    Private Declare Function SetWindowPos Lib _
    "user32" (ByVal hWnd As Long, ByVal _
    hWndIsertAfter As Long, ByVal X As Long, _
    ByVal Y As Long, ByVal cx As Long, ByVal cy _
    As Long, ByVal wFlags As Long) As Long

    Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_SHOWWINDOW = &H40
    Private Const SWP_NOActivate = &H10

    Public Enum WindowPos
    vbtopmost = -1&
    vbnottopmost = -2&
    End Enum

    Public Sub SetFormPosition(hWnd As Integer, _
    Position As WindowPos)
    Const wFlags As Long = SWP_NOMOVE Or _
    SWP_NOSIZE Or SWP_SHOWWINDOW Or SWP_NOActivate
    If Position = vbtopmost Or Position = vbnottopmost Then
    SetWindowPos hWnd, Position, 0, 0, 0, 0, wFlags
    End If
    End Sub



    'Paste this into the form load procedure for it to stay on top

    SetFormPosition Me.hWnd, vbTopMost

    'paste this into a command for the form not to be on top
    SetFormPosition Me.hWnd, vbNotTopMost
    NXSupport - Your one-stop source for computer help

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I'm surprised they put hwnd as integer instead of long. Other than that, i would say it should work fine with multiple windows, just put their handle in the hwnd argument.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    Can you please tell me what code to write? I'm not very smart
    NXSupport - Your one-stop source for computer help

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Shoudn't be that hard, just pass them like this:
    Code:
    SetFormPosition form1.hwnd, vbtopmost
    SetFormPosition form2.hwnd, vbtopmost
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Cool THANKS

    THANKS ALOTTTTTTT that helped me ALOT!!!
    NXSupport - Your one-stop source for computer help

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