FindWindow Help

FindWindow Help

Postby lailton.webmaster » Sun Apr 04, 2010 5: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.
Last edited by lailton.webmaster on Thu Feb 17, 2011 3:50 pm, edited 1 time in total.
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: FindWindow Help

Postby Antonio Linares » Sun Apr 04, 2010 9:05 am

Lailton,

Try it this way:
Code: Select all  Expand view

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

Re: FindWindow Help

Postby lailton.webmaster » Sun Apr 04, 2010 3:46 pm

Nice Antonio, more no work in PRG.
How make this in C language ?

im trying:

Code: Select all  Expand view
#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.
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: FindWindow Help

Postby Antonio Linares » Mon Apr 05, 2010 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FindWindow Help

Postby Enrico Maria Giordano » 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: Select all  Expand view
sizeof( cBuffer )


:-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FindWindow Help

Postby nageswaragunupudi » Mon Apr 05, 2010 1:59 pm

sizeof is operator, not a function.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FindWindow Help

Postby Enrico Maria Giordano » Mon Apr 05, 2010 2: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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FindWindow Help

Postby lailton.webmaster » Mon Apr 05, 2010 5:28 pm

Well. i think that it´s OK

Code: Select all  Expand view
#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
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 90 guests