Page 1 of 1

Question about CaptureWindow()

Posted: Fri Jan 13, 2006 3:06 pm
by Rafael Clemente
Let's asume I have an application than can be written -or not- with FWH. I know that with TWCapture() I can take some control of it (hiding, maximizing, even changing dimensions of the app. window...)

However: Is there any way than allows me to get a list of all the objets (controls) present in the window. Specifically, I would like to be able to retrieve a list such as {oBtn1, oBtn2, oGet1, oListBox1, oGet2...}?

The idea is to be able to read the coordinates of each control and, eventually, the contens of the Gets: oGet1:VarGet(), oGet1:nTop etc...

Anybody could provide a simple example of how to do it?

Thanks a lot in advance

Rafael

Posted: Fri Jan 13, 2006 3:36 pm
by Frank Demont
oDlg:aControls is a array with all the controls

Frank

Posted: Fri Jan 13, 2006 3:58 pm
by Rafael Clemente
Frank:

Thanks for your answer but I must be doing something wrong. Part of my code:

oWnd := TWCapture():New("MyMainWnd") // "MyMainWindow" is a FWH application whose App class is a TWindow()

oWnd:Say(20, 20, "Hello", CLR_YELLOW, CLR_RED, oFont, .T., .F.) // It paints "Hello", therefore, oWnd is properly captured

? LEN(oWnd:aControls) --->> Error BASE/1111 Argument error: LEN
Args:
[ 1] = U

Can you suggest something?
Thks
Rafael

Posted: Fri Jan 13, 2006 4:14 pm
by VeRCE
Rafael Clemente wrote:Frank:

Thanks for your answer but I must be doing something wrong. Part of my code:

oWnd := TWCapture():New("MyMainWnd") // "MyMainWindow" is a FWH application whose App class is a TWindow()

oWnd:Say(20, 20, "Hello", CLR_YELLOW, CLR_RED, oFont, .T., .F.) // It paints "Hello", therefore, oWnd is properly captured

? LEN(oWnd:aControls) --->> Error BASE/1111 Argument error: LEN
Args:
[ 1] = U

Can you suggest something?
Thks
Rafael


Then you need the function

oWndFromhWnd( hWnd )

With the handle you can get the object of the window.
Regards

Posted: Fri Jan 13, 2006 4:38 pm
by Rafael Clemente
Juan Carlos:

I'am affraid I do not fully understand four suggestion. In me example, oWnd is the objeto to the captured window and I have enough control over it as to be able to write something with the Say("Hello") instruction.

Anyhow, I tried your suggestion:

Code: Select all

        oWnd := TWCapture():New( cTitle )
        hWnd := oWnd:hWnd
        ? oWnd, hWnd                   // "Object" and a lon number. Seems Ok
        oW := oWndFromhWnd(hWnd)
        ? oW                   // Nil
        ? LEN(oW:aControls())       // Error, of course
Obviously, there is something wrong. Can you tell me how to do it?
Thanks
Rafael

Posted: Fri Jan 13, 2006 6:11 pm
by Antonio Linares
Rafael,

oWndFromhWnd(hWnd) will just work for created windows in FWH.

If the window is from another application, not created with FWH, once you have its hWnd you may get each control doing:

Code: Select all

   local hCtrl := GetWindow( hWnd, GW_CHILD ) 

   while hCtrl != 0 
      hCtrl = GetWindow( hCtrl, GW_HWNDNEXT ) 
      ...
   end 

Posted: Fri Jan 13, 2006 7:04 pm
by Rafael Clemente
Antonio:

Thanks a lot for your help. On the Spanish FWH forum, Paco Garcia has suggested the same approach. I've tried it and I have it almost working now. Just a small detail is missing. Please, refer to the thread in that forum.

Thanks

Rafael