FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FindWindow Help
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
FindWindow Help
Posted: Sun Apr 04, 2010 05:01 AM

Hi,

How i return text selected in a window ?

hWnd:= FindWindow(,"Mozilla FireFox")
SendMessage(hWnd, EM_GETSELTEXT, 0, 0)

i wanna return "_text this string "

Someone can help me ?

Thanks so much.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FindWindow Help
Posted: Sun Apr 04, 2010 09:05 AM
Lailton,

Try it this way:
Code (fw): Select all Collapse
local cBuffer := Space( 1000 )

hWnd := FindWindow(,"Mozilla FireFox")
SendMessage( hWnd, EM_GETSELTEXT, 0, @cBuffer )

But probably it will not work from PRG code so you have to do the same from C language
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: FindWindow Help
Posted: Sun Apr 04, 2010 03:46 PM
Nice Antonio, more no work in PRG.
How make this in C language ?

im trying:

Code (fw): Select all Collapse
#include "Fivewin.ch"

Function main()

 public oWnd
 define window ownd
 activate window ownd On Right Click Get()

return nil

Function Get()
local hWnd, cRet
      hWnd:= FindWindow(,"Mozilla FireFox")

      cRet = GetSelectedStringByHandle( hWnd )

      msginfo(cRet,"Retorno")

return   

#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"

#define GETSELTEXT              1086

HB_FUNC( GETSELECTEDSTRINGBYHANDLE )
{
   HWND hWndCtrl = hb_parnl( 1 );
   CHAR cBuffer[1000];
   SendMessage( hWndCtrl, GETSELTEXT, 0, &cBuffer );
   hb_retc( cBuffer );
}
#pragma ENDDUMP



Show me erro:

Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
obj\DEMO.c:
Error E2349 DEMO.PRG 29: Nonportable pointer conversion in function HB_FUN_GETSELECTEDSTRINGBYHANDLE
Error E2342 DEMO.PRG 31: Type mismatch in parameter 'lParam' (wanted 'long', got 'signed char ( *)[1000]') in function HB_FUN_GETSELECTEDSTRINGBYHANDLE
*** 2 errors in Compile ***
Done.
Deleting: "obj\DEMO.c"
Done.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FindWindow Help
Posted: Mon Apr 05, 2010 02:51 AM

Lailton,

Don't use & here:

SendMessage( hWndCtrl, GETSELTEXT, 0, cBuffer );

The name of an array is its address :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FindWindow Help
Posted: Mon Apr 05, 2010 12:32 PM
Antonio Linares wrote:The name of an array is its address :-)


Not always. As an example, it is not true in the expression

Code (fw): Select all Collapse
sizeof( cBuffer )


:-)

EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FindWindow Help
Posted: Mon Apr 05, 2010 01:59 PM

sizeof is operator, not a function.

Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FindWindow Help
Posted: Mon Apr 05, 2010 02:53 PM
nageswaragunupudi wrote:sizeof is operator, not a function.


That's irrelevant. Still there are cases in which an array name does not decay to the address of its first item. Another example is the unary & (address of) operator. The third case is when an array is initialized using a string literal. Please search Internet for this well known behavior that is covered by the standard.

EMG
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: FindWindow Help
Posted: Mon Apr 05, 2010 05:28 PM
Well. i think that it´s OK

Code (fw): Select all Collapse
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
HB_FUNC( GSELECTED )
{
   HWND hWndCtrl = (HWND) hb_parnl( 1 );
   CHAR cBuffer[1000];
   SendMessage( hWndCtrl, 1086, 0, (LONG) cBuffer );
   hb_retc( cBuffer );
}
#pragma ENDDUMP


but no work with Mozilla, i think that it´s only for GET´s of a windows.

Thanks

Continue the discussion