I can select an item in a list view with code, but it doesn't show as hilighted.
LV_ITEM lvi;
lvi.mask = LVIF_STATE;
lvi.state = LVIS_SELECTED|LVIS_FOCUSED;
lvi.stateMask = LVIS_SELECTED|LVIS_FOCUSED;
SendMessage(p_lvwAgenda->m_hwnd,LVM_SETITEMSTATE,0,&lvi);
msg(NumToStr(p_lvwAgenda->GetCurSel())); // displays "2", so selection happens
Suggestions?
Thanks.
Is there not a separate attribute for highlight? Reversed or something like that?
Not that I can find. The info I'm using came from MSDN.
Got it.
Added AWS_TABSTOP to the listvew's style at then set focus.
Well now that makes lots of sense. Would never have guessed that one.
I sat staring at the stupid control. I tested the response to the up- and down-arrows -- I knew an item was selected and wanted to see if there was that functionality. No response. Then I clicked in a blank area of the control and the proper item became hilighted. Ahah! Progress. The rest was simple.
Kool - my kind of programming.
Quote from: peaslee on April 17, 2007, 11:31:23 AM
Got it.
Added AWS_TABSTOP to the listvew's style at then set focus.
can you post a code sample. I'll using Listview right now and want to see what you're doing.
I can't post the whole program as I intend to sell it to the unsuspecting public :D
Here is what I do for the control creation:
m_dlgAgenda.AddControl(CTLISTVIEW,"",22,25,875,502,AWS_VISIBLE|ALVS_REPORT|AWS_TABSTOP,0x200,AD_LVW_AGENDA);
I think the AWS_TABSTOP is necessary for the control to get the focus. Then I set which item (line) in the list view I want to be selected. This code appears in the OnInitDialog method for the dialog containing the control.
CListView *p_lvwAgenda = GetControl(AD_LVW_AGENDA);
p_lvwAgenda->SetSel(2); // select item 2
SetFocus(AD_LVW_AGENDA);
After determining that the problem appeared to be with the focus, I went back and used the SetSel() method provided by Aurora instead of the Sendmessage technique shown in the previous post.
Is this useful?
I discovered that if you comment out the SetFocus method, the program still works, so I assume all that was needed to fix this problem was the tab stop style constant.
That kinda makes sense. The set focus would override any previous control.
Is there a specific order in which grouped controls are applied - control precedence?
Quote from: Rock Ridge Farm (Larry) on April 18, 2007, 09:59:12 AM
Is there a specific order in which grouped controls are applied - control precedence?
If you mean tab order, I believe it follows the sequence of control ID numbers.
Tab order is in order of when the controls were created, which while usually is the order of the IDs, it doesn't always have to be.