Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

ontop

how do I make a form always ontop using code?


Comments

  • Simple:


    API:


    Private 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


    Constants:


    Private Const HWND_TOPMOST = -1

    Private Const HWND_NOTOPMOST = -2

    Private Const SWP_NOSIZE = &H1

    Private Const SWP_NOMOVE = &H2

    Private Const SWP_NOACTIVATE = &H10


    Code:


    (On top)


    x = SetWindowPos(Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOACTIVATE)


    (Normal)


    x = SetWindowPos(Me.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOACTIVATE)


  • Where am I supposed to put what? I don't understand. Is something supposed to go in a module?


  • The API and the constants go in the declarations section of your form(if you want the function available to your whole app, put them in a module and change the "Private" keyword to "Public"). The code goes in any event, sub or function that you want to trigger it.




  • I tried everything you said and it still doesn't work, could you send me a project at mrcool4444@hotmail.com. Thanks!





  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    _____ \ http://forcoder.org \ free video tutorials and ebooks about < R Swift Perl Go Visual Basic .NET Visual Basic Python MATLAB Assembly Scratch PHP PL/SQL Ruby C++ C# Delphi Objective-C C JavaScript Java FoxPro Hack Ada Rust Alice Erlang Clojure Julia Apex Lua Fortran Logo Scheme ML Kotlin Awk Bash Transact-SQL SAS F# ABAP Scala LabVIEW Crystal VBScript Dart COBOL D Prolog Lisp /> ____________

Sign In or Register to comment.