Home All Groups Group Topic Archive Search About

GetCaretPos in a MDI Window

Author
2 Mar 2007 7:24 AM
omicronlab
Hello,
I know how to get caret position in SDI environment using vb6.
But it is always returning (0,0) position in a mdi interface (e.g.
IE7, Firefox), although the caret is not there. How can I solve this
problem?

Thanks in advance for your kind help.

Here is the code:

------------------------------------------------------------------------
hwndFG = GetForegroundWindow()



    If hwndFG <> 0 Then
        TID = GetWindowThreadProcessId(hwndFG, ByVal 0&)
        If TID <> App.ThreadID Then
            If AttachThreadInput(App.ThreadID, TID, 1) <> 0 Then
                hwndFoc = GetFocus()
                If hwndFoc <> 0 Then
                    If GetCaretPos(Position) <> 0 Then
                        GetCaretPos Position
                        ClientToScreen hwndFoc, Position
                        FindCaretPosWindow = hwndFoc
                    End If
                End If
                AttachThreadInput App.ThreadID, TID, 0
            End If
        End If
    End If
-----------------------------------------------------------------------

Author
3 Mar 2007 5:48 PM
omicronlab
On Mar 2, 1:24 pm, omicron***@gmail.com wrote:
Show quoteHide quote
> Hello,
> I know how to get caret position in SDI environment using vb6.
> But it is always returning (0,0) position in a mdi interface (e.g.
> IE7, Firefox), although the caret is not there. How can I solve this
> problem?
>
> Thanks in advance for your kind help.
>
> Here is the code:
>
> ------------------------------------------------------------------------
> hwndFG = GetForegroundWindow()
>
>     If hwndFG <> 0 Then
>         TID = GetWindowThreadProcessId(hwndFG, ByVal 0&)
>         If TID <> App.ThreadID Then
>             If AttachThreadInput(App.ThreadID, TID, 1) <> 0 Then
>                 hwndFoc = GetFocus()
>                 If hwndFoc <> 0 Then
>                     If GetCaretPos(Position) <> 0 Then
>                         GetCaretPos Position
>                         ClientToScreen hwndFoc, Position
>                         FindCaretPosWindow = hwndFoc
>                     End If
>                 End If
>                 AttachThreadInput App.ThreadID, TID, 0
>             End If
>         End If
>     End If
> -----------------------------------------------------------------------

Anyone?
Author
4 Mar 2007 6:18 AM
J French
On 1 Mar 2007 23:24:24 -0800, omicron***@gmail.com wrote:

Show quoteHide quote
>Hello,
>I know how to get caret position in SDI environment using vb6.
>But it is always returning (0,0) position in a mdi interface (e.g.
>IE7, Firefox), although the caret is not there. How can I solve this
>problem?
>
>Thanks in advance for your kind help.
>
>Here is the code:
>
>------------------------------------------------------------------------
>hwndFG = GetForegroundWindow()
>
>
>
>    If hwndFG <> 0 Then
>        TID = GetWindowThreadProcessId(hwndFG, ByVal 0&)
>        If TID <> App.ThreadID Then
>            If AttachThreadInput(App.ThreadID, TID, 1) <> 0 Then
>                hwndFoc = GetFocus()
>                If hwndFoc <> 0 Then
>                    If GetCaretPos(Position) <> 0 Then
>                        GetCaretPos Position
>                        ClientToScreen hwndFoc, Position
>                        FindCaretPosWindow = hwndFoc
>                    End If
>                End If
>                AttachThreadInput App.ThreadID, TID, 0
>            End If
>        End If
>    End If
>-----------------------------------------------------------------------

Well that code will not even try to get the Caret position if that App
is the Foreground Application.