Problema con Captura de ventana

Post Reply
User avatar
Rafael Clemente
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Problema con Captura de ventana

Post by Rafael Clemente »

Estoy intentando leer el contenido de un Get de una ventana desde otra ventana independiente. Efectivamente, leo el valor inicial del Get pero aunque escriba en él algo diferente, siempre leo el valor inicial.

Alguien podría mirarse estos dos prgs y decirme qué estoy haciendo mal? (ambos se compilan con Buildh.bat)

El programa que captura:

Code: Select all

//----------------------------------------------------------------------------//
// Capt.prg - Prueba de captura de otra ventana
//----------------------------------------------------------------------------//
#include "FiveWin.ch"
#define GW_CHILD      5
#define GW_HWNDNEXT   2

FUNCTION Main()
LOCAL oWnd, hWnd, hCtrl, cClassName, cTitle
cTitle := PADR("TEST", 200)
IF MsgGet( "Entre titulo de una ventana abierta", "Titulo:", @cTitle) 
   hWnd := FindWindow( 0, ALLTRIM(cTitle))
   IF hWnd <= 0
      MsgInfo("No puedo capturar esa ventana")
   ELSE
      hCtrl := GetWindow( hWnd, GW_CHILD )
      WHILE hCtrl != 0
         cClassName := Upper(GetClassName(hCtrl))
         IF cClassName = "EDIT"
            ? cClassName+"  "+GetWindowText(hCtrl)
         ENDIF
         hCtrl = GetWindow( hCtrl, GW_HWNDNEXT )
      END
   ENDIF
ENDIF
RETURN NIL
y el programa cuyos gets quiero capturar:

Code: Select all

//  Test.prg
#include 'FIVEWIN.CH'
FUNCTION Main()
   LOCAL  oWnd, oGet1, oGet2, cGet1, cGet2
   DEFINE WINDOW oWnd FROM 0,0 TO 12,35 TITLE 'Test'
   cGet1 := "Hola        "
   cGet2 := "Bye         "
   @ 10,10  BUTTON "Button 01"  SIZE 100,20 PIXEL OF oWnd ACTION MsgInfo("Button 01")
   @ 40,10  GET oGet1 VAR cGet1 SIZE 100,20 PIXEL OF oWnd
   @ 70,10  GET oGet2 VAR cGet2 SIZE 100,20 PIXEL OF oWnd
   ACTIVATE WINDOW oWnd
RETURN NIL
Gracias,

Rafael
User avatar
Rafael Clemente
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Problem with Capture()

Post by Rafael Clemente »

Ooops; I just posted my message in Spanish. Sorry. Here is the translation:

I am trying to read the contens of a Get in a Window from another, independent window. I can capture and read the INITAL value of the get, but when I overwrite it with a different text, I keek reading the original value.

Could anybody take a look at these two prgs and tell me what am I doing wrong? (Both can be compiled with buildh.bat)

The capture program:

Code: Select all

//----------------------------------------------------------------------------// 
// Capt.prg - Capture test 
//----------------------------------------------------------------------------// 
#include "FiveWin.ch" 
#define GW_CHILD      5 
#define GW_HWNDNEXT   2 

FUNCTION Main() 
LOCAL oWnd, hWnd, hCtrl, cClassName, cTitle 
cTitle := PADR("TEST", 200) 
IF MsgGet( "Input the title of an open window", "Title:", @cTitle) 
   hWnd := FindWindow( 0, ALLTRIM(cTitle)) 
   IF hWnd <= 0 
      MsgInfo("Can not capture this window") 
   ELSE 
      hCtrl := GetWindow( hWnd, GW_CHILD ) 
      WHILE hCtrl != 0 
         cClassName := Upper(GetClassName(hCtrl)) 
         IF cClassName = "EDIT" 
            ? cClassName+"  "+GetWindowText(hCtrl) 
         ENDIF 
         hCtrl = GetWindow( hCtrl, GW_HWNDNEXT ) 
      END 
   ENDIF 
ENDIF 
RETURN NIL 

And the window to be captured:

Code: Select all

//  Test.prg 
#include 'FIVEWIN.CH' 
FUNCTION Main() 
   LOCAL  oWnd, oGet1, oGet2, cGet1, cGet2 
   DEFINE WINDOW oWnd FROM 0,0 TO 12,35 TITLE 'Test' 
   cGet1 := "Hello        " 
   cGet2 := "Bye         " 
   @ 10,10  BUTTON "Button 01"  SIZE 100,20 PIXEL OF oWnd ACTION MsgInfo("Button 01") 
   @ 40,10  GET oGet1 VAR cGet1 SIZE 100,20 PIXEL OF oWnd 
   @ 70,10  GET oGet2 VAR cGet2 SIZE 100,20 PIXEL OF oWnd 
   ACTIVATE WINDOW oWnd 
RETURN NIL 

Thanks,
Rafael
Post Reply