Announcement

Collapse
No announcement yet.

Problem bei GetWindowLong

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

  • Problem bei GetWindowLong

    Hallo. <br>
    Ich versuche eine Liste aller Fenster-Captions zu erstellen. <br>
    Dazu verwende ich die Fkt. EnumWindows. <br>
    In der Callback-Fkt. versuche ich mit der folgenden Zeile die Message-Prozedur des Fensters zu bekommen, um ihm die Meldung WM_GETTEXT zu senden. <br> <br>
    ...GetWindowLong(Handle, GWL_WNDPROC); <br>
    Beim Compilieren meldet der Compiler den Fehler : <br>
    "Inkompatible Typen: 'Integer' und 'Pointer'". Dabei steht der Cursor hinter GWL_WNDPROC. <br> <br>
    Was mache ich falsch? <br> <br>
    Gibt es vielleicht eine andere Möglichkeit, die Captions der Fenster zu bekommen? <br>
    Ein normales Gettext fkt. nicht mit Fenstern anderer Application. <br> <br>
    Danke, <br>
    kh

  • #2
    Funktioniert der Zeilenumbruch nicht

    Comment


    • #3
      Hi

      probier mal SendMessage(Wnd, wm_GetText, Integer(PChar('Hallo')), 5);

      oder noch besser

      GetWindowText(Wnd, .., ..);

      Gruß Hage

      Comment


      • #4
        SendMessage werde ich mal probieren.<br>
        GetWindowText funktioniert nicht mit anderen Applicationen.<br>
        k

        Comment


        • #5
          Hi

          Warum soll getWindowText() nicht funktionieren ??
          Bzw. wenn getWindowText() nicht funktioniert, warum soll dann
          SendMessage() eine Wirkung erzielen ??

          Gruß Hage

          Comment


          • #6
            Hallo Hagen,

            es gibt in der Tat einen Unterschied, der von Microsoft in der Platform SDK-Hilfe mit dem Satz "<i>However, GetWindowText cannot retrieve the text of a control in another application.</i>" beschrieben wird.

            Zur Lösung dieses Problems schlägt Microsoft in der Hilfe folgendes vor:

            <i>If the target window is owned by the current process, GetWindowText causes a WM_GETTEXT message to be sent to the specified window or control. If the target window is owned by another process and has a caption, GetWindowText retrieves the window caption text. If the window does not have a caption, the return value is a null string. This behavior is by design. It allows applications to call GetWindowText without hanging if the process that owns the target window is hung.

            To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.
            </i&gt

            Comment


            • #7
              hi

              Ok, SendMessage() funktioniert aber, richtig ?

              Andere Möglichkeit wäre SendMessage() zu simulieren indem man
              CallWindowProc() mit der entsprechenden Fensterfunktion des Zielfensteres nutzt. Auf jeden Fall kann man mit GetWindowLong() diese fensterfunktion ausfindig machen.

              Man muß aber einen Typcast vornehmen:

              <pre>

              Wndproc: Pointer// etc.

              WndProc := Pointer(getWindowLong(handle, gwl_Wndproc));

              </pre>

              Zudem könnte man vor getWindowText() oder SendMessage() eine
              SendMessageTimeout(.., wm_Null,..) senden, und so überprüfen ob die Zielanwendung hängt :-)

              Gruß Hage

              Comment

              Working...
              X