SetItemHeight in CListCtrl

Is there a way for me to set the height of all the items in a CListCtrl? I 
am trying to overlay one of the columns in an item with a CComboxBox and the 
minimum height in the comboBox appears to be greater than the height of the 
item in the CListCtrl. 


0
bwestcott (33)
3/9/2005 9:03:49 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
1061 Views

Similar Articles

[PageSpeed] 3

Brian Westcott wrote:
> Is there a way for me to set the height of all the items in a CListCtrl? I 
> am trying to overlay one of the columns in an item with a CComboxBox and the 
> minimum height in the comboBox appears to be greater than the height of the 
> item in the CListCtrl. 
> 
> 

You have to create OWNERDRAW CListCtrl (define LVS_OWNERDRAW style). 
Then you can define item height by writing message handler for 
WM_MEASUREITEM message in CListCtrl parent control. BUT, when you create 
ownerdraw listview, you have to draw all listview items by self in 
WM_DRAWITEM message handler in CListCtrl parent control. That isn�t 
really hard to do. I wrote a property editor, which displays data in 
combo inside listview and i did it that way...
0
3/10/2005 7:54:17 AM
Thanks for the info. I found some code that used LVS_OWNERDRAWFIXED and was 
able to solve my problem in a few minutes.

"Asko Telinen" <asko.NOSPAM.telinen@jyu.REMOVETHIS.fi> wrote in message 
news:eCXVZZUJFHA.1208@TK2MSFTNGP10.phx.gbl...
> Brian Westcott wrote:
>> Is there a way for me to set the height of all the items in a CListCtrl? 
>> I am trying to overlay one of the columns in an item with a CComboxBox 
>> and the minimum height in the comboBox appears to be greater than the 
>> height of the item in the CListCtrl.
>
> You have to create OWNERDRAW CListCtrl (define LVS_OWNERDRAW style). Then 
> you can define item height by writing message handler for WM_MEASUREITEM 
> message in CListCtrl parent control. BUT, when you create ownerdraw 
> listview, you have to draw all listview items by self in WM_DRAWITEM 
> message handler in CListCtrl parent control. That isn�t really hard to do. 
> I wrote a property editor, which displays data in combo inside listview 
> and i did it that way... 


0
bwestcott (33)
3/11/2005 3:14:48 PM
Reply:

Similar Artilces:

CListCtrl questions
Hi, I am developping on Pocket pc and smartphone and I have a few questions about CListCtrl in report mode. First how can I know how many items I can display without having a vertical scrollbar? On smartphone we are using keypad to move, so first time when I press down key, the curent selection doesn't move.It's only the second time I press the key that is starts to move. First I thought it was a focus problem but even with the focus, it still the same. I also tried to select the first line first with a setitemstate but same result.any idea ? Last question is once a clistctrl h...

SetItemHeight in CListCtrl
Is there a way for me to set the height of all the items in a CListCtrl? I am trying to overlay one of the columns in an item with a CComboxBox and the minimum height in the comboBox appears to be greater than the height of the item in the CListCtrl. Brian Westcott wrote: > Is there a way for me to set the height of all the items in a CListCtrl? I > am trying to overlay one of the columns in an item with a CComboxBox and the > minimum height in the comboBox appears to be greater than the height of the > item in the CListCtrl. > > You have to create OWNERDRAW CLi...

CListCtrl
I have used LVS_EX_CHECKBOXES extended style for my CListCtrl. Do Parent Window/Dialog receive any notification message when user set/reset the checkbox. I tried to use NM_CLICK , but checkbox value is changed after this notification is processed. ...

Displaying JPEG images in CListCtrl
Hi All, I am writing an application in which I want to display a set of JPEG images into a CListCtrl. Is there a way of doing this by using just MFC? Awaiting for your reply Thanks & Regards Sachin Bhave > I am writing an application in which I want to display a set of JPEG > images into a CListCtrl. Is there a way of doing this by using just MFC? Try codeguru/codeproject for something like this. Here is one that should get you started: http://www.codeproject.com/listctrl/thumbnailview.asp --- Ajay ...

CListCtrl Header height change??
CListCtrl Header height change?? Is it possible to change the height of a CListCtrl Header.? Thanks Markus ...

Problems with CListCtrl
I'm having trouble with a CListCtrl object. I'm trying to automatically set the selected items of the list from my code. I try the following statement: m_List.SetItem (pos, 0, LVIF_STATE, NULL, 0, LVIS_SELECTED, LVIS_SELECTED, 0); The SetItem function returns non-zero, which supposedly means it was successful. However, I don't see any selection showing up. I even called RedrawItem on this list item, but it didn't help either. Anyone know about this? -Eric >I'm having trouble with a CListCtrl object. I'm trying to automatically >set the selected ite...

CTreeCtrl and CListCtrl problem
I use create a single document struct using MFC(explore style).The left of the window is CLeftView class(which inherit CTreeView).The right is CBrowserView which inherit CListView.I want to display the content of a directory in the right(CListview) when user click the item of the ctreectrl. In the LeftViw I add method "void CLeftView::OnClickItem (NMHDR* pNMHDR, LRESULT* pResult)" because I want to know which item be clicked by user. ////////////////Leftview////////////////////// CTreeCtrl& mtree=GetTreeCtrl(); HTREEITEM item=mtree.GetSelectedItem(); data=mtree.GetItemDat...

CListCtrl and sub item editting
Hi, Is it possible to implement CListCtrl sub item editting without creating a custom ctrl? I am using VS2003. TIA Tony >Is it possible to implement CListCtrl sub item editting without creating a >custom ctrl? Tony , There's no built-in support for this, so no, you have to provide some implementation for this. Have a look on sites such as CodeGuru and CodeProject, they'll have examples. Dave Thanks Dave, I've seen examples, I just wasnt sure if I needed my own ctrl. Regards Tony "David Lowndes" <DavidL@example.invalid> wrote in message news:k...

How to add clistctrl into clistctrl?
How to clistctrl into a clistctrl? For example like adding checkbox , combobox, i want to add clistctrl into a clistctrl ...

using TVS_CHECKBOXES and SetItemHeight
I am using a CTreeCtrl (in a CTreeView). I've altered the height of the tree items, using SetItemHeight(), making each item 50% larger than the default. The problem is, now when I try to use the checkboxes (using TVS_CHECKBOXES style) the boxes are not centered vertically (although the text and the +/- collapse buttons are). The checkboxes sit down at the bottom of the item's rectangle. Is this a bug? or is there some way I can alter the placement of the checkbox? Thanks in advance. ...

Unable to use CListCtrl.FindItem after CListCtrl.SortItems
I have a CListCtrl which I want to sort, but after I sort I can no longer use FindItem because it always returns a failure. Any assistance with this is greatly appreciated. Thanks! >I have a CListCtrl which I want to sort, but after I sort I can no longer >use FindItem because it always returns a failure. Any assistance with this >is greatly appreciated. Show a concise code example of what you're doing then someone may be able to point out what's wrong. Dave -- MVP VC++ FAQ: http://www.mvps.org/vcfaq LVFINDINFO findinfo; findinfo.flags=LVFI_STRING; findinfo.ps...

CListCtrl Item Selection Questions
Hi I want to ask several things about CListCtrl here: 1. How to disable multiple item selection? 2. How to disable the column header click? Since I don't have any sorting facility in my application. Thank you very much. Select the ListCtrl object in resource editor and set the following properties Single Selection True No Sort Header True Cheers Check Abdoul --------------------- "Landon" <Landon@discussions.microsoft.com> wrote in message news:589C8584-BE50-4BA0-AA56-58297A072FC3@microsoft.com... > Hi I want to ask severa...

CListCtrl ?
I was wondering if there is an equivalent statement for the CListCtrl to select a particular? Something like SetCurSel(item number) in a CListBox? What I want is to highlight the insert item and have the list scroll down so that the current item that was inserted is always visible. As it is now the top of the list is always visible. Z.K. You can use SetItemState() and EnsureVisible() to do what you're trying to do. Something like: m_MyList.InsertItem(nItem,_T("New Text For This Item"); m_MyList.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); m_MyL...

Problem with CListCtrl::HitTest
Hi all... I'm programming a Custom Drawn List Control. The problem is when I add a handler for ON_WM_LBUTTONDOWN. This is the code I have in it: void CMyGrid::OnLButtonDown(UINT nFlags, CPoint point) { LVHITTESTINFO ht; ZeroMemory(&ht, sizeof(LVHITTESTINFO)); ht.pt = point; HitTest(&ht); CListCtrl::OnLButtonDown(nFlags, point); } After the call to HitTest, these values are contained in the structure: pt = {x=177 y=179} flags = 1 iItem = -1 iSubitem = 0 regardless I click on an item or not. To know the item and subitem where the click occures, I can use a loop, I think, ...

Creating a CListCtrl
I'm creating a CListCtrl manually to be added to a tabbed window. I have the line: m_listCtrlArtifacts->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT, CRect(20,20,200,200), &m_outBar, IDGT_PROJ_LIST_ARTIFACTSLIST); MSDN help page - http://msdn2.microsoft.com/en-us/library/zdff988k.aspx - seems like I have all parameters valid, but the problem is that at runtime this gives me an unhandled exception. Any suggestions? > I'm creating a CListCtrl manually to be added to a tabbed window. I have the > line: > > m_listCtrlArtifacts->Create(WS_CHILD|WS_VISIBLE|...

CListCtrl?
Can anyone tell me how to save the items in a CListCtrl to a file and then to load it when the dialog is opened? Thanks in advance I think this already got answered, but this is a new thread so: I would use CStdioFile and simply write the file out as comma separated values like: "Name","Address","Company" or, alternatively, you could store the items in an object list and serialize it to disk if you don't need the file to be readable by outside programs or people. Then, when you want to reload the list control you read and parse the file and write th...

Hello Experts ! Problem in inserting items in one CListCtrl based on another CLisTCtrl
Hello Experts and ALiR, I have 2 ClistCtrls and both are sublassed CMyListCtrlOne and CMyListCtrlTwo. In the CFromView ,I am initilaizing the column ,width and also add items for CMyListCtrlOne and for the CMyListCtrlTwo I am I am initilaizing the column ,width only. and When I click any item related to CMyListCtrlOne ,in the OnClcik handler I get the row and data. Now I want to add this data in the second list CMyListCtrlTwo Here is the code.....Tell me where I am going wrong. After running this app I get a debug assertion file name:afxcmn.inl line no:142 Thanks in advance Tom In C...

Right clicking on a CListCtrl item
I have a TreeCtl object in a dialog box. I created an OnNMRclick.. override function to capture a right clicks. The problem I can't figure out is how to find the tree item that the user has right clicked on. Here's what I tried: void CRestoreFiles::OnNMRclickXYZ(NMHDR *pNMHDR, LRESULT *pResult) POINT CurPos; TVHITTESTINFO lpht; HTREEITEM RightClickItem; GetCursorPos(&CurPos); lpht.pt = CurPos; RightClickItem = TreeView_HitTest(pNMHDR->hwndFrom,&lpht); ... I figured that GetCursorPos would give me the position of the cursor where I had right clicke...

CListCtrl confusion
I am confused about the meaning of selected (LVIS_SELECTED) and focused (LVIS_FOCUSED). What is the difference? The above can be set/read with Set/GetItemState(). The there is also GetSelectionMark() and its set. When you get the selection mark, is this the one that is selected? Or does it mean something else? What I am able to do is click on a row and then execute my method, doit(). Now I want to simply use the up and down arrow keys to move the selection and focus up and down the list, each time calling doit() for the new row. The problem I am running into is that I get recursive calls to...

clistctrl::InsertItem() and clistctrl::setitemtext() issue in windows xp
Hi, I've been developing an application on windows 2000 (sp3) for the past few months. Turns out we'll have to support the app on windows xp too. I tried running the app on xp but have run into a problem. The text I'd like to display in my list control doesn't show up on XP. Basically, when an UpdateAllViews() is sent from the document, the list view's OnUpdate() function calls InsertItem() and SetItemText(....) to display the information. This works with no problem on windows 2000 but I'm having a hard time figuring out why it's not working on XP. Any ideas? Thank...

NM_CUSTOMDRAW and CListCtrl
Forgive me if this is a duplicate post. I'm using a CListCtrl with LVS_OWNERDATA and using NM_CUSTOMDRAW to draw the items myself, rather than letting windows do it -- however, this is quite slow. How does windows do it so fast, and why is my code so slow? Keep in mind that becuase of the LVS_OWNERDATA style, NM_CUSTOMDRAW is only fired once per item, not once per sub item, so when I get the event, I have to draw the entire row at one time. Heres the code: void CMusikPlaylistCtrl::OnLvnGetdispinfo(NMHDR *pNMHDR, LRESULT *pResult) { NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDI...

clistctrl drag image not showing text
I am using a class derived from clistctrl. I am using the CreateDragImage function to create the image shown when dragging. My understanding is that this should create an image of both the icon displayed as well as the text for the particular item I am dragging, however all I am getting is the icon with no text. I am sure this has something to do with the fact that this is a derived class, but does anyone know any other workarounds for getting the text to display in the drag image? Thanks, Derrick could i create a bitmap from the rect of the selected item on screen and use that bitmap for t...

CListCtrl Setting the Focus to a Row through Code
Hi i am taken a dialog based application. on the dialog i placed CListCtrl.i added 3 cols and 10 row to the list control. the first column is Checkbox. On the dialog box i placed two Buttons with captions "Next" and "Previous". when i run my application, when i Press "Next" Button the selection mark in the CListCtrl should move to the next row.and when i press "Previous" the selection mark in the CListCtrl should move to the previous row. i am using nItem=5; m_ListCtrl.SetItemState( nItem, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED ); it...

attaching child ClistCtrl window to resizable parent Dialog
I'm using Visual C++ 7.0 and MFC With the Wizard, I created a Dialog Window [which I made resizable]. I've place two ClistCtrls side by side on the top of the dialog. I'd like to attach the RHS of the rightmost ctrl to the parent dialog so that when I resize the dialog, the listctrl expands. Note that I don't explicitly create the listctrls - this ia all behind the scene. I only send an initial message to each: m_ConfCtrlList.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE,0, LVS_EX_FULLROWSELECT|LVS_REPORT|LVS_EX_GRIDLINES ); Thanks, Ihor VC++ doesn't not...

Using CListCtrl
When I click a list Item using left mouse button, I get NM_Click notification message. And When I select a list item using keyboad, I get NM_KEYDOWN notificatication message. Is there any single notification message, which will tell me about List Item Selection? ...