Announcement

Collapse
No announcement yet.

Window handle from edit that owns the caret?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Window handle from edit that owns the caret?

    Hi,

    I want to retrieve the window handle of the edit control that owns the caret?

    -------------
    Patrice Terrier
    mailto[email protected][email protected]</A>
    Patrice Terrier
    www.zapsolution.com
    www.objreader.com
    Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

  • #2
    Patrice --
    as I understand, caret is located in window, which has keyboard focus.
    Means API GetFocus

    ------------------

    Comment


    • #3
      If your working in a MDI environment:
      Code:
      'Get the current active edit control window handle
      FUNCTION getEdit() AS DWORD
        FUNCTION = GetDlgItem(MdiGetActive(ghWndClient), %IDC_EDIT)
      END FUNCTION
      Cecil

      ------------------

      Comment


      • #4
        Semen

        I know the use of GetFocus.
        But in my case it could not be used.
        Because I perform an action based on mouse move and click detection that change the focus without removing the caret from the edit control.
        I would like a kind of function like the WindowFronPoint but for the caret.



        ------------------
        Patrice Terrier
        mailto[email protected][email protected]</A>
        Patrice Terrier
        www.zapsolution.com
        www.objreader.com
        Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

        Comment


        • #5
          Patrice --

          Does your program own the window that you are trying to identify? Or is it another program's window and caret?

          -- Eric


          ------------------
          Perfect Sync: Perfect Sync Development Tools
          Email: mailto:[email protected][email protected]</A>

          "Not my circus, not my monkeys."

          Comment


          • #6
            Eric,

            Indeed my problem comes from the fact that due to a postmessage from the DLL to an EXE (I can't use sendmessage) the events are not handled in the good sequence order between the DLL and the EXE.

            >> Is it another program's window and caret?
            No it isn't

            ------------------
            Patrice Terrier
            mailto[email protected][email protected]</A>
            Patrice Terrier
            www.zapsolution.com
            www.objreader.com
            Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

            Comment


            • #7
              >> Is it another program's window and caret?

              > No it isn't

              Then maybe using HideCaret/ShowCaret (with a NUL hWnd) would work. According to Win32.HLP the ShowCaret function's return value is "nonzero" if the call works, but I've found that sometimes that means that an API returns a handle, in this case presumably the handle of the window with the caret. Or maybe it's the handle of the caret itself, and you could use GetParent or GetWindow to get the parent window? I'm just guessing... Maybe the return value is just a meaningless "1". It's worth trying anyway, but if it works be sure test it on all versions of Windows.

              -- Eric

              ------------------
              Perfect Sync: Perfect Sync Development Tools
              Email: mailto:[email protected][email protected]</A>

              "Not my circus, not my monkeys."

              Comment


              • #8
                I think I was over-complicating things... If it's your program's window, why not use GetCaretPos and ChildWindowFromPoint?

                -- Eric

                ------------------
                Perfect Sync: Perfect Sync Development Tools
                Email: mailto:[email protected][email protected]</A>



                [This message has been edited by Eric Pearson (edited June 08, 2000).]
                "Not my circus, not my monkeys."

                Comment


                • #9
                  Thanks to all of you.

                  I have found a solution to synchronize my messages in the good order and that solves my problem, because now I can rely again on the GetFocus API.

                  Eric --
                  Your are right, GetCaretPos and ChildWindowFromPoint should work as well. Thank you.


                  ------------------
                  Patrice Terrier
                  mailto[email protected][email protected]</A>
                  Patrice Terrier
                  www.zapsolution.com
                  www.objreader.com
                  Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

                  Comment


                  • #10
                    Eric --
                    Unlike Patrice, it's not clear for me your idea about GetCaretPos and ChildWindowFromPoint.
                    GetCaretPos returns client coordinates of edit box.
                    ChildWindowFromPoint requires client's coordinates of parent window for this edit box.

                    ------------------

                    Comment


                    • #11
                      Semen

                      You can use ClientToScreen or ScreenToClient in order to swith between coordinates.



                      ------------------
                      Patrice Terrier
                      mailto[email protected][email protected]</A>
                      Patrice Terrier
                      www.zapsolution.com
                      www.objreader.com
                      Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

                      Comment


                      • #12
                        Patrice --
                        Try to do following
                        1) Press Alt-O. You will see (1, 1)
                        2) Tab (to second edit box). Alt-O. Also (1, 1)

                        How can you recognize edit box 1 or 2, when button has a focus ?!
                        Code:
                           #Compile Exe
                           #Dim All
                           #Register None
                           #Include "win32api.inc"
                        
                           CallBack Function OkProc
                              Dim pt As PointApi
                              GetCaretPos pt
                              MsgBox Str$(pt.x) + Str$(pt.y)
                           End Function
                        
                           Function PbMain
                              Local hDlg As Long
                              Dialog New %HWND_DESKTOP, "", , , 400, 200, %WS_CAPTION Or %WS_SYSMENU To hDlg
                              Control Add TextBox, hDlg, 101, "", 5, 10, 300, 80
                              Control Add TextBox, hDlg, 102, "", 5, 100, 300, 80
                              Control Add Button,  hDlg, 103, "&Open", 320, 10, 70, 15 Call OkProc
                              Dialog Show Modal hDlg
                           End Function
                        ------------------

                        Comment


                        • #13
                          Semen --

                          >>How can you recognize edit box 1 or 2, when button has a focus ?!

                          Of course you can't because the caret is hidden as soon as the button gets the focus.

                          But this was not my case.
                          In my WinLIFT "Skin Engine" I can have hot spots, which the user can click on without removing the caret from an edit control.
                          Hot spots looks like buttons but they are not, for example the icon found at the top left corner on most program caption could be considered as a hot spot that won't remove the focus from an edit control, even if it fires a popup menu.



                          ------------------
                          Patrice Terrier
                          mailto[email protected][email protected]</A>
                          Patrice Terrier
                          www.zapsolution.com
                          www.objreader.com
                          Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

                          Comment

                          Working...
                          X