Click here to Skip to main content
16,017,167 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Pull Downs Menu Items Pin
BobInNJ11-Nov-08 14:09
BobInNJ11-Nov-08 14:09 
GeneralRe: Pull Downs Menu Items Pin
lavagoblin12-Nov-08 4:18
lavagoblin12-Nov-08 4:18 
GeneralRe: Pull Downs Menu Items Pin
Mark Salsbery11-Nov-08 15:42
Mark Salsbery11-Nov-08 15:42 
AnswerRe: Pull Downs Menu Items Pin
BobInNJ11-Nov-08 13:00
BobInNJ11-Nov-08 13:00 
QuestionGet parent process command line in 64 bit Pin
Jack Rong11-Nov-08 10:23
Jack Rong11-Nov-08 10:23 
QuestionHow to select an initial entry when Virtual List is first displayed? Pin
AmVal11-Nov-08 8:11
AmVal11-Nov-08 8:11 
QuestionRe: How to select an initial entry when Virtual List is first displayed? Pin
Mark Salsbery11-Nov-08 8:41
Mark Salsbery11-Nov-08 8:41 
AnswerRe: How to select an initial entry when Virtual List is first displayed? Pin
AmVal11-Nov-08 11:25
AmVal11-Nov-08 11:25 
I'm getting my list of items (CStrings) from doing a database SELECT, then as I loop through each of the results, for a normal list control I would have inserted each item directly into the list control in OnInitDialog(), now for virtual I'm just putting those items into a list at that point, and then pointing the virtual list control to my list, calling .SetItemCount() to set the size for the list control, making the control LVS_OWNERDATA style, etc., following the tutorial in the link below:

http://www.codeproject.com/KB/list/virtuallist.aspx[^]


My OnGetDispInfo() function is pretty simple and looks like this:

void MyDlg::OnGetDispInfo(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
LV_ITEM* pItem= &(pDispInfo)->item;

int itemid = pItem->iItem;

if (pItem->mask & LVIF_TEXT) //valid text buffer?
{
CString text = MyList_.at(itemid);

lstrcpyn(pItem->pszText, text, pItem->cchTextMax);

} // if

*pResult = 0;
}


I don't know if this is typical, but I also had problems in general with programmatically selecting an item in the virtual list control. SetItemState() didn't seem to work at all. (I should mention that I am forced to use Visual C++ 5.0, so I don't know if this could be an old problem that no longer exists). But I did see someone else had this same problem, and suggested a fake mouse click on the item. (See section 'Selection Problems' in the article below)

http://www.ddj.com/184404349;jsessionid=BVQZXGZXOGLUSQSNDLOSKH0CJUNN2JVN?_requestid=130370[^]

So I followed exactly what this guy did, and in general it seems to work great, (even though it doesn't feel like the best solution).

The only issue is with that initial selection when the list first displays. Maybe if SetItemState() worked properly, it wouldn't be an issue. Maybe it's because I'm having to simulate that mouse-click, and there's not really anything there to click on yet.

I'm not really sure.
GeneralRe: How to select an initial entry when Virtual List is first displayed? Pin
Mark Salsbery11-Nov-08 12:39
Mark Salsbery11-Nov-08 12:39 
GeneralRe: How to select an initial entry when Virtual List is first displayed? Pin
AmVal12-Nov-08 4:30
AmVal12-Nov-08 4:30 
GeneralRe: How to select an initial entry when Virtual List is first displayed? Pin
Mark Salsbery12-Nov-08 7:29
Mark Salsbery12-Nov-08 7:29 
GeneralRe: How to select an initial entry when Virtual List is first displayed? Pin
AmVal12-Nov-08 10:17
AmVal12-Nov-08 10:17 
GeneralRe: How to select an initial entry when Virtual List is first displayed? Pin
Mark Salsbery12-Nov-08 10:51
Mark Salsbery12-Nov-08 10:51 
GeneralRe: How to select an initial entry when Virtual List is first displayed? Pin
AmVal12-Nov-08 11:24
AmVal12-Nov-08 11:24 
GeneralRe: How to select an initial entry when Virtual List is first displayed? Pin
Mark Salsbery12-Nov-08 12:04
Mark Salsbery12-Nov-08 12:04 
GeneralRe: How to select an initial entry when Virtual List is first displayed? Pin
AmVal13-Nov-08 2:51
AmVal13-Nov-08 2:51 
GeneralRe: How to select an initial entry when Virtual List is first displayed? Pin
Mark Salsbery13-Nov-08 6:25
Mark Salsbery13-Nov-08 6:25 
GeneralRe: How to select an initial entry when Virtual List is first displayed? Pin
AmVal17-Nov-08 4:30
AmVal17-Nov-08 4:30 
GeneralRe: How to select an initial entry when Virtual List is first displayed? Pin
Mark Salsbery17-Nov-08 4:34
Mark Salsbery17-Nov-08 4:34 
GeneralRe: How to select an initial entry when Virtual List is first displayed? Pin
Mark Salsbery12-Nov-08 7:35
Mark Salsbery12-Nov-08 7:35 
QuestionException problem Pin
rrrado11-Nov-08 3:44
rrrado11-Nov-08 3:44 
AnswerRe: Exception problem Pin
David Crow11-Nov-08 4:27
David Crow11-Nov-08 4:27 
GeneralRe: Exception problem Pin
rrrado11-Nov-08 4:38
rrrado11-Nov-08 4:38 
GeneralRe: Exception problem Pin
David Crow11-Nov-08 4:55
David Crow11-Nov-08 4:55 
AnswerRe: Exception problem Pin
Rajkumar R12-Nov-08 1:08
Rajkumar R12-Nov-08 1:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.