Are we done yet :)

Started by James Fuller, July 08, 2016, 03:50:08 PM

Previous topic - Next topic

James Fuller

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

José Roca

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