getting tittle bar text of any window

  • Thread starter Thread starter shalender verma
  • Start date Start date
S

shalender verma

Hello All
I am using VB 6. I am trying to get the text in the tittle
bar of the window i click by using GetWindowText API
function but its not working. Here is the code i am using:-

Private Declare Function GetWindowText Lib "user32"
Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal
lpszString As String, ByVal cch As Long) As Long
Private Declare Function WindowFromPoint Lib "user32"
(ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function SetCapture Lib "user32" (ByVal
hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As
Long
Private Declare Function ClientToScreen Lib "user32"
(ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Dim blnChoose As Boolean


Private Sub Command1_Click()
blnChoose = True
intRetVal = SetCapture(hwnd)
End Sub

Private Sub Form_Load()
blnChoose = False
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As
Integer, X As Single, Y As Single)
Dim window As Long
Dim buffer As String * 1024
Dim ptPoint As POINTAPI
If blnChoose Then
ptPoint.X = X
ptPoint.Y = Y
retval = ClientToScreen(hwnd, ptPoint)
window = WindowFromPoint(ptPoint.X, ptPoint.Y)
lngRetVal = GetWindowText(window, buffer, 1024)
Text1.Text = buffer
End If
End Sub

Please tell me if there is any problem in this code so
that my prob. can be solved

thanks
 
Hi Shalender,

This is a VB.net newgroup as you could seen in your previous answers you
have got it is a very different language from VB6.

There are very much VB6 language newsgroups also,

They called often public.vb with a lot of special subjects.

You better place your questions in those newsgroups, because the first time
people will answer you here because most are very polite, but by keeping
doing it, some of us become a little bit sad.

Cor
 
Back
Top