Click here to Skip to main content
15,906,335 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Status Pane Pin
kasturi_haribabu11-Feb-07 21:57
kasturi_haribabu11-Feb-07 21:57 
GeneralRe: Status Pane Pin
T.RATHA KRISHNAN11-Feb-07 22:37
T.RATHA KRISHNAN11-Feb-07 22:37 
AnswerRe: Status Pane Pin
Hamid_RT11-Feb-07 19:42
Hamid_RT11-Feb-07 19:42 
QuestionRe: Status Pane Pin
David Crow12-Feb-07 2:45
David Crow12-Feb-07 2:45 
Questionconsole application TCP client in C++ [modified] Pin
wizard 20211-Feb-07 16:48
wizard 20211-Feb-07 16:48 
Questionopengl and color filter Pin
zqueezy11-Feb-07 11:45
zqueezy11-Feb-07 11:45 
AnswerRe: opengl and color filter Pin
cmk11-Feb-07 12:20
cmk11-Feb-07 12:20 
QuestionCListCtrl Selection problem Pin
Zombie_Inc11-Feb-07 9:44
Zombie_Inc11-Feb-07 9:44 
Hi all,

Following is the problem (I provided some test code):
After runing the below sample the correct item is displayd at
the top of the list control's visible area just as I want.
The problem is that if I push the VK_DOWN or VK_UP key, the next
selected item will be the first item and not item 356 or 354 as
as you would expect from this sample.
The list will automatically scroll to the first item. However if
I click on the selected item (in this example 355) and then push
the VK_DOWN or VK_UP key it will select the correct item
(in this example 356 or 354).

This is really anoying. Could anybody please give me a hint on how
to proceed. It should be easy to solve but I just can't figur it out.

// In CMyDialog.h
CListCtrl m_cListCtrl;

BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();

// Remove styles
m_cListCtrl.ModifyStyle( LVS_ICON | LVS_LIST | LVS_REPORT | LVS_SMALLICON, 0 );
// Add styles
m_cListCtrl.ModifyStyle(0, LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS );
// Add extended styles
ListView_SetExtendedListViewStyle( m_cListCtrl.m_hWnd, LVS_EX_FULLROWSELECT );

// Header
m_cListCtrl.InsertColumn( 0, "Col 1", 0, 100 );
m_cListCtrl.InsertColumn( 1, "Col 2", 0, 100 );

// Set LVITEM structure
LVITEM lvi;
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0;

// Adding items and subitems
for ( int i=0; i<900; i++ )
{
lvi.iItem = i;
lvi.pszText = "";
m_cListCtrl.InsertItem( &lvi );
for ( int j=0; j<2; j++ )
{
CString str;
str.Format( "Col %d, Row %d", j, i );
m_cListCtrl.SetItemText( i, j, str );
}
}

return TRUE; // return TRUE unless you set the focus to a control
}

void CMyDialog::OnBnClickedButton1()
{
int nItemIndex = 355;
CRect rcTopItem;
CRect rcSelItem;
// Current top visible item
int nTopIndex = m_cListCtrl.GetTopIndex();
// Get bounding rectangle around the current top item
m_cListCtrl.GetItemRect( nTopIndex + 1, &rcTopItem, LVIR_BOUNDS );
// Get bounding rectangle around the selected item
m_cListCtrl.GetItemRect( nItemIndex, &rcSelItem, LVIR_BOUNDS );
// Compute the y distance between the two items
CSize sz( 0, rcSelItem.bottom - rcTopItem.bottom );
m_cListCtrl.Scroll( sz );

m_cListCtrl.SetItemState( nItemIndex, LVIS_SELECTED, LVIS_SELECTED|
LVIS_FOCUSED );
m_cListCtrl.EnsureVisible( nItemIndex, FALSE );

m_cListCtrl.SetFocus();
}
AnswerRe: CListCtrl Selection problem Pin
Mark Salsbery11-Feb-07 11:19
Mark Salsbery11-Feb-07 11:19 
GeneralRe: CListCtrl Selection problem Pin
Zombie_Inc11-Feb-07 11:32
Zombie_Inc11-Feb-07 11:32 
GeneralRe: CListCtrl Selection problem Pin
Mark Salsbery11-Feb-07 11:35
Mark Salsbery11-Feb-07 11:35 
GeneralRe: CListCtrl Selection problem Pin
Mark Salsbery11-Feb-07 11:50
Mark Salsbery11-Feb-07 11:50 
QuestionLog file structures Pin
Waldermort11-Feb-07 8:46
Waldermort11-Feb-07 8:46 
AnswerRe: Log file structures Pin
Mark Salsbery11-Feb-07 9:21
Mark Salsbery11-Feb-07 9:21 
GeneralRe: Log file structures Pin
Waldermort11-Feb-07 9:40
Waldermort11-Feb-07 9:40 
GeneralRe: Log file structures Pin
Mark Salsbery11-Feb-07 10:28
Mark Salsbery11-Feb-07 10:28 
GeneralRe: Log file structures Pin
Waldermort11-Feb-07 20:40
Waldermort11-Feb-07 20:40 
GeneralRe: Log file structures Pin
kakan12-Feb-07 1:17
professionalkakan12-Feb-07 1:17 
GeneralRe: Log file structures Pin
Waldermort12-Feb-07 2:00
Waldermort12-Feb-07 2:00 
GeneralRe: Log file structures Pin
kakan12-Feb-07 2:04
professionalkakan12-Feb-07 2:04 
QuestionCreateFileMapping/MapViewOfFile and 0xC0000005 (ACCESS_DENIED) Pin
Jeffrey Walton11-Feb-07 3:59
Jeffrey Walton11-Feb-07 3:59 
AnswerRe: CreateFileMapping/MapViewOfFile and 0xC0000005 (ACCESS_DENIED) Pin
Waldermort11-Feb-07 4:06
Waldermort11-Feb-07 4:06 
GeneralRe: CreateFileMapping/MapViewOfFile and 0xC0000005 (ACCESS_DENIED) Pin
Jeffrey Walton11-Feb-07 10:06
Jeffrey Walton11-Feb-07 10:06 
GeneralRe: CreateFileMapping/MapViewOfFile and 0xC0000005 (ACCESS_DENIED) Pin
Jeffrey Walton11-Feb-07 10:13
Jeffrey Walton11-Feb-07 10:13 
GeneralRe: CreateFileMapping/MapViewOfFile and 0xC0000005 (ACCESS_DENIED) Pin
Waldermort11-Feb-07 20:27
Waldermort11-Feb-07 20:27 

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.