Results 1 to 13 of 13

Thread: Topmost problem?

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Topmost problem?

    I dont understand this one at all. No matter what, i have a form thats being rude and wont stay topmost whatever i do. If i use setwindowpos or load it so its vbmodal it always goes to the back, any other ideas here? Ive never had such a troublesome form

  2. #2

  3. #3
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Re: Topmost problem?

    Are you having this trouble with a compiled program? VB doesn't let the form be topmost unless you compile it.

    Hope this helps,
    Sir Loin

  4. #4

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Topmost problem?

    martin, i dont need that as ive already used all the thoughts mentioned in it. Im positive im setting it right, so my question was more towards why isnt it working then how to do so. Sir loin, i thought you might be right, but it doesnt work out of IDE too.
    Code:
                            LoadFrm.Show
                            LoadFrm.Visible = True
                            Call SetWindowPos(LoadFrm.hwnd, -1, 0, 0, 0, 0, 3)
    should at least make it visible..but it flashes and dissapears..

  5. #5

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Topmost problem?

    And i just found out..if i walk thru the code it makes it topmost..i dont get it

  6. #6

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Topmost problem?

    so can i get some help here?

  7. #7
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Topmost problem?

    Are you doing this in form_load? If so, put this before the SetWindowPos call:
    VB Code:
    1. Me.Show

    EDIT: Its one of those days for me . I see you've done that. It helps to use the constants instead of numbers:
    VB Code:
    1. Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (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
    2.  
    3. Private Const SWP_SHOWWINDOW = &H40
    4. Private Const SWP_NOSIZE = &H1
    5. Private Const SWP_NOMOVE = &H2
    6. Private Const HWND_TOPMOST = -1
    7.  
    8. Dim ret As Long
    9. ret = SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_SHOWWINDOW)
    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Topmost problem?

    Are you using a timer in your app?

  9. #9

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Topmost problem?

    Yes i am running a timer

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Topmost problem?

    What code is in there?

  11. #11
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Topmost problem?

    Start a new exe project and it should have a Form in it.

    Go to the code section of the form and paste the following and run the project.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Sub SetWindowPos Lib "user32" _
    4.    (ByVal hwnd As Long, _
    5.    ByVal hWndInsertAfter As Long, _
    6.    ByVal X As Long, _
    7.    ByVal Y As Long, _
    8.    ByVal cx As Long, _
    9.    ByVal cy As Long, _
    10.    ByVal wFlags As Long)
    11.  
    12. Private Const HWND_TOPMOST = -1
    13. Private Const SWP_NOSIZE = &H1
    14. Private Const SWP_NOMOVE = &H2
    15. Private Const SWP_NOACTIVATE = &H10
    16.  
    17. Private Declare Function ShowWindow Lib "user32" _
    18.    (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    19.  
    20. Private Const SW_SHOWNOACTIVATE = 4
    21.  
    22. Private Sub Form_Load()
    23.    SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_NOMOVE Or SWP_NOSIZE
    24.    ShowWindow Me.hwnd, SW_SHOWNOACTIVATE
    25. End Sub

  12. #12
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Topmost problem?

    This works for me...

    VB Code:
    1. Load frmSplash
    2. DoEvents
    3. Success = SetWindowPos(frmSplash.hWnd, HWND_TOPMOST, 0, 0, 0, 0, flags)
    4. DoEvents
    5. Unload Me
    6. frmItineraryEntry.Show
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  13. #13

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Topmost problem?

    okay. i already said i know it works in other projects. I just want to know how to fix it/any debugging i should do.

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