If you are using TextOut you will want to get some details about the current font and character sizes first.You need to know the client area size so in your WM_SIZE do something like this...
ClientWidth=LOWORD(lParam);
ClientHeight=HIWORD(lParam);
These variables need to be statically allocated to your winproc.
now maybe in WM_CREATE you need to make a call to GetTextMetrics(HDC,TEXTMETRIC&).look it up at msdn.From that you can work out whether you have a fixed width or variable width font.You will also need to work out your text dimensions such as average char width and average char height.Once you have that part done you can now work out how many lines of text you can get into the client area and how many chars you can fit on a line. for more info look at msdn