Click here to Skip to main content
15,892,674 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WindowLess Rich Text Pin
ForNow10-Feb-09 13:21
ForNow10-Feb-09 13:21 
GeneralRe: WindowLess Rich Text Pin
ForNow10-Feb-09 13:54
ForNow10-Feb-09 13:54 
QuestionRedrawing lines draw by a user Pin
en9ap10-Feb-09 6:27
en9ap10-Feb-09 6:27 
AnswerRe: Redrawing lines draw by a user Pin
Stuart Dootson10-Feb-09 6:54
professionalStuart Dootson10-Feb-09 6:54 
AnswerRe: Redrawing lines draw by a user Pin
led mike10-Feb-09 6:54
led mike10-Feb-09 6:54 
AnswerRe: Redrawing lines draw by a user Pin
Cedric Moonen10-Feb-09 7:59
Cedric Moonen10-Feb-09 7:59 
GeneralRe: Redrawing lines draw by a user Pin
en9ap11-Feb-09 4:39
en9ap11-Feb-09 4:39 
QuestionToggling highlighting through a CListCtrl in the correct order Pin
Sternocera10-Feb-09 6:01
Sternocera10-Feb-09 6:01 
Hi guys.

My MFC application uses a CListCtrl with the icon style. The List Ctrl handles messages that make it select/highlight the first, previous, next and last icon, for navigation purposes. However, the order that selection toggles is wrong (it's consistent though) - It is as if the CListCtrl has a different conception of their actual order. I can toggle through the icons 1st, 4th, 2nd, 3rd. I can press "First", send a message, and get to the 1st. I can press last, and get to the third. I can toggle back and forth in that consistent, incorrect order.

What might I be doing wrong? Any suggestions as to how I might solve this problem are greatly appreciated.

Here is the relevant code:
void CMyView::OnInitialUpdate()
{
	.....
	MyListCtrl.ModifyStyle(0, LVS_AUTOARRANGE);
	MyListCtrl.SetImageList(&imgl, 0);
	LVITEM lvi0;
	lvi0.mask =  LVIF_IMAGE | LVIF_TEXT;
	lvi0.iSubItem = 0;
	lvi0.pszText = "First Icon";
	lvi0.iImage = 0;


	int first_icon = MyListCtrl.InsertItem(&lvi0);
	MyListCtrl.SetItemData(first_icon, 1);
	....
}
LRESULT CMyView::OnPressedFirst(WPARAM, LPARAM lParam)
{
	ClearSelection();
	MyListCtrl.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
	return 0;
}
LRESULT CMyView::OnPressedPrevious(WPARAM, LPARAM lParam)
{
	
	MyListCtrl.SetFocus();
	int i = MyListCtrl.GetItemCount();
	int j = 0;
	for(; j != i; ++j)
	{
		UINT uState = MyListCtrl.GetItemState(j, LVIS_SELECTED | LVIS_FOCUSED);
		if (uState & LVIS_SELECTED)
			break;
	}
	if(j == i)
	{
		MyListCtrl.SetItemState(0,LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING);
		return 0;
	}
	--j; // it's the previous one
	if( j < 0)
	{
		MyListCtrl.SetItemState(0,LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING);
		return 0;
	}
	ClearSelection();
	MyListCtrl.SetItemState(j,LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING);
	return 0;
}
LRESULT CMyView::OnPressedNext(WPARAM, LPARAM lParam)
{
	MyListCtrl.SetFocus();
	int i = MyListCtrl.GetItemCount();
	int j = 0;
	for(; j != i; ++j)
	{
		UINT uState = MyListCtrl.GetItemState(j, LVIS_SELECTED | LVIS_FOCUSED);
		if (uState & LVIS_SELECTED)
			break;
	}
	if(j == i)
	{
		MyListCtrl.SetItemState(0,LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING);
		return 0;
	}
	++j; // it's the next one
	if( j >= i)
	{
		return 0;
	}
	ClearSelection();
	MyListCtrl.SetItemState(j,LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING);
	return 0;

}
LRESULT CMyView::OnPressedLast(WPARAM, LPARAM lParam)
{
	ClearSelection();
	MyListCtrl.SetFocus();
	int i = MyListCtrl.GetItemCount();
	--i;
	MyListCtrl.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING);
	return 0;
}

Regards,
Sternocera
QuestionHow can i modify my picture control to automatically draw line? Pin
z01e10-Feb-09 5:50
z01e10-Feb-09 5:50 
QuestionBack to basics; just started learnin C++ Pin
EliottA10-Feb-09 5:46
EliottA10-Feb-09 5:46 
AnswerRe: Back to basics; just started learnin C++ Pin
prasad_som10-Feb-09 6:39
prasad_som10-Feb-09 6:39 
AnswerRe: Back to basics; just started learnin C++ Pin
Eytukan10-Feb-09 7:24
Eytukan10-Feb-09 7:24 
GeneralRe: Back to basics; just started learnin C++ Pin
EliottA10-Feb-09 7:32
EliottA10-Feb-09 7:32 
GeneralRe: Back to basics; just started learnin C++ Pin
toxcct10-Feb-09 7:51
toxcct10-Feb-09 7:51 
GeneralRe: Back to basics; just started learnin C++ Pin
EliottA10-Feb-09 7:52
EliottA10-Feb-09 7:52 
GeneralRe: Back to basics; just started learnin C++ Pin
toxcct10-Feb-09 7:58
toxcct10-Feb-09 7:58 
GeneralRe: Back to basics; just started learnin C++ Pin
EliottA10-Feb-09 8:01
EliottA10-Feb-09 8:01 
GeneralRe: Back to basics; just started learnin C++ Pin
Eytukan10-Feb-09 8:31
Eytukan10-Feb-09 8:31 
GeneralRe: Back to basics; just started learnin C++ Pin
EliottA10-Feb-09 8:33
EliottA10-Feb-09 8:33 
GeneralRe: Back to basics; just started learnin C++ Pin
Eytukan10-Feb-09 8:37
Eytukan10-Feb-09 8:37 
QuestionVisual Studio 2008 Lost Class View of XXXview and a couple of other classes. Pin
Desmond Mardle10-Feb-09 5:44
Desmond Mardle10-Feb-09 5:44 
AnswerRe: Visual Studio 2008 Lost Class View of XXXview and a couple of other classes. Pin
prasad_som10-Feb-09 6:41
prasad_som10-Feb-09 6:41 
GeneralRe: Visual Studio 2008 Lost Class View of XXXview and a couple of other classes. Pin
Desmond Mardle10-Feb-09 7:32
Desmond Mardle10-Feb-09 7:32 
GeneralRe: Visual Studio 2008 Lost Class View of XXXview and a couple of other classes. Pin
Niklas L10-Feb-09 21:21
Niklas L10-Feb-09 21:21 
GeneralRe: Visual Studio 2008 Lost Class View of XXXview and a couple of other classes. Pin
Desmond Mardle10-Feb-09 23:16
Desmond Mardle10-Feb-09 23:16 

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.