Re: GetWindowText - Windows API

From: Gregory Adam (GregoryAdam_at_PleaseReplyViaNewsGroup.com)
Date: 04/17/04


Date: Sat, 17 Apr 2004 12:20:59 +0200

hi Sarah,

GetWindowText has a third parameter, ie the length of the buffer where it
can put the text

 declare integer GetWindowText in User32.dll ;
      integer hnwd, string @lpstring, integer buflen

 declare integer FindWindow in win32api ;
    string @lpClassName, string @WindowName

 local hwnd
 hwnd = FindWindow( null, _screen.caption )
 local buf, nchars
 buf = space(1024)

 nchars = GetWindowText(hwnd, @buf, len(buf))

 do case
 case empty(nchars)
  ?? 'error'

 otherwise
  buf = left(buf, nchars)
  ?buf
 endcase

Gregory
__________________________________________________
"Sarah" <anonymous@discussions.microsoft.com> wrote in message
news:45E16284-2487-4D15-B82A-4AF6F996BCB9@microsoft.com...
> Hi All,
>
> I want to use the GetWindowText, Windows API in vfp. The following code is
giving error
>
> DECLARE INTEGER GetWindowText IN win32api;
> HWND iwinhdl,;
> STRING cwindow_title
> GetWindowText(mActiveWndHdl,mGetWinTxt)
>
> The following is the error message
> Too many arguments.
> Line of code with error: GetWindowText(mActiveWndHdl,mGetWinTxt)
> Message1: ISWINDEX
>
> Can't make out why the error is flaged!
>
>
>



Relevant Pages

  • Re: Help needed with macros: Brain turning to jelly
    ... '(('string buf) ) ... QUOTE their argument, usually. ... :pointer args ...
    (comp.lang.lisp)
  • Re: newbie question
    ... avoid memory allocations: the data can be swapped in-place. ... // modifies the contentes of 0-terminated 'buf' as described above ... string swapHalves ...
    (comp.lang.cpp)
  • Re: difference between casting and atol,atoi functions
    ... The first is ill-formed since buf may not be suitably ... character code 255 need not represent a digit ... or a text string ... Note that the size and representation of a signed long can ...
    (alt.comp.lang.learn.c-cpp)
  • Re: difference between casting and atol,atoi functions
    ... The first is ill-formed since buf may not be suitably ... character code 255 need not represent a digit ... or a text string ... Note that the size and representation of a signed long can ...
    (comp.lang.c)
  • Length of window text
    ... GetWindowTextLength is safe to use in allocating a buffer that will be at least as big as necessary. ... But in order to know the real length of the string, I have to call GetWindowText instead. ... It seems maybe I've wasted a lot of effort on buffer allocations and memory handles if GetWindowText still has to be used in order to get the real length. ... to depend on undocumented internal behaviour of the edit control. ...
    (microsoft.public.win32.programmer.ui)