PlanetSquires Forums

Support Forums => General Board => Topic started by: James Fuller on July 08, 2016, 03:50:08 PM

Title: Are we done yet :)
Post by: James Fuller on July 08, 2016, 03:50:08 PM
Jose,
  Are you still experimenting with CBStr or am I rushing the gun wanting an AfxWin.inc update :)?
As in AfxGetWindowText OVERLOAD (BYVAL hwnd AS HWND) AS AFX_BSTR

James
Title: Re: Are we done yet :)
Post by: José Roca on July 08, 2016, 04:26:36 PM
I'm always experimenting.

What about this:


' ========================================================================================
FUNCTION AfxGetWindowTextW (BYVAL hwnd AS HWND) AS CBSTR
   DIM nLen AS LONG = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
   DIM cbText AS CBSTR = SPACE(nLen + 1)
   nLen = SendMessageW(hwnd, WM_GETTEXT, nLen + 1, cast(LPARAM, *cbText))
   FUNCTION = LEFT(**cbText, nLen)
END FUNCTION
' ========================================================================================



MessageBoxW 0, AfxGetWindowTextW(hwndMain), "", MB_OK


With your current headers, use:


MessageBoxW 0, *AfxGetWindowTextW(hwndMain), "", MB_OK