View Full Version : Word Wrap
{F}allen
07-02-2002, 03:25 PM
As my get-to-know-win32-api program, i decided to write a notepad clone. Its going quite well, but one of the few things i just can't figure out is word wrap. It isn't documented as far as i can tell, and i don't know enough about EDIT controls to make the virtual linebreaks. can anyone walk me through it or point me somewhere? (i'm using VS.NET with msdn if anyone cares)
[i'll post the sln when its finished!]
ack! cloning notepad!? The horror!!! that's like jurassic park "oh we're just cloning them for the sake of science", but then they escape and wreak hav0k. Be careful fallen!! be careful!!
anyway.. there's a function... lemme look...
(I'm assuming you have access to the msdn documentation for further reading)
CDC::GetTextExtent
which tells how long and tall a given string is
So I'm thinking you call GetClientRect on your Edit Control to find out how wide the window is, then call GetTextExtent to see if the string needs to be wrapped. There must be a better way than trial and error to find exactly where to cut the line though...
lemme look some more.
Look at the docs for
GetTextExtentExPoint
I think that'll do what you want.
Bradmont
07-02-2002, 09:46 PM
Ick, MFC. I wish I could banish all knowledge of it from my mind. It's evil and disgusting and should be destroyed!
/me takes a few deep breaths
Ok, I'm feeling better now...
{F}allen
07-03-2002, 01:08 AM
err, note. since i think its pure evil and completely bloated, i'm not using MFC.
Strike
07-04-2002, 04:28 AM
<Yoda>Started down the path to darkness you have. Not using MFC help you will not.</Yoda>
;)
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.