FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Question about CaptureWindow()
Posts: 365
Joined: Sat Oct 08, 2005 07:59 PM
Question about CaptureWindow()
Posted: Fri Jan 13, 2006 03: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

Posts: 142
Joined: Sun Oct 09, 2005 10:59 AM
Question about CaptureWindow()
Posted: Fri Jan 13, 2006 03:36 PM

oDlg:aControls is a array with all the controls

Frank

Posts: 365
Joined: Sat Oct 08, 2005 07:59 PM
Question about CaptureWindow()
Posted: Fri Jan 13, 2006 03: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

Posts: 219
Joined: Fri Nov 04, 2005 02:34 PM
Question about CaptureWindow()
Posted: Fri Jan 13, 2006 04: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.

-------------------------------------------------
Posts: 365
Joined: Sat Oct 08, 2005 07:59 PM
Question about CaptureWindow()
Posted: Fri Jan 13, 2006 04: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:
        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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Question about CaptureWindow()
Posted: Fri Jan 13, 2006 06: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:

   local hCtrl := GetWindow( hWnd, GW_CHILD ) 

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

Antonio Linares
www.fivetechsoft.com
Posts: 365
Joined: Sat Oct 08, 2005 07:59 PM
Question about CaptureWindow()
Posted: Fri Jan 13, 2006 07: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

Continue the discussion