Question about CaptureWindow()

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

Question about CaptureWindow()

Post 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
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Post by Frank Demont »

oDlg:aControls is a array with all the controls

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

Post 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
User avatar
VeRCE
Posts: 219
Joined: Fri Nov 04, 2005 2:34 pm
Location: Mexico D.F.
Contact:

Post 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
Juan Carlos Salinas Ojeda
México. D.F.
-------------------------------------------------
User avatar
Rafael Clemente
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Rafael Clemente
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Post 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
Post Reply