
Si alguien sabe.
| ||||
![]() Saber si una ventana aparece en la barra de tareas ![]() Si alguien sabe.
__________________ Por favor, antes de preguntar, revisa la Guía para realizar preguntas. |
| |||
Cita: Create un proyecto nuevo y en el Form1 mete un MsFlexGrid llamado MSFlexGrid1 y este código:
Iniciado por David el Grande Saber si una ventana aparece en la barra de tareas ![]() Si alguien sabe.
Código:
salu2 Option Explicit Private Declare Function GetTopWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wFlag As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Private Const GW_HWNDFIRST = 0 Private Const GW_HWNDNEXT = 2 Private Const GWL_STYLE = (-16) Private Const GWL_HWNDPARENT = (-8) Private Const WS_OVERLAPPED = &H0& Private Const WS_BORDER = &H800000 Private Const WS_DLGFRAME = &H400000 Private Const WS_CAPTION = WS_BORDER Or WS_DLGFRAME Private Const WS_SYSMENU = &H80000 Private Const WS_THICKFRAME = &H40000 Private Const WS_MINIMIZEBOX = &H20000 Private Const WS_MAXIMIZEBOX = &H10000 Private Const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX) ' Return information about this window. Private Sub GetWindowInfo(ByVal app_hwnd As Long, ByRef app_parent As Long, ByRef app_owner As Long, ByRef app_visible As Boolean, ByRef app_style As Long, ByRef app_text As String, ByRef app_class As String) Const MAX_LENGTH = 1024 Dim buf As String * MAX_LENGTH Dim length As Long app_parent = GetParent(app_hwnd) app_owner = GetWindowLong(app_hwnd, GWL_HWNDPARENT) app_visible = IsWindowVisible(app_hwnd) app_style = GetWindowLong(app_hwnd, GWL_STYLE) length = GetWindowText(app_hwnd, buf, MAX_LENGTH) app_text = Left$(buf, length) length = GetClassName(app_hwnd, buf, MAX_LENGTH) app_class = Left$(buf, length) End Sub Private Sub Form_Load() Dim app_hwnd As Long Dim app_parent As Long Dim app_owner As Long Dim app_visible As Boolean Dim app_style As Long Dim app_text As String Dim app_class As String Dim wid As Single Dim col_wid() As Single Dim r As Integer Dim c As Integer MSFlexGrid1.FixedRows = 1 MSFlexGrid1.FixedCols = 0 MSFlexGrid1.Rows = 1 MSFlexGrid1.Cols = 3 MSFlexGrid1.TextMatrix(0, 0) = "hWnd" MSFlexGrid1.TextMatrix(0, 1) = "Text" MSFlexGrid1.TextMatrix(0, 2) = "Class" GetWindowInfo app_hwnd, app_parent, app_owner, _ app_visible, app_style, app_text, app_class app_hwnd = GetTopWindow(0) r = 1 Do While app_hwnd <> 0 ' Get information about this window. GetWindowInfo app_hwnd, app_parent, app_owner, _ app_visible, app_style, app_text, app_class ' See if this window is interesting. If app_visible And _ app_parent = 0 And _ app_owner = 0 And _ Len(app_text) > 0 And _ Left$(app_text, 8) <> "VBBubble" And _ (Left$(app_class, 7) <> "Progman" Or _ (app_style And WS_OVERLAPPEDWINDOW) <> 0) _ Then MSFlexGrid1.Rows = r + 1 MSFlexGrid1.TextMatrix(r, 0) = app_hwnd MSFlexGrid1.TextMatrix(r, 1) = app_text MSFlexGrid1.TextMatrix(r, 2) = app_class r = r + 1 End If app_hwnd = GetNextWindow(app_hwnd, GW_HWNDNEXT) Loop ' Size the columns. ReDim col_wid(0 To MSFlexGrid1.Cols - 1) For r = 0 To MSFlexGrid1.Rows - 1 For c = 0 To MSFlexGrid1.Cols - 1 wid = TextWidth(MSFlexGrid1.TextMatrix(r, c)) + 240 If col_wid(c) < wid Then col_wid(c) = wid Next c Next r For c = 0 To MSFlexGrid1.Cols - 1 MSFlexGrid1.ColWidth(c) = col_wid(c) Next c End Sub Private Sub Form_Resize() MSFlexGrid1.Move 0, 0, ScaleWidth, ScaleHeight End Sub
__________________ Lo importante no es saber, sino tener el teléfono del que sabe :risa: |