how to word wrap in CListCtrl?

Hi,

I have an application that sets up a grid using CListCtrl.
Now I am trying to fit a line of characters into one of the cells.
Because the length of the line may vary, I need to have word wrap for the
cell.
However, I cannot find references anywhere to do this.
Any ideas or advices are absolutely appreciated.

Andy


0
ang (2)
7/9/2003 2:02:47 PM
vc.mfc 33608 articles. 0 followers. Follow

8 Replies
2434 Views

Similar Articles

[PageSpeed] 17

I don't think you can do it without handling NM_CUSTOMDRAW and draw item
text manually. In report mode all items should have the same height, so you
have to decide beforehand how many lines of text per listview item you want
and choose the appropriate item height. Setting item height is a bit
tricky... One way to do it is to create empty imagelist of desired height
and select it into your list control.

Yan


"A. Ng" <ang@peerdirect.com> wrote in message
news:e3HvHLiRDHA.3192@tk2msftngp13.phx.gbl...
> Hi,
>
> I have an application that sets up a grid using CListCtrl.
> Now I am trying to fit a line of characters into one of the cells.
> Because the length of the line may vary, I need to have word wrap for the
> cell.
> However, I cannot find references anywhere to do this.
> Any ideas or advices are absolutely appreciated.
>
> Andy
>
>


0
Yan
7/9/2003 6:23:08 PM
Yan,

Thanks for the suggestion.   I checked MSDN on NM_CUSTOMDRAW but it did not
provide any details
at all.   Wonder if any one have some pseudo/sample code for me to look at?
BTW, I am kind of new to MFC, so I really appreciate the help here.

Andy

"Yan K. Avlasov" <_yan_avlasov_@_azimuth.net_> wrote in message
news:%23hcTnckRDHA.2228@tk2msftngp13.phx.gbl...
> I don't think you can do it without handling NM_CUSTOMDRAW and draw item
> text manually. In report mode all items should have the same height, so
you
> have to decide beforehand how many lines of text per listview item you
want
> and choose the appropriate item height. Setting item height is a bit
> tricky... One way to do it is to create empty imagelist of desired height
> and select it into your list control.
>
> Yan
>
>
> "A. Ng" <ang@peerdirect.com> wrote in message
> news:e3HvHLiRDHA.3192@tk2msftngp13.phx.gbl...
> > Hi,
> >
> > I have an application that sets up a grid using CListCtrl.
> > Now I am trying to fit a line of characters into one of the cells.
> > Because the length of the line may vary, I need to have word wrap for
the
> > cell.
> > However, I cannot find references anywhere to do this.
> > Any ideas or advices are absolutely appreciated.
> >
> > Andy
> >
> >
>
>


0
ang (2)
7/9/2003 8:45:38 PM
See if the following link helps you

        http://www.codeproject.com/listctrl/lvcustomdraw.asp

--
Cheers
Check Abdoul [ VC++ MVP ]
-----------------------------------

"A. Ng" <ang@peerdirect.com> wrote in message
news:e3HvHLiRDHA.3192@tk2msftngp13.phx.gbl...
> Hi,
>
> I have an application that sets up a grid using CListCtrl.
> Now I am trying to fit a line of characters into one of the cells.
> Because the length of the line may vary, I need to have word wrap for the
> cell.
> However, I cannot find references anywhere to do this.
> Any ideas or advices are absolutely appreciated.
>
> Andy
>
>


0
CheckAbdoul
7/9/2003 9:19:48 PM
Handling NM_CUSTOMDRAW in your case will be quite tedious... It is better
that you derive your own class from CListCtrl. In your class handle
NM_CUSTOMDRAW message (you can specify the handler in the messages section
of class properties (assuming you go with the VC++ .NET). This is how your
handler may look like (this is just to get you going, it will not handle
drawing images, different item states and control focus):


void CMyListCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
{
    LPNMLVCUSTOMDRAW pNMCD = reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR);
    *pResult = 0;
    switch(pNMCD->nmcd.dwDrawStage)
    {
    case CDDS_PREPAINT :
        *pResult = CDRF_NOTIFYITEMDRAW;
        break;

    case CDDS_ITEMPREPAINT:
        *pResult = CDRF_NOTIFYSUBITEMDRAW;
        break;

    case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
        *pResult = CDRF_SKIPDEFAULT;
        {
            CRect rc;
            CDC* pDC = CDC::FromHandle( pNMCD->nmcd.hdc );
            CString itemText = GetItemText( pNMCD->nmcd.dwItemSpec,
pNMCD->iSubItem );
            GetSubItemRect( pNMCD->nmcd.dwItemSpec, pNMCD->iSubItem,
LVIR_BOUNDS, rc );
            pDC->FillSolidRect( rc, GetSysColor( COLOR_WINDOW ) );
            GetSubItemRect( pNMCD->nmcd.dwItemSpec, pNMCD->iSubItem,
LVIR_LABEL, rc );
            pDC->DrawText( itemText, rc, DT_LEFT|DT_WORDBREAK );
        }
        break;
    }
}



"A. Ng" <ang@peerdirect.com> wrote in message
news:OoTcRslRDHA.560@TK2MSFTNGP10.phx.gbl...
> Yan,
>
> Thanks for the suggestion.   I checked MSDN on NM_CUSTOMDRAW but it did
not
> provide any details
> at all.   Wonder if any one have some pseudo/sample code for me to look
at?
> BTW, I am kind of new to MFC, so I really appreciate the help here.
>
> Andy
>
> "Yan K. Avlasov" <_yan_avlasov_@_azimuth.net_> wrote in message
> news:%23hcTnckRDHA.2228@tk2msftngp13.phx.gbl...
> > I don't think you can do it without handling NM_CUSTOMDRAW and draw item
> > text manually. In report mode all items should have the same height, so
> you
> > have to decide beforehand how many lines of text per listview item you
> want
> > and choose the appropriate item height. Setting item height is a bit
> > tricky... One way to do it is to create empty imagelist of desired
height
> > and select it into your list control.
> >
> > Yan
> >
> >
> > "A. Ng" <ang@peerdirect.com> wrote in message
> > news:e3HvHLiRDHA.3192@tk2msftngp13.phx.gbl...
> > > Hi,
> > >
> > > I have an application that sets up a grid using CListCtrl.
> > > Now I am trying to fit a line of characters into one of the cells.
> > > Because the length of the line may vary, I need to have word wrap for
> the
> > > cell.
> > > However, I cannot find references anywhere to do this.
> > > Any ideas or advices are absolutely appreciated.
> > >
> > > Andy
> > >
> > >
> >
> >
>
>


0
Yan
7/9/2003 9:35:01 PM
On Wed, 09 Jul 2003 16:24:41 -0400, Joseph M. Newcomer
<newcomer@flounder.com> wrote:

>I tend to solve this problem in a very lazy fashion.

All good programmers do. (That's a bad "joke," not flamebait! )

>I keep an ordinary CEdit control, invisible, around. 
[Good advice snipped]

I've taken a slightly different approach. I create the edit control
and use it for all the data entry. I make it appears as though it's
part of whatever background control I need it to.

I move the edit to whatever location that will have the focus and the
user types into it. I determine what the location and extents are 
( x, y, cx,cy coords ) and call MoveWindow(...), like so:

myEdit.MoveWindow( x,y,cx,cy ).

When I want it hidden I call MoveWindow() Like this:

 myEdit.MoveWindow( -1000,-1000,10,10 ); 
(Arguments are just examples assuming MM_TEXT.)

Thus taking it out of the viewable DC. You can also just toggle
ShowWindow( SW_HIDE ) and ShowWindow( SW_SHOW ). I've 
informally timed this and I see no difference in performance. 

When the user moves focus away from that location, you get the text
out of the edit and put it ( paint it, or whatever ) into the
appropriate area.

The net effect is that it looks like it's part of your background
control. On occasion I disable other controls to accommodate this
behavior.

[War Story Alert!]
I once created an irregular spreadsheet (grid) with nothing but *one*
old style edit window and a lot of paint. IOW, it looked just like a
modern spreadsheet, but the rows determined the size of the cells not
the columns. I literally painted everything on the screen except where
the current cell was. That was the edit control that I just
"MoveWindow'ed" around. The customer loved it.

"Ah, the good old, bad old days."


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----
0
JustBoo (4)
7/10/2003 3:22:29 AM
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:1rtogvou7qs3e5tdm6abh3971o5g6lkccs@4ax.com...
> The other issue is how to actually split the input into words and fit
them into the area
> you have provided. The usual algorithms require doing GetTextExtent,
searching for break
> characters, etc.
>
> I tend to solve this problem in a very lazy fashion.
>
> I keep an ordinary CEdit control, invisible, around. Typically, I
create it during the
> PreSubclassWindow operation. It has no horizontal scrolling, is a
multiline listbox, and
> has vertical scrolling. I set its font to be the font of the dialog, or
to be more
> precise, to the font of the control (CListBox) that I am dealing with.
>
> When it comes time to draw (and I've done this with CListBox, not
CListCtrl), I resize
> this invisible edit control to the width of the area I have to draw in.
This sets the
> "column width". I then do a SetWindowText to put the text in the edit
control. The CEdit
> does all the grotty details of figuring out how to break the line up.
Forcing word wrap by
> splitting the word if the word is too long to fit on even a single
line. All that stuff. I
> then iterate through all the lines of the edit control, extracting the
string that is each
> line, and do a simple TextOut on that. Assuming you know the x, y, and
width of the area
> you need to write text into,

What about simply using DrawText() with DT_WORDBREAK?


-- 
jlr


0
jlr (33)
7/10/2003 5:35:12 PM
On Thu, 10 Jul 2003 14:35:12 -0300, "Jos� Lamas R�os"
<jlr@artech.com.uy> wrote:

>What about simply using DrawText() with DT_WORDBREAK?

How does one type into DrawText() ? ... Suddenly you're writting a lot
of code.

My watch is three hours fast, and I can't fix it.  So I'm going to
move to New York. - sw


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----
0
JustBoo (4)
7/11/2003 4:36:40 AM
<JustBoo@BooHoo.gone> wrote in message
news:3f0e3e6c.3767913@news.dakotacom.net...
> On Thu, 10 Jul 2003 14:35:12 -0300, "Jos� Lamas R�os"
> <jlr@artech.com.uy> wrote:
>
> >What about simply using DrawText() with DT_WORDBREAK?
>
> How does one type into DrawText() ?

You don't. The issue at hand was about displaying text with word wrap.

> ... Suddenly you're writting a lot
> of code.

Huh?


-- 
jlr


0
jlr (33)
7/11/2003 12:07:58 PM
Reply:

Similar Artilces:

Printing WORD docs from a form
I have a button on a form and I want it to print a Word mail merge document that contains data from the database that is linked to my application. I'm using the following code but always get a 5922 error - Word can't open the source... All variable names contain valid data, so that's NOT the problem. With appWord .Visible = True .Documents.Open pathdocname With .ActiveDocument.MailMerge .MainDocumentType = wdFormLetters strConnection = "DSN=MS Access Databases;" _ & "DB...

problem with BOLD. ITALIC...using Word as editor
I compose a msg using Outlook. Word is the editor. I set a word in bold ot italic. I send msg to myselg, reading in Outlook. The bold or italic is gone. What to do? Thanks, Leo Are you sending the message as text only? If so all formatting will disappear. If you want to retain your formatting you'll need to send your messages as HTML. You can check this in your Outlook options. -- Martin Sketchley | www.msketchley.pwp.blueyonder.co.uk (remove EGGBEANSANDSPAM to reply by e-mail) ...

Windows XP: Open file in read-only: Word, Excel, Visio
I'm often sharing files on a network drive with someone. Often, one of us knows that we don't need to open a file for modification, and we only need read-access. Is there a way to open a file in read-only mode so that when someone does need to open it for modification, the read-only user is not blocking that? If there is not a way to do this native to Windows XP, is there a way to do it from the three applications that we use most, namely Word, Excel, Visio? All are 2003 versions. Thx. I used to save files like this in "read only recommended" mode. File|SaveAs|Tools|Ge...

Not enough memory error trying to open a Word X file
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Error message: &quot;There is not enough memory or disk space available to complete the operation&quot; when trying to open a Word X file in Office 2008 in Leopard or Snow Leopard on iMac that works fine in Word X despite resaving a new version. Any tips? Not enough information to answer. Check that OS X and Office 2008 have the latest updates applied. Use Disk Utility to Repair Permissions. Check the access your user ID has to the system Temporary folder (don't worry about this if you ar...

Cannot upgrade to Word 2007 from Word 2002 as word crashes when tr
We have a word add in that programatically inserts an auto text table then adds rows to it. This works ok in Word 2002 but occasionally crashes in Word 2007 - this is not a consistent crash when we carry out the same operation it happens in no specific sequence. The only place we are able to track it down to is the auto text table inserting rows. Word itself is crashing. We are using COM AddIn written in VB6. Does anyone know of any key differences/issues between Word 2002 and Word 2007 that could cause such an error. Or is there a better way to attach a debugger/word debugg...

Word 2007 TOC Not saving settings...
Hi there, When I use Word 2007 TOC, and I want to edit an existing TOC layout, etc. It wont remember my settings. I go to References Table of Contents Insert Table of Contents Then I make my chnages here, such as changing the levels of the various styles and how they show up Then I select OK, the TOC is created.. I then decide I don't like the changes I made, or I need to include another style So I go to References Table of Contents Insert Table of Contents The changes I made are no where to be seen. I have to start over from scratch. What am I doing wrong,...

Encoded Word Documents
We have recently purchased a new pc with windows 7 and have installed the Microsoft Office software however when I got to open a PDF or word document from a webpage a file conversion pop up box comes up and asks for me to select the encoding that makes the document readable but none of them do. even the windows default doesn't work...... You cannot open a pdf in Word. You need Adobe Reader. What you're downloading from a web page probably isn't a Word document, either. On May 27, 4:25=A0pm, Newuser <Newu...@discussions.microsoft.com> wrote: > We have rece...

Word Wrap: Where is it in Word 2007?
I have Googled and Googled and cannot find any page that tells me where Word Wrap is. For such a basic feature you'd think it would be under View. Suggestions? On Mon, 18 Jan 2010 18:55:28 -0600, "Gary Gary" <blah@blah.blah> wrote: >I have Googled and Googled and cannot find any page that tells me where >Word Wrap is. For such a basic feature you'd think it would be under >View. Suggestions? The reason you aren't finding anything is that word wrap is automatic in Word unless you turn it off, or possibly if something is broken. Wha...

Where are my saved word?
I open the attachment directly, it is .doc and edit it in a loong time, what I ask is when I press save button and it show nothing so I think it succes. And I close it!! I can't find it now, could you help me ????? Thanks! It is gone. When editing an attachment, you /must/ save it to your HDD first, edit it and then reattach it. -- Bruce Hagen MS-MVP [Mail] Imperial Beach, CA "smezsc" <smezsc@discussions.microsoft.com> wrote in message news:3AF0D07A-D490-4819-A649-1C5FC079027F@microsoft.com... >I open the attachment dire...

Bulk E-mail with Non-Word Attachment
I need to be able to send a bulk e-mail (not from a template) with attachments of a number of different document types to a group of contacts (could be from a Saved View or Marketing List). Direct E-mail, Quick Campaigns and Mail Merge do not seem to be able to do this. Is there another way? Thanks. Nope. Take a look at this blog http://groups.google.com/group/microsoft.public.crm/msg/0a84808e99645006?dmode=source&hl=en Cheers, Venkatesh ---- On May 16, 11:57 pm, DStella <DSte...@discussions.microsoft.com> wrote: > I need to be able to send a bulk e-mail (not from a tem...

word 2002 compatibility with Windows 7
My niece is handicapped and her new computer has Office 2007 on it. She would like me to install word 2002 on her Inspiron 546. Is this possible? Yes, if it is licensed for another computer. If it is an OEM version, it cannot be installed on any but the system with which it was sold. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "Sharon F" <SharonF@discussions.microsoft.com> wrote in message news:216DC8A6-4282-46A1-876D-B4D76E793F33@microsoft.com... > My niece is handicapped and her new computer ...

Word 2007--pesky black dotted line
Hello: I have this moderately thick, black, dotted line running between paragraphs on my page. I have no idea how to get this thing to go away. Please, could you tell me what to do to get rid of it? Thanks, John Saxon See here http://word.mvps.org/faqs/formatting/CantGetRidOfLine.htm -- Mary Sauer MVP http://msauer.mvps.org/ "John" <someone@someplace.invalid> wrote in message news:2B22C75C-4BBB-43E0-8C67-BE19C55B818C@microsoft.com... > Hello: > > I have this moderately thick, black, dotted line running between paragraphs on > my p...

Formula to extract the last word from a cell
Anyone know of a formula that will extract the last word from a cell. For example if cell contains the text: Best available title How could I produce the result: "title" (And preferably be able to fill the formula down the column to get the last word from other cells in the column as well.) Thanks for any suggestions. =MID(A10,FIND(CHAR(1),SUBSTITUTE(A10," ",CHAR(1),B10))+1,99) -- __________________________________ HTH Bob "Dave K" <fred.sheriff@gmail.com> wrote in message news:c4347e85-a3e2-4abe-b632-88643d4d244c@w7g2000hsa.googlegroups.com... &...

Default DOCX file to open w/ Word 2007 and DOC to open with Word 2
Hi, I am trying to convert several hundred mail merge documents from Word 2003 to Word 2007. Currently, if I double click a document to open it, it opens in whichever version of Word was run last. What I would like, is for ..DOC files to open in 2003 and .DOCX files to open with 2007. I've tried to change the file types to do this, but can't make it 'stick'. Any suggestions? To prevent the two Word versions from "competing" over the file associations, see the "Hacking the Registry" section of the article at http://www.gmayor.com/Toolbars_in_wor...

copying Arabic into Word document on Mac
I am trying to copy and paste an Arabic word from the web into a multi-lingual Word document on my Mac but am having terrible trouble. It always comes out either backwards (left-right) or with the letters not correctly joined up (an Algerian colleague tells me). I have tried making the web page I am copying from into a PDF first, but doesn't help. Any advice greatly appreciated. Michael <huanzuiju@googlemail.com> wrote: > I am trying to copy and paste an Arabic word from the web into a > multi-lingual Word document on my Mac but am having terrible trouble. > It always co...

limiting number of words in textbox in Word 2007
I created a Textbox in MS-Word 2007 by going to the Developer option->then chose Design Mode, then Legacy Tools->Text box Field. The MultiLine and Enterkey properties are True and the rest are default values. Is there a way I can limit the number of words to a certain number? I realize there is a way to limit the number of characters in the Textbox by the Maxlength value. Also, is it possible that a message appears when the user exceeds the maximum length informing him about that. Do I need to use VBA code or do the inbuilt features of word allow me to do that? The short ...

microsoft word
is it possible to create a macro to open up word and copy and paste some data from excel into it. Thanks Debra Dalgleish has an example at: http://www.contextures.com/xlcomments03.html#CopyToWord It's a way of copying comments in a worksheet to a word document. But you can see the structure nicely. head wrote: > > is it possible to create a macro to open up word and copy and paste some data from excel into it. Thanks -- Dave Peterson ec35720@msn.com ...

Word conversion
I have a long list of items in a Word doc, and when I copy paste t Excel, all the items are in one cell. Is there a way to paste the item into Excel into different columns? Thanks -- Message posted from http://www.ExcelForum.com You could use Data | Text to Columns | Delimited and choose a space as the delimiter. Just follow the dialogue. Regards Trevor "mrroboto >" <<mrroboto.1al9vr@excelforum-nospam.com> wrote in message news:mrroboto.1al9vr@excelforum-nospam.com... > I have a long list of items in a Word doc, and when I copy paste to > Excel, all the ite...

Use Word 2007 to edit Outlook 2003?
I have Word 2007 from the teacher and student edition, so it did not come with Outlook 2007. I use Outlook 2003 from an earlier package. I would like to use Word as my email editor, but when I go to Outlook's Tools/Options/Mail Format tab the boxes say Word 2003 and are grayed out; there is no option for Word 2007, nor a way to click on Word 2003. Is there a way to use Word as my email editor? Thanks, tfall No. Version must match. It has been ever thus. -- Russ Valentine "tfall" <tfall@discussions.microsoft.com> wrote in message news:A58F9CAE-086B-4B7...

Microsoft Word Question
Hi all, I realise this is not the correct group for this but hoped someone could tell me which group I should post in? On my desktop Computer with Microsoft XP Home, I have the Microsoft Office 2007 suite, In word 2007 from it, I cannot find how to "select all" as I used to be able to do in earlier Word versions. Would anyone be able to help please? Mick Cant. "Mick Cant" <mrcycleuk@yahoo.co.uk> wrote in message news:JfqdnRfHApyrTBDUnZ2dnUVZ8tqdnZ2d@brightview.com... > Hi all, > I realise this is not the correct group for this but hoped someone cou...

Word 2007 error 01-13-10
We hvae offfcie 2007 professional installed, user's getting the following erro when launch word 2007, If I re-create the windows user profile it works fine. Is any easire workaround for this. Microsoft Visual Basic Run-time error '429'; ActiveX component can't create object This is usually the result of a broken add-in or a corrupted Normal.dotm template -- see http://support.microsoft.com/kb/828550 for background. First, with Word closed down, go to %appdata%\Microsoft\Templates and rename Normal.dotm to OldNormal.dotm. Restart Word, which will create a new...

Pasting an excel worksheet into word
How do I rotate an Excel worksheet 90 degrees when pasting it into a Word file? Hi one workaround: - copy the data in Excel - insert the data as PICTURE within MS Word ('Edit - Paste Special') - use the 'Draw' toolbar to rotate this picture Note: The data is not updated within this picture if you change the Excel file. -- Regards Frank Kabel Frankfurt, Germany Rix wrote: > How do I rotate an Excel worksheet 90 degrees when pasting it into a > Word file? Frank When I do this the rotate buttons are greyed out and I can't use them. Hi I just tried it (with Excel...

dots appearing between all words in Word 2003
All of a sudden, dots are appearing between all words in Word 2003. What have I done ??? -- Yvonne J You have turned on Word's hidden formatting characters. Press the � button or CTRL+SHIFT+8 to toggle the display. If that doesn't work, it is possible that Word has corrupted its data key where the formatting setting preferences are stored. Check Tools > Options > View > Formatting marks and ensure that all the boxes are unchecked. If the setting changes back then delete the Word data key in the registry and allow Word to build a new one. Even this may not t...

Adding comments to Word documents
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel When editing a document in Word for Mac, how do you add &quot;Comments&quot; that show as mark ups for other readers of the document. This function is found in the &quot;Review&quot; tab of Word on PCs. <br> Thanks One option: Insert> Comment But see Word Help on the subject: Insert a comment HTH |:>) Bob Jones [MVP] Office:Mac On 3/28/10 7:57 PM, in article 59bb61ea.-1@webcrossing.JaKIaxP2ac0, "Elliot_ta@officeformac.com" <Elliot_ta@officeformac.com&...

Filter Out Key Words
Filter What is your method to filter windows live mail? The spammers use the same key words like pharmacy or drugs. But the emails come from different email addresses or servers. Which email program will filter out 'Key Words' or is that possible? Thanks from The New Orleans French Quarter ...