Results 1 to 3 of 3

Thread: Keep form at the back of all windows.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2009
    Location
    Scotland, UK
    Posts
    26

    Lightbulb Keep form at the back of all windows.

    Hi there i was just thinking earlier if i could make a little application that stays on the back of all the applications. Like the desktop. I was just wanting to know if there was a little piece of code that keeps the form at the back all of the time, also i would like to know if there was a simple piece of code that takes away the minimize, maximize and the exit button from the top of the form.

    Thanks in advanced.
    Alistair.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Keep form at the back of all windows.

    For question #1. It is an API call. Try the following
    Code:
    ' place this at the top of your form
    Private Const HWND_BOTTOM As Long = 1
    Private Const SWP_NOMOVE As Long = &H2
    Private Const SWP_NOSIZE As Long = &H1
    Private Declare Function SetWindowPos Lib "user32.dll" (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
    
    ' now in your form load event, try adding this line
    SetWindowPos Me.hWnd, HWND_BOTTOM, 0,0, 0,0, SWP_NOMOVE Or SWP_NOSIZE
    Note that the above won't guarantee that your form will always be at the bottom of the zOrder. This is because other windows can also add themselves to the bottom and if done after yours, then they will be below your window. Understand. There is another possible solution using SetParent and GetDesktopWindow APIs.

    For question #2. Your form has a property call ControlBox. Set it to False
    But be warned, if you do this then there is no way your users can close the application (except taskmanager) without you providing a menu or some other button to close it. Last but not least, you also want to prevent the window from showing on the task bar (ShowInTaskbar property), else users can hit FlyingWindowsKey + M to minimize your window. Pretty sure about that, but not positive.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2009
    Location
    Scotland, UK
    Posts
    26

    Re: Keep form at the back of all windows.

    Thanks yet again LaVolpe. Great work. I will reply later if it does what i want it to 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