Set Windows/Desktop working area
Set Windows/Desktop working area
Set Windows/Desktop working area
Set Windows/Desktop working area
Set Windows/Desktop working area
Set Windows/Desktop working area Set Windows/Desktop working area Set Windows/Desktop working area Set Windows/Desktop working area Set Windows/Desktop working area Set Windows/Desktop working area Set Windows/Desktop working area Set Windows/Desktop working area
Set Windows/Desktop working area Set Windows/Desktop working area
Set Windows/Desktop working area
Go Back  Xtreme Visual Basic Talk > > > Set Windows/Desktop working area


Reply
 
Thread Tools Display Modes
  #1  
Old 05-28-2014, 08:20 AM
charlie's Avatar
charlie charlie is offline
Senior Contributor
 
Join Date: Jul 2003
Location: Barcelona (SPAIN)
Posts: 1,057
Default Set Windows/Desktop working area


Hi all!
It's been several years since I posted my last thread in this forum! Last time here I was with VB6 I've been following the .NET forum, but now it's time to ask the experts!

Well, I'm making an application which will communicate with another one running in an IE. The current version of the application is AlwaysOnTop but users are complaining everyday because the app is "over" IE and "it disturbs the view".

What I'm trying to achieve is the app keeps staying AlwaysOnTop (done!) and it will position on top of the desktop. The application is like a bar, like Windows Taskbar (a bit bigger). But the "thing" is: when this app is running, the available desktop area must be "fit" outside the app. I mean, the app is on top of the screen and IE and any other application/window, when it get meximized, must be "below" the app. I don't know if someone will understand what I'm trying to explain... I'm attaching an image (an image is worth 1000 words).

The point is: how to make my app to hace the same behavior as Windows Taskbar for maximizing other applications. Whan maximizing applications, they don't cover Windows Taskbar. That is what I want.

I've been looking for it but I don't know how to achieve this.
By the way, I'm using VB 2010.

Thank you very very much!
Attached Images
File Type: jpg example.jpg (154.2 KB, 14 views)
__________________
01000011011010000110000101110010011011000110100101100101
~ En mi vida sólo hay dos días que no me importan: ayer y mañana ~
Reply With Quote
  #2  
Old 06-03-2014, 01:15 AM
Goggy's Avatar
Goggy Goggy is offline
Contributor
 
Join Date: Sep 2005
Location: Enschede,The Netherlands
Posts: 670
Default Not perfect but a start

Code:
Public Class AppBar

        Inherits System.Windows.Forms.Form

        Private Structure RECT
            Public left As Integer
            Public top As Integer
            Public right As Integer
            Public bottom As Integer
        End Structure
        Private Structure APPBARDATA
            Public cbSize As Integer
            Public hWnd As IntPtr
            Public uCallbackMessage As Integer
            Public uEdge As Integer
            Public rc As RECT
            Public lParam As IntPtr
        End Structure
        Private Enum ABMsg As Integer
            ABM_NEW = 0
            ABM_REMOVE = 1
            ABM_QUERYPOS = 2
            ABM_SETPOS = 3
            ABM_GETSTATE = 4
            ABM_GETTASKBARPOS = 5
            ABM_ACTIVATE = 6
            ABM_GETAUTOHIDEBAR = 7
            ABM_SETAUTOHIDEBAR = 8
            ABM_WINDOWPOSCHANGED = 9
            ABM_SETSTATE = 10
        End Enum
        Private Enum ABNotify As Integer
            ABN_STATECHANGE = 0
            ABN_POSCHANGED
            ABN_FULLSCREENAPP
            ABN_WINDOWARRANGE
        End Enum
        Private Enum ABEdge As Integer
            ABE_LEFT = &H0
            ABE_TOP = &H1
            ABE_RIGHT = &H2
            ABE_BOTTOM = &H3
        End Enum

        Private Declare Function SHAppBarMessage Lib "shell32.dll" Alias "SHAppBarMessage" (ByVal dwMessage As Integer, <MarshalAs(UnmanagedType.Struct)> ByRef pData As APPBARDATA) As Integer
        Private Declare Function MoveWindow Lib "user32" Alias "MoveWindow" (ByVal hwnd As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Integer) As Integer
        Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Integer
        Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As Point) As Boolean

        Private BarIsRegistered As Boolean = False
        Private BarIsPinned As Boolean = False
        Private BarIsFocused As Boolean = False

        Private CallBack As Integer
        Private DockedEdge As ABEdge

        Private m_MinimumWindowSize As Integer = &HC8 ' System.Windows.Forms.SystemInformation.CaptionHeight + &H1F
        Private m_NormalWindowSize As Integer = &HC8
        Private m_DockedScreen As Integer = &H0

        Private Const WM_MOUSEHOVER As Integer = &H2A1
        Private Const WM_MOUSELEAVE As Integer = &H2A3

        Private Const CaptionButtonSize As Integer = &H18

        Private Event Focus_Changed(ByVal HasFocus As Boolean)

        ''' <summary>
        ''' Gets or sets the minimum size of the window.
        ''' </summary>
        ''' <value>
        ''' The minimum size of the window.
        ''' </value>
        Public Property MinimumWindowSize() As Integer
            Get
                Return m_MinimumWindowSize
            End Get
            Set(ByVal value As Integer)
                m_MinimumWindowSize = value
            End Set
        End Property
        ''' <summary>
        ''' Gets or sets the size of the normal window.
        ''' </summary>
        ''' <value>
        ''' The size of the normal window.
        ''' </value>
        Public Property NormalWindowSize() As Integer
            Get
                Return m_NormalWindowSize
            End Get
            Set(ByVal value As Integer)
                m_NormalWindowSize = value
            End Set
        End Property
        ''' <summary>
        ''' Gets or sets the docked screen.
        ''' </summary>
        ''' <value>
        ''' The docked screen.
        ''' </value>
        Public Property DockedScreen() As Integer
            Get
                Return m_DockedScreen
            End Get
            Set(ByVal value As Integer)
                m_DockedScreen = value
            End Set
        End Property
#Region "Form events"
        ''' <summary>
        ''' Raises the <see cref="E:System.Windows.Forms.Form.Closing" /> event.
        ''' </summary>
        ''' <param name="e">A <see cref="T:System.ComponentModel.CancelEventArgs" /> that contains the event data.</param>
        Protected Overrides Sub OnClosing(e As System.ComponentModel.CancelEventArgs)
            MyBase.OnClosing(e)
            RegisterBar()
        End Sub
        ''' <summary>
        ''' Raises the <see cref="E:System.Windows.Forms.Form.Load" /> event.
        ''' </summary>
        ''' <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
        Protected Overrides Sub OnLoad(e As System.EventArgs)
            MyBase.OnLoad(e)
            ' Set the priority to above normal to run the program in a nice speed.
            Threading.Thread.CurrentThread.Priority = Threading.ThreadPriority.AboveNormal
            DockedEdge = ABEdge.ABE_LEFT

            Select Case DockedEdge
                Case ABEdge.ABE_LEFT, ABEdge.ABE_RIGHT
                    Me.Width = m_NormalWindowSize
                Case Else
                    Me.Height = m_NormalWindowSize
            End Select

            RegisterBar()

            Me.Invalidate()
            Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
        End Sub
        ''' <summary>
        ''' Raises the <see cref="E:System.Windows.Forms.Form.ResizeEnd" /> event.
        ''' </summary>
        ''' <param name="e">A <see cref="T:System.EventArgs" /> that contains the event data.</param>
        Protected Overrides Sub OnResizeEnd(e As System.EventArgs)
            MyBase.OnResizeEnd(e)
            ABSetPos(DockedEdge)
        End Sub
        ''' <summary>
        ''' </summary>
        ''' <param name="m">The Windows <see cref="T:System.Windows.Forms.Message" /> to process.</param>
        Protected Overloads Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
            If m.Msg = CallBack Then
                Select Case m.WParam.ToInt32()
                    Case CInt(ABNotify.ABN_POSCHANGED)
                        ABSetPos(DockedEdge)
                        Exit Select
                End Select
            End If
            MyBase.WndProc(m)
        End Sub
#End Region
#Region "Application Bar Routines"
        ''' <summary>
        ''' Registers the bar.
        ''' </summary>
        Private Sub RegisterBar()
            Dim abd As New APPBARDATA

            abd.cbSize = Marshal.SizeOf(abd)
            abd.hWnd = Me.Handle

            If Not BarIsRegistered Then
                CallBack = RegisterWindowMessage("AppBarMessage")
                abd.uCallbackMessage = CallBack

                Dim ret As Integer = SHAppBarMessage(CType(ABMsg.ABM_NEW, Integer), abd)
                BarIsRegistered = True

                ABSetPos(DockedEdge)
            Else
                SHAppBarMessage(ABMsg.ABM_REMOVE, abd)
                BarIsRegistered = False
            End If
        End Sub
        ''' <summary>
        ''' Abs the set position.
        ''' </summary>
        ''' <param name="Edge">The edge.</param>
        Private Sub ABSetPos(ByRef Edge As ABEdge)
            Dim abd As New APPBARDATA()
            Dim Screen As Screen = Screen.AllScreens(DockedScreen)
            abd.cbSize = Marshal.SizeOf(abd)
            abd.hWnd = Me.Handle
            abd.uEdge = Edge

            If abd.uEdge = CInt(ABEdge.ABE_LEFT) OrElse abd.uEdge = CInt(ABEdge.ABE_RIGHT) Then
                abd.rc.top = Screen.Bounds.Top
                abd.rc.bottom = Screen.WorkingArea.Height
                If abd.uEdge = CInt(ABEdge.ABE_LEFT) Then
                    abd.rc.left = Screen.Bounds.Left
                    abd.rc.right = m_MinimumWindowSize
                Else
                    abd.rc.right = Screen.WorkingArea.Width
                    abd.rc.left = abd.rc.right - m_MinimumWindowSize
                End If
            Else
                abd.rc.left = Screen.Bounds.Left
                abd.rc.right = Screen.WorkingArea.Width
                If abd.uEdge = CInt(ABEdge.ABE_TOP) Then
                    abd.rc.top = Screen.Bounds.Top
                    abd.rc.bottom = Me.Size.Height
                Else
                    abd.rc.bottom = Screen.WorkingArea.Height
                    abd.rc.top = abd.rc.bottom - Me.Size.Height
                End If
            End If
            ' Query the system for an approved size and position. 
            SHAppBarMessage(CInt(ABMsg.ABM_QUERYPOS), abd)
            ' Adjust the rectangle, depending on the edge to which the 
            ' appbar is anchored. 
            Select Case abd.uEdge
                Case CInt(ABEdge.ABE_LEFT)
                    abd.rc.right = abd.rc.left
                Case CInt(ABEdge.ABE_RIGHT)
                    abd.rc.left = abd.rc.right
                Case CInt(ABEdge.ABE_TOP)
                    abd.rc.bottom = abd.rc.top
                Case CInt(ABEdge.ABE_BOTTOM)
                    abd.rc.top = abd.rc.bottom
            End Select
            ' Pass the final bounding rectangle to the system. 
            SHAppBarMessage(CInt(ABMsg.ABM_SETPOS), abd)
            ' Move and size the appbar so that it conforms to the 
            ' bounding rectangle passed to the system. 
            MoveWindow(abd.hWnd.ToInt32, abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, 1)
        End Sub
#End Region
    End Class
__________________
As finishing touch, god created the Dutch!

utterly useless, but always trying to help
Reply With Quote
  #3  
Old 06-03-2014, 02:23 AM
charlie's Avatar
charlie charlie is offline
Senior Contributor
 
Join Date: Jul 2003
Location: Barcelona (SPAIN)
Posts: 1,057
Default

Thanks Googy!! It worked!
__________________
01000011011010000110000101110010011011000110100101100101
~ En mi vida sólo hay dos días que no me importan: ayer y mañana ~
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Set Windows/Desktop working area
Set Windows/Desktop working area
Set Windows/Desktop working area Set Windows/Desktop working area
Set Windows/Desktop working area
Set Windows/Desktop working area
Set Windows/Desktop working area Set Windows/Desktop working area Set Windows/Desktop working area Set Windows/Desktop working area Set Windows/Desktop working area Set Windows/Desktop working area Set Windows/Desktop working area
Set Windows/Desktop working area
Set Windows/Desktop working area
 
Set Windows/Desktop working area
Set Windows/Desktop working area
 
-->