Question about CaptureWindow()

Question about CaptureWindow()

Postby Rafael Clemente » Fri Jan 13, 2006 3:06 pm

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
User avatar
Rafael Clemente
 
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Postby Frank Demont » Fri Jan 13, 2006 3:36 pm

oDlg:aControls is a array with all the controls

Frank
Frank Demont
 
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Postby Rafael Clemente » Fri Jan 13, 2006 3:58 pm

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
Rafael Clemente
 
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Postby VeRCE » Fri Jan 13, 2006 4:14 pm

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

Postby Rafael Clemente » Fri Jan 13, 2006 4:38 pm

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  Expand view  RUN
        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
Rafael Clemente
 
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Postby Antonio Linares » Fri Jan 13, 2006 6:11 pm

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  Expand view  RUN
   local hCtrl := GetWindow( hWnd, GW_CHILD )

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Rafael Clemente » Fri Jan 13, 2006 7:04 pm

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
User avatar
Rafael Clemente
 
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 72 guests

cron