Results 1 to 4 of 4

Thread: Form always "on desktop" ; changing form from "on desktop" to topmost and back

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    4

    Question Form always "on desktop" ; changing form from "on desktop" to topmost and back

    Hello,

    I've got the following situation:

    My program consists currently of two forms: Blue and red. I want both of those to be "on the desktop" aka every other program should be on a higher toplevel than my forms. The blue form should ALWAYS be at the very bottom, the red form should also be at the bottom but should be able to move up/down.
    Name:  1.jpg
Views: 343
Size:  7.5 KB

    If I start any app it will obviously be on top of mine.
    Name:  2.jpg
Views: 332
Size:  9.8 KB

    Now.. if I move my mouse all over to the right border of the screen I want the red form to be topmost, and if I leave the red-form-area I want it to be on the desktop and the other app beeing on top of it again. (Same should happen with a fullscreen app, picture two)

    Name:  3.jpg
Views: 323
Size:  9.9 KB Name:  4.jpg
Views: 302
Size:  5.1 KB

    I've used search but it only brings up pretty old topics which solutions that did party/not work for me.
    So far I have:

    Blue form: 1520x1050, Top 0, Left 0
    Red form: 400x1050, Top 0, left 1520
    Timer1 on blue form (Enabled, Interval 10)
    Label1 on blue form

    Code:
       
        Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As IntPtr, _
        ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, _
        ByVal Y As Integer, ByVal cx As Integer, ByVal cy As _
        Integer, ByVal uFlags As UInt32) As Boolean
    
        ReadOnly HWND_BOTTOM As New IntPtr(1)
        ReadOnly HWND_TOP As New IntPtr(0)
    
        Private Const SWP_NOSIZE As UInt32 = &H1
        Private Const SWP_NOMOVE As UInt32 = &H2
    
    Private Sub form_blue_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            form_red.Show()
            Me.Top = 0
            Me.Left = 0
    End Sub
    
    Private Sub form_red_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.Top = 0
    Me.Left = 0
    End Sub
    
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            Label1.Text = MousePosition.X & " / " & MousePosition.Y
            If MousePosition.X = 1919 Then
                form_red.TopMost = True
                Dim flags As UInt32 = SWP_NOMOVE Or SWP_NOSIZE
                SetWindowPos(form_red.Handle, HWND_TOP, 0, 0, 0, 0, flags)
            ElseIf MousePosition.X < 1519 Then
                form_red.TopMost = False
                Dim flags As UInt32 = SWP_NOMOVE Or SWP_NOSIZE
                SetWindowPos(form_red.Handle, HWND_BOTTOM, 0, 0, 0, 0, flags)
            End If
        End Sub

    1. If I run it, then click for example my fullscreen chrome and then move to the right border, nothing will happen.

    2. If I run it, then click for example my fullscreen chrome, click on my form_blue in the taskbar (this will not show anything of my app, chrome is still fullscreen on top) and then move to the right border, red form will show up, and disappear when I leave it. Works
    2.1 If I click any other app and mine loses focus, it will do nothing again

    3. I didn't do anything with the blue form and as a result it's not on the bottom. If I put blue AND red form on bottom (If X < 1519) then it will show red form and put both red and blue above my other programs as I'm leaving the area.

    I'd appreciate any ideas.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Form always "on desktop" ; changing form from "on desktop" to topmost and back

    The blue form should ALWAYS be at the very bottom
    Then why is it a form at all? What's the point?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    4

    Re: Form always "on desktop" ; changing form from "on desktop" to topmost and back

    Quote Originally Posted by dunfiddlin View Post
    Then why is it a form at all? What's the point?
    Because I want it to replace the actual desktop. When every other apps are closed I just want my two forms to hang out there without having the normal desktop icons + wallpapers. Later on it will also have some functionality, but for a start it will just be a plain solid color or image.

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Form always "on desktop" ; changing form from "on desktop" to topmost and back

    Ultimately there is only one way to do this, which is to replace Explorer with your own application as the Windows shell. There is no such thing as a form that cannot be brought forward by some method with the standard Windows shell in place.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

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