begin process at 2010 03 20 18:54:51
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

API

 > SAVOIR SI UNE FENETRE EST VISIBLE DANS LA BARRE DE TACHE ( .NET )

SAVOIR SI UNE FENETRE EST VISIBLE DANS LA BARRE DE TACHE ( .NET )


 Information sur la source

Note :
9 / 10 - par 1 personne
9,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :API Source .NET ( DotNet ) Classé sous :task, taskbar, alttab, barre, tache Niveau :Initié Date de création :04/04/2005 Date de mise à jour :04/11/2005 11:35:53 Vu :11 897

Auteur : Alain Proviste

Ecrire un message privé
Site perso
Ce membre participe au partage de revenus publicitaires
Commentaire sur cette source (3)
Ajouter un commentaire et/ou une note


 Description

cette classe ( inachevée ) contient des routines pour tester si une fenetre est listée dans la taskbar ( et le alt-tab ) et pour recupérer l'icone associée a cette fenetre ( pour coder une fausse taskbar ! )

LA CLASSE EST INACHEVEE ( pas de try catch, code imparfait ) c'est un départ pour ceux qui ont comme moi lutté pour trouver les critères ( styles ) qui ne sont pas complètement ce que la msdn nous dit !

Afin de vous éviter de chercher pendant des heures une logique dans spy++ , je publie cette source, ne ralez pas si le code est crade, c'est à vous de mettre en forme, c'est une matière première !

Source

  • #Region "Copyright"
  • '************************************************************************
  • '* Auteur * Proviste / Coq *
  • '* Date Création * 07/12/04 *
  • '* Derniere Modification * 25/12/04 *
  • '************************************************************************
  • '* * *
  • '* Module * clsHwndInfos *
  • '* * *
  • '* Description * Operation et information sur les hwnd *
  • '* * *
  • '* * *
  • '************************************************************************
  • #End Region
  • #Region "Imports"
  • '-_-'
  • Imports System.Runtime.InteropServices
  • #End Region
  • Public Class clsHwndInfo
  • #Region " Declaration"
  • #Region " Enum Window Style :o"
  • Private Enum enWindowStyles
  • WS_BORDER = &H800000
  • WS_CAPTION = &HC00000
  • WS_CHILD = &H40000000
  • WS_CLIPCHILDREN = &H2000000
  • WS_CLIPSIBLINGS = &H4000000
  • WS_DISABLED = &H8000000
  • WS_DLGFRAME = &H400000
  • WS_EX_ACCEPTFILES = &H10&
  • WS_EX_DLGMODALFRAME = &H1&
  • WS_EX_NOPARENTNOTIFY = &H4&
  • WS_EX_TOPMOST = &H8&
  • WS_EX_TRANSPARENT = &H20&
  • WS_EX_TOOLWINDOW = &H80&
  • WS_GROUP = &H20000
  • WS_HSCROLL = &H100000
  • WS_MAXIMIZE = &H1000000
  • WS_MAXIMIZEBOX = &H10000
  • WS_MINIMIZE = &H20000000
  • WS_MINIMIZEBOX = &H20000
  • WS_OVERLAPPED = &H0&
  • WS_POPUP = &H80000000
  • WS_SYSMENU = &H80000
  • WS_TABSTOP = &H10000
  • WS_THICKFRAME = &H40000
  • WS_VISIBLE = &H10000000
  • WS_VSCROLL = &H200000
  • '\\ New from 95/NT4 onwards
  • WS_EX_MDICHILD = &H40
  • WS_EX_WINDOWEDGE = &H100
  • WS_EX_CLIENTEDGE = &H200
  • WS_EX_CONTEXTHELP = &H400
  • WS_EX_RIGHT = &H1000
  • WS_EX_LEFT = &H0
  • WS_EX_RTLREADING = &H2000
  • WS_EX_LTRREADING = &H0
  • WS_EX_LEFTSCROLLBAR = &H4000
  • WS_EX_RIGHTSCROLLBAR = &H0
  • WS_EX_CONTROLPARENT = &H10000
  • WS_EX_STATICEDGE = &H20000
  • WS_EX_APPWINDOW = &H40000
  • WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE Or WS_EX_CLIENTEDGE)
  • WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE Or _
  • WS_EX_TOOLWINDOW Or WS_EX_TOPMOST)
  • End Enum
  • #End Region
  • #Region " GetWindowLong Diverses Declaration"
  • <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="GetWindowLong")> _
  • Private Shared Function GetWindowLong32(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
  • End Function
  • <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="GetWindowLong")> _
  • Private Shared Function GetWindowLongPtr(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As IntPtr
  • End Function
  • <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="GetWindowLong")> _
  • Private Shared Function GetWindowLong64(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Long
  • End Function
  • #End Region
  • #Region " GetClassLong Diverses Declaration"
  • <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="GetClassLong", SetLastError:=True)> _
  • Private Shared Function GetClassLong32(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
  • End Function
  • <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="GetClassLong", SetLastError:=True)> _
  • Private Shared Function GetClassLongPtr(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As IntPtr
  • End Function
  • <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="GetClassLong", SetLastError:=True)> _
  • Private Shared Function GetClassLong64(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Long
  • End Function
  • #End Region
  • <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="SendMessage")> _
  • Private Shared Function SendMessagePtr(ByVal hwnd As IntPtr, _
  • ByVal wMsg As Int32, _
  • ByVal wParam As Integer, _
  • ByVal lParam As Integer) As IntPtr
  • End Function
  • '-sendmessage
  • Private Declare Function SendMessage _
  • Lib "user32" _
  • Alias "SendMessageA" _
  • (ByVal hwnd As IntPtr, _
  • ByVal wMsg As Int32, _
  • ByVal wParam As Integer, _
  • ByVal lParam As System.Text.StringBuilder) As Integer
  • Private Declare Function SendMessage _
  • Lib "user32" _
  • Alias "SendMessageA" _
  • (ByVal hwnd As IntPtr, _
  • ByVal wMsg As Int32, _
  • ByVal wParam As Integer, _
  • ByVal lParam As Integer) As Integer
  • Private Const WM_SETTEXT = &HC
  • Private Const WM_GETTEXT = &HD
  • Private Const WM_GETTEXTLENGTH = &HE
  • Private Const WM_SETICON = &H80
  • Private Const WM_GETICON = &H7F
  • Private Const ICON_SMALL = 0
  • Private Const ICON_BIG = 1
  • Private Const Icon_BIG_XP = 2
  • Private Enum enGetWindowLong
  • GWL_EXSTYLE = (-20)
  • GWL_HINSTANCE = (-6)
  • GWL_HWNDPARENT = (-8)
  • GWL_ID = (-12)
  • GWL_STYLE = (-16)
  • GWL_USERDATA = (-21)
  • GWL_WNDPROC = (-4)
  • End Enum
  • Private Enum enGetWindowLongPtr
  • GCLP_MENUNAME = (-8)
  • GCLP_HBRBACKGROUND = (-10)
  • GCLP_HCURSOR = (-12)
  • GCLP_HICON = (-14)
  • GCLP_HMODULE = (-16)
  • GCLP_WNDPROC = (-24)
  • GCLP_HICONSM = (-34)
  • End Enum
  • Private Const GCL_CBCLSEXTRA = -20
  • Private Const GCL_CBWNDEXTRA = -18
  • Private Const GCL_HCURSOR = -12
  • Private Const GCL_HICON = -14
  • Private Const GCL_HMODULE = -16
  • Private Const GCL_MENUNAME = -8
  • Private Const GCL_STYLE = -26
  • Private Const GCL_WNDPROC = -24
  • Private Const GCL_HICONSM = -34
  • Private myHwndPtr As IntPtr
  • #End Region
  • #Region " Procédures"
  • #Region " Publiques"
  • ''' -----------------------------------------------------------------------------
  • ''' <summary>
  • ''' Crée une nouvelle instance de la classe.
  • ''' </summary>
  • ''' <param name="hwndptr">Hwndptr qui sera traité</param>
  • ''' <remarks>
  • ''' </remarks>
  • ''' <history>
  • ''' Proviste 28/12/2004 Created
  • ''' </history>
  • ''' -----------------------------------------------------------------------------
  • Public Sub New(ByVal hwndptr As IntPtr)
  • NewInst(hwndptr)
  • End Sub
  • ''' -----------------------------------------------------------------------------
  • ''' <summary>
  • ''' Crée une nouvelle instance de la classe
  • ''' </summary>
  • ''' <param name="hwnd"></param>
  • ''' <remarks>
  • ''' </remarks>
  • ''' <history>
  • ''' Proviste 28/12/2004 Created
  • ''' </history>
  • ''' -----------------------------------------------------------------------------
  • Public Sub New(ByVal hwnd As Long)
  • NewInst(New IntPtr(hwnd))
  • End Sub
  • #End Region
  • #Region " Privées"
  • Private Sub NewInst(ByVal hwndptr As IntPtr)
  • myHwndPtr = hwndptr
  • End Sub
  • #End Region
  • #End Region
  • #Region " Property"
  • ''' -----------------------------------------------------------------------------
  • ''' <summary>
  • ''' Cette propriété renvoie ou définie le texte associé à un hwnd.
  • ''' </summary>
  • ''' <value>Valeur de type string</value>
  • ''' <remarks>
  • ''' </remarks>
  • ''' <history>
  • ''' Proviste 28/12/2004 Created
  • ''' </history>
  • ''' -----------------------------------------------------------------------------
  • Public Property WindowText() As String
  • Get
  • Dim wdsTxtBuilt As System.Text.StringBuilder
  • Dim wdsTxtLength As Integer
  • wdsTxtLength = SendMessage(myHwndPtr, WM_GETTEXTLENGTH, 0, 0) + 1
  • wdsTxtBuilt = New System.text.StringBuilder(Chr(0), wdsTxtLength)
  • SendMessage(myHwndPtr, WM_GETTEXT, wdsTxtLength, wdsTxtBuilt)
  • Return wdsTxtBuilt.ToString
  • End Get
  • Set(ByVal Value As String)
  • SendMessage(myHwndPtr, WM_SETTEXT, Value.Length, New System.Text.StringBuilder(Value))
  • End Set
  • End Property
  • ''' -----------------------------------------------------------------------------
  • ''' <summary>
  • ''' Retourne une valeur booléene pour savoir si l'objet associée au hwnd ( à priori une feuille ) est affichée dans la barre des tâche.
  • ''' </summary>
  • ''' <value>True : la form associée au hwnd passé en paramètre est affichée dans la barre des tâches</value>
  • ''' <remarks>
  • ''' </remarks>
  • ''' <history>
  • ''' Proviste 01/12/2005 Created
  • ''' </history>
  • ''' -----------------------------------------------------------------------------
  • Public ReadOnly Property ShownInTaskBar() As Boolean
  • Get
  • If myHwndPtr.Size = 8 Then 'win64
  • Dim wStyles As Long
  • wStyles = GetWindowLong64(myHwndPtr, enGetWindowLong.GWL_STYLE)
  • If (wStyles And enWindowStyles.WS_VISIBLE) = enWindowStyles.WS_VISIBLE Then
  • Dim wStylesEx As Long
  • wStylesEx = GetWindowLong32(myHwndPtr, enGetWindowLong.GWL_EXSTYLE)
  • If (wStylesEx And enWindowStyles.WS_EX_TOOLWINDOW) = enWindowStyles.WS_EX_TOOLWINDOW Then
  • Return False
  • Else
  • Return ((wStyles And enWindowStyles.WS_EX_APPWINDOW) = enWindowStyles.WS_EX_APPWINDOW) OrElse _
  • ((wStyles And enWindowStyles.WS_POPUP) = enWindowStyles.WS_POPUP)
  • End If
  • Else
  • Return False
  • End If
  • Else
  • Dim wStyles As Integer
  • wStyles = GetWindowLong32(myHwndPtr, enGetWindowLong.GWL_STYLE)
  • If (wStyles And enWindowStyles.WS_VISIBLE) = enWindowStyles.WS_VISIBLE Then
  • Dim wStylesEx As Integer
  • wStylesEx = GetWindowLong32(myHwndPtr, enGetWindowLong.GWL_EXSTYLE)
  • If (wStylesEx And enWindowStyles.WS_EX_TOOLWINDOW) = enWindowStyles.WS_EX_TOOLWINDOW Then
  • Return False
  • Else
  • Return ((wStyles And enWindowStyles.WS_EX_APPWINDOW) = enWindowStyles.WS_EX_APPWINDOW) OrElse _
  • ((wStyles And enWindowStyles.WS_POPUP) = enWindowStyles.WS_POPUP)
  • End If
  • Else
  • Return False
  • End If
  • End If
  • End Get
  • End Property
  • ''' -----------------------------------------------------------------------------
  • ''' <summary>
  • ''' Retourne une valeur booléene pour savoir si l'objet associé au hwnd est visible ( indépendement du fait qu'il soit caché ou non )
  • ''' </summary>
  • ''' <value>Renvoie True si l'objet est visible</value>
  • ''' <remarks>
  • ''' </remarks>
  • ''' <history>
  • ''' Proviste 01/12/2005 Created
  • ''' </history>
  • ''' -----------------------------------------------------------------------------
  • Public ReadOnly Property Visible() As Boolean
  • Get
  • If myHwndPtr.Size = 8 Then 'win64
  • Return ((GetWindowLong64(myHwndPtr, enGetWindowLong.GWL_EXSTYLE) And enWindowStyles.WS_VISIBLE) = enWindowStyles.WS_VISIBLE)
  • Else
  • Return ((GetWindowLong32(myHwndPtr, enGetWindowLong.GWL_EXSTYLE) And enWindowStyles.WS_VISIBLE) = enWindowStyles.WS_VISIBLE)
  • End If
  • End Get
  • End Property
  • ''' -----------------------------------------------------------------------------
  • ''' <summary>
  • ''' Renvoie ou définie le handle de l'icone associé à la fenetre
  • ''' </summary>
  • ''' <value></value>
  • ''' <remarks>
  • ''' </remarks>
  • ''' <history>
  • ''' Proviste 01/12/2005 Created
  • ''' </history>
  • ''' -----------------------------------------------------------------------------
  • Public ReadOnly Property hIcon() As IntPtr
  • Get
  • Dim hIcn As IntPtr
  • hIcn = SendMessagePtr(myHwndPtr, WM_GETICON, ICON_BIG, 0)
  • If hIcn.ToString = "0" Then
  • Return GetClassLongPtr(myHwndPtr, GCL_HICON)
  • Else
  • Return hIcn
  • End If
  • End Get
  • ' Set(ByVal Value As IntPtr)
  • ' 'MsgBox(SetClassLong(myHwndPtr, GCL_HICON, Value))
  • ' End Set
  • End Property
  • ''' -----------------------------------------------------------------------------
  • ''' <summary>
  • ''' Renvoie ou définie le handle de l'icone 16*16 associé à la fenetre
  • ''' </summary>
  • ''' <value></value>
  • ''' <remarks>
  • ''' </remarks>
  • ''' <history>
  • ''' Proviste 01/12/2005 Created
  • ''' </history>
  • ''' -----------------------------------------------------------------------------
  • Public ReadOnly Property hIconSmall() As IntPtr
  • Get
  • Dim hIcn As IntPtr
  • hIcn = SendMessagePtr(myHwndPtr, WM_GETICON, ICON_SMALL, 0)
  • If hIcn.Equals(IntPtr.Zero) Then
  • Return GetClassLongPtr(myHwndPtr, GCL_HICONSM)
  • Else
  • Return hIcn
  • End If
  • End Get
  • ' Set(ByVal Value As IntPtr)
  • '
  • ' End Set
  • End Property
  • #End Region
  • End Class
#Region "Copyright"
'************************************************************************
'* Auteur                   * Proviste / Coq                            *
'* Date Création            * 07/12/04                                  *
'* Derniere Modification    * 25/12/04                                  *
'************************************************************************
'*              *                                                       *
'* Module       * clsHwndInfos                                          *
'*              *                                                       *
'* Description  * Operation et information sur les hwnd                 *
'*              *                                                       *
'*              *                                                       *
'************************************************************************
#End Region

#Region "Imports"
'-_-'
Imports System.Runtime.InteropServices
#End Region

Public Class clsHwndInfo
#Region "   Declaration"

#Region "        Enum Window Style :o"
    Private Enum enWindowStyles
        WS_BORDER = &H800000
        WS_CAPTION = &HC00000
        WS_CHILD = &H40000000
        WS_CLIPCHILDREN = &H2000000
        WS_CLIPSIBLINGS = &H4000000
        WS_DISABLED = &H8000000
        WS_DLGFRAME = &H400000
        WS_EX_ACCEPTFILES = &H10&
        WS_EX_DLGMODALFRAME = &H1&
        WS_EX_NOPARENTNOTIFY = &H4&
        WS_EX_TOPMOST = &H8&
        WS_EX_TRANSPARENT = &H20&
        WS_EX_TOOLWINDOW = &H80&
        WS_GROUP = &H20000
        WS_HSCROLL = &H100000
        WS_MAXIMIZE = &H1000000
        WS_MAXIMIZEBOX = &H10000
        WS_MINIMIZE = &H20000000
        WS_MINIMIZEBOX = &H20000
        WS_OVERLAPPED = &H0&
        WS_POPUP = &H80000000
        WS_SYSMENU = &H80000
        WS_TABSTOP = &H10000
        WS_THICKFRAME = &H40000
        WS_VISIBLE = &H10000000
        WS_VSCROLL = &H200000
        '\\ New from 95/NT4 onwards
        WS_EX_MDICHILD = &H40
        WS_EX_WINDOWEDGE = &H100
        WS_EX_CLIENTEDGE = &H200
        WS_EX_CONTEXTHELP = &H400
        WS_EX_RIGHT = &H1000
        WS_EX_LEFT = &H0
        WS_EX_RTLREADING = &H2000
        WS_EX_LTRREADING = &H0
        WS_EX_LEFTSCROLLBAR = &H4000
        WS_EX_RIGHTSCROLLBAR = &H0
        WS_EX_CONTROLPARENT = &H10000
        WS_EX_STATICEDGE = &H20000
        WS_EX_APPWINDOW = &H40000
        WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE Or WS_EX_CLIENTEDGE)
        WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE Or _
                                 WS_EX_TOOLWINDOW Or WS_EX_TOPMOST)
    End Enum
#End Region

#Region "   GetWindowLong Diverses Declaration"

    <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="GetWindowLong")> _
   Private Shared Function GetWindowLong32(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
    End Function

    <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="GetWindowLong")> _
    Private Shared Function GetWindowLongPtr(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As IntPtr
    End Function

    <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="GetWindowLong")> _
    Private Shared Function GetWindowLong64(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Long
    End Function

#End Region

#Region "   GetClassLong Diverses Declaration"

    <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="GetClassLong", SetLastError:=True)> _
    Private Shared Function GetClassLong32(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
    End Function

    <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="GetClassLong", SetLastError:=True)> _
    Private Shared Function GetClassLongPtr(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As IntPtr
    End Function

    <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="GetClassLong", SetLastError:=True)> _
    Private Shared Function GetClassLong64(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Long
    End Function

#End Region


    <DllImport("user32.dll", CharSet:=CharSet.Ansi, EntryPoint:="SendMessage")> _
    Private Shared Function SendMessagePtr(ByVal hwnd As IntPtr, _
        ByVal wMsg As Int32, _
        ByVal wParam As Integer, _
        ByVal lParam As Integer) As IntPtr
    End Function

    '-sendmessage
    Private Declare Function SendMessage _
        Lib "user32" _
        Alias "SendMessageA" _
       (ByVal hwnd As IntPtr, _
        ByVal wMsg As Int32, _
        ByVal wParam As Integer, _
    ByVal lParam As System.Text.StringBuilder) As Integer

    Private Declare Function SendMessage _
        Lib "user32" _
        Alias "SendMessageA" _
        (ByVal hwnd As IntPtr, _
        ByVal wMsg As Int32, _
        ByVal wParam As Integer, _
    ByVal lParam As Integer) As Integer

    Private Const WM_SETTEXT = &HC
    Private Const WM_GETTEXT = &HD
    Private Const WM_GETTEXTLENGTH = &HE
    Private Const WM_SETICON = &H80
    Private Const WM_GETICON = &H7F
    Private Const ICON_SMALL = 0
    Private Const ICON_BIG = 1
    Private Const Icon_BIG_XP = 2

    Private Enum enGetWindowLong
        GWL_EXSTYLE = (-20)
        GWL_HINSTANCE = (-6)
        GWL_HWNDPARENT = (-8)
        GWL_ID = (-12)
        GWL_STYLE = (-16)
        GWL_USERDATA = (-21)
        GWL_WNDPROC = (-4)
    End Enum

    Private Enum enGetWindowLongPtr
        GCLP_MENUNAME = (-8)
        GCLP_HBRBACKGROUND = (-10)
        GCLP_HCURSOR = (-12)
        GCLP_HICON = (-14)
        GCLP_HMODULE = (-16)
        GCLP_WNDPROC = (-24)
        GCLP_HICONSM = (-34)
    End Enum

    Private Const GCL_CBCLSEXTRA = -20
    Private Const GCL_CBWNDEXTRA = -18
    Private Const GCL_HCURSOR = -12
    Private Const GCL_HICON = -14
    Private Const GCL_HMODULE = -16
    Private Const GCL_MENUNAME = -8
    Private Const GCL_STYLE = -26
    Private Const GCL_WNDPROC = -24
    Private Const GCL_HICONSM = -34

    Private myHwndPtr As IntPtr

#End Region

#Region "   Procédures"
#Region "       Publiques"

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Crée une nouvelle instance de la classe.
    ''' </summary>
    ''' <param name="hwndptr">Hwndptr qui sera traité</param>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	Proviste	28/12/2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Sub New(ByVal hwndptr As IntPtr)
        NewInst(hwndptr)
    End Sub

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Crée une nouvelle instance de la classe
    ''' </summary>
    ''' <param name="hwnd"></param>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	Proviste	28/12/2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Sub New(ByVal hwnd As Long)
        NewInst(New IntPtr(hwnd))
    End Sub


#End Region

#Region "       Privées"



    Private Sub NewInst(ByVal hwndptr As IntPtr)
        myHwndPtr = hwndptr
    End Sub

#End Region

#End Region

#Region "   Property"
    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Cette propriété renvoie ou définie le texte associé à un hwnd.
    ''' </summary>
    ''' <value>Valeur de type string</value>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	Proviste	28/12/2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Property WindowText() As String
        Get
            Dim wdsTxtBuilt As System.Text.StringBuilder
            Dim wdsTxtLength As Integer

            wdsTxtLength = SendMessage(myHwndPtr, WM_GETTEXTLENGTH, 0, 0) + 1

            wdsTxtBuilt = New System.text.StringBuilder(Chr(0), wdsTxtLength)

            SendMessage(myHwndPtr, WM_GETTEXT, wdsTxtLength, wdsTxtBuilt)

            Return wdsTxtBuilt.ToString
        End Get
        Set(ByVal Value As String)
            SendMessage(myHwndPtr, WM_SETTEXT, Value.Length, New System.Text.StringBuilder(Value))
        End Set

    End Property

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Retourne une valeur booléene pour savoir si l'objet associée au hwnd ( à priori une feuille ) est affichée dans la barre des tâche.
    ''' </summary>
    ''' <value>True : la form associée au hwnd passé en paramètre est affichée dans la barre des tâches</value>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	Proviste 01/12/2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public ReadOnly Property ShownInTaskBar() As Boolean
        Get

            If myHwndPtr.Size = 8 Then 'win64
                Dim wStyles As Long
                wStyles = GetWindowLong64(myHwndPtr, enGetWindowLong.GWL_STYLE)
                If (wStyles And enWindowStyles.WS_VISIBLE) = enWindowStyles.WS_VISIBLE Then
                    Dim wStylesEx As Long
                    wStylesEx = GetWindowLong32(myHwndPtr, enGetWindowLong.GWL_EXSTYLE)
                    If (wStylesEx And enWindowStyles.WS_EX_TOOLWINDOW) = enWindowStyles.WS_EX_TOOLWINDOW Then
                        Return False
                    Else
                        Return ((wStyles And enWindowStyles.WS_EX_APPWINDOW) = enWindowStyles.WS_EX_APPWINDOW) OrElse _
                           ((wStyles And enWindowStyles.WS_POPUP) = enWindowStyles.WS_POPUP)
                    End If
                Else
                    Return False
                End If
            Else
                Dim wStyles As Integer
                wStyles = GetWindowLong32(myHwndPtr, enGetWindowLong.GWL_STYLE)
                If (wStyles And enWindowStyles.WS_VISIBLE) = enWindowStyles.WS_VISIBLE Then
                    Dim wStylesEx As Integer
                    wStylesEx = GetWindowLong32(myHwndPtr, enGetWindowLong.GWL_EXSTYLE)
                    If (wStylesEx And enWindowStyles.WS_EX_TOOLWINDOW) = enWindowStyles.WS_EX_TOOLWINDOW Then
                        Return False
                    Else
                        Return ((wStyles And enWindowStyles.WS_EX_APPWINDOW) = enWindowStyles.WS_EX_APPWINDOW) OrElse _
                           ((wStyles And enWindowStyles.WS_POPUP) = enWindowStyles.WS_POPUP)
                    End If
                Else
                    Return False
                End If
            End If
        End Get
    End Property

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Retourne une valeur booléene pour savoir si l'objet associé au hwnd est visible ( indépendement du fait qu'il soit caché ou non ) 
    ''' </summary>
    ''' <value>Renvoie True si l'objet est visible</value>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	Proviste	01/12/2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public ReadOnly Property Visible() As Boolean
        Get
            If myHwndPtr.Size = 8 Then 'win64
                Return ((GetWindowLong64(myHwndPtr, enGetWindowLong.GWL_EXSTYLE) And enWindowStyles.WS_VISIBLE) = enWindowStyles.WS_VISIBLE)
            Else
                Return ((GetWindowLong32(myHwndPtr, enGetWindowLong.GWL_EXSTYLE) And enWindowStyles.WS_VISIBLE) = enWindowStyles.WS_VISIBLE)
            End If
        End Get
    End Property

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Renvoie ou définie le handle de l'icone associé à la fenetre
    ''' </summary>
    ''' <value></value>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	Proviste	01/12/2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public ReadOnly Property hIcon() As IntPtr
        Get
            Dim hIcn As IntPtr

            hIcn = SendMessagePtr(myHwndPtr, WM_GETICON, ICON_BIG, 0)
            If hIcn.ToString = "0" Then
                Return GetClassLongPtr(myHwndPtr, GCL_HICON)
            Else
                Return hIcn
            End If

        End Get
        '        Set(ByVal Value As IntPtr)
        '           'MsgBox(SetClassLong(myHwndPtr, GCL_HICON, Value))
        '      End Set
    End Property

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Renvoie ou définie le handle de l'icone 16*16 associé à la fenetre
    ''' </summary>
    ''' <value></value>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	Proviste	01/12/2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public ReadOnly Property hIconSmall() As IntPtr
        Get
            Dim hIcn As IntPtr

            hIcn = SendMessagePtr(myHwndPtr, WM_GETICON, ICON_SMALL, 0)
            If hIcn.Equals(IntPtr.Zero) Then
                Return GetClassLongPtr(myHwndPtr, GCL_HICONSM)
            Else
                Return hIcn
            End If

        End Get
        '        Set(ByVal Value As IntPtr)
        '
        '       End Set 
    End Property
#End Region
End Class

 Conclusion

Merci au vieux coq pour son aide :D


 Historique

04 novembre 2005 11:35:54 :
j'ai corrigé deux fautes d'orthographe.

 Sources du même auteur

Source avec Zip TUTORIAL VB6 : UN CARNET D'ADRESSE / REPERTOIRE TELEPHONIQUE
Source .NET (Dotnet) EXECUTER EN TANT QUE EN .NET
Source .NET (Dotnet) FONCTION D'ACKERMAN
Source avec Zip Source .NET (Dotnet) VB.NET : DRAG & DROP DE FICHIER 'PAR EXEMPLE DEPUIS LE BURE...
Source .NET (Dotnet) TUTO VB.NET : SUPPRIMER UNE LIGNE DANS UN FICHIER

 Sources de la même categorie

Source avec Zip Source avec une capture Source .NET (Dotnet) UTILISATION DE L' API GOOGLE YOUTUBE RECHERCHER ET LIRE DES ... par tresorsdevie
Source avec Zip Source avec une capture Source .NET (Dotnet) FAIRE LA DIFFÉRENCE ENTRE UNE ADRESSE EMAIL QUI EXISTE D'UNE... par lesinfosdugeek
ENVOYER UN MESSAGE SUR SON COMPTE TWITTER par lesinfosdugeek
Source avec Zip Source avec une capture TROUVER LES CLÉS DE REGISTRE QUI CHANGENT par Flocreate
Source avec Zip IP_PUBLIQUE_INTERNETGETCONNECTEDSTATE par marco62118

 Sources en rapport avec celle ci

Source avec Zip DÉPLACER ET PARAMÉTRER LA BARRE DES TACHES / LE MENU DÉMARRE... par MS1969
Source avec Zip Source avec une capture Source .NET (Dotnet) SCROLL CONTROL USER POUR DÉROULER LES CONTROLES ET ENREGISTR... par Londonic
Source .NET (Dotnet) [.NET] IMAGELIST & NOTIFYICON par cbu
ÉTAT DE VISIBLITÉ DE LA BARRE DES TÂCHES [WIN9X] par max12
METTRE UNE ICÔNES DANS LA BARRE DE TACHES par Zarbiboss

Commentaires et avis

Commentaire de Alain Proviste le 04/04/2005 17:17:40 administrateur CS

il est possible qu'il y ait des déclaration qui ne servent à rien, j'ai vraiment ni le temps ni l'envie de trier !

Commentaire de NetWedge le 04/11/2005 00:28:34

Hi!Ton code c'est tres bien et je vois que tu utilise le Sendmessage pour recuperer le texte d'une ''form'' mais tu devrai essayer de trouver comment on recupere le texte d'un textbox par exemple,c 'est nettement moins facile....pour avoir essayer,a priori VB n'est pas tres compatible avec TOUTES les API. Il est tres dificiles d'obtenir le Handle du dernier buffer utiliser pour un textbox.En gros, le texte que l'on recupere lorsque l'on utilise GetWindowText ou SendMessage c'est le premier code inscrit dans le textbox,toutes les modifications pendant l'execution ne s'affiche pa.Voila,alors si tu trouve BRAVO A TOI....
NETWedge@Hotmail.com

Commentaire de kouki1000 le 14/07/2009 20:26:05 9/10

Je suis assez débutant en vb.net et je voudrais savoir comment utiliser cette classe... Si quelqu'un voulait bien me montrer comment... Car, comme l'a deviné Alain Proviste, je vsuis en train de coder une 2eme taskbar (sous Vista explorer.exe = 21000K de ram utilisée, donc je fais mon explorer).

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

[?]!!!!! Help !!!!!!!! j'ai besoin de masquer la barre de tache de windobe [ par OverDarck ] S'il quelqun pouvais me donner un code qui permet de masquer la barre de teche se serait cool pour m'aider a finir un prog !!!za511@aol.com Le haut de la position de la barre de tache [ par MEGATRIX ] Comment connaitre le haut de la position de la barre de tache ? Docker une feuille dans la taskbar, comme la barre Quicklaunch [ par Bouh ] Hello,Tout d'abord, je profite de ce premier post pour remercier tous ceux qui font ce site ou qui y participent, car il m'a beaucoup servi durant mon empêcher l'accès à la barre des tâches et à Task Manager sous NT 4 [ par noisy ] JE développe mon application sous Win NT 4J'aimerais emêcher l'accès à la barre des tâches ainsi qu' à Task Manager (je ne peux pas utiliser la source Prob: form depassant sur barre de tache... [ par wico2002 ] Question: je me fais un jeux et le form du plateau de jeux embarque par dessus la barre ds tache. mais moi je ne veux pas... comment faire pour quelle comment simuler la barre de tache windows ? [ par martinkk ] j'ai remplacé dans le fichier system.ini dans la section [boot], shell=explorer.exe par shell=monprog.exe (mon programme).le problème est que la barre Réduire un formulaire en VBA [ par daffy21 ] Sur un Prog Excel en macro, je voudrais pouvoir réduire l'application dans la barre de tache, mais comme un formulaire est affiché, la fonction ne fon Barre des tache de windows [ par Robinwood01 ] Comment fait ton pour savoir si la barre du menu demarré de windows est en haut ou en bas avec Visual Basic ?Car j'ai une fenetre que j'aimerais place Détecté si la barre de tache est caché ou visible [ par cosmic ] BonjoursJ'ai besoin de votre aide.Je voudrais savoir s'il éxiste un moyen de détecté si la barre de tache est visible ou caché.Et non pas un code qui fenetre en arrière plan comme la barre de tache ?? [ par PBDLpc ] bonjour, je voudrais faire une barre du style barre mac, mais je sais pas commetn faire que les fenetres de windows ne viennent pas dessus ni en deess


Nos sponsors


Sondage...

CalendriCode

Mars 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,702 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales