
04-09-2012, 01:15 PM
|
 |
Senior Contributor
|
|
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,177
|
|
[VB6] - detecting code window
|
using api functions in a timer i can see what windows are activated, getting their caption. but i'm having problem to complete the code:
in a timer:
Code:
If IsCodeWindowActivated = True Then tmrIDEScrollClick.Enabled = False
in a module:
Code:
Public Function IsCodeWindowActivated() As Boolean
Dim lngActivatedWindow As Long
Dim lngtest As Long
lngActivatedWindow = GetActiveWindow
EnumChildWindows lngActivatedWindow, AddressOf EnumChildProc, 0
End Function
Private Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
'On Error Resume Next
Dim slength As Long, wintext As String ' title bar text length and buffer
Dim retval As Long ' return value
Dim buffer As String
Static winnum As Integer ' counter keeps track of how many windows have been enumerated
winnum = winnum + 1 ' one more window enumerated....
slength = GetWindowTextLength(hwnd) + 1 ' get length of title bar text
buffer = Space(slength) ' make room in the buffer
retval = GetWindowText(hwnd, buffer, slength) ' get title bar text
If Left(buffer, slength - 1) = "Cambalinho" Then
IsCodeWindowActivated = True
Else
IsCodeWindowActivated = False
End If
EnumChildProc = 1 ' return value of 1 means continue enumeration
End Function
(forget the Cambalinho string)
my objective is testing if the code window is activated or geted focus. can anyone advice me?
|
|