For selection change you can catch the LVN_ITEMCHANGED message. Keep in
for an item being selected.
AliR.
I looked a bit at the examples code for the virtual list controls and
MSDN documentation. One thing I am not sure how to handle is the fact
that the selection change notification seems to be missing. I tried
handling LVN_ODSSTATECHANGED but it seems never to be called. I guess
the only way is to keep track of NM_CLICK and LVN_KEYDOWN for that. Is
there another way?
I suppose that SetSelectionMark and EnsureVisible combination would
replace the SetCurSel of a standard ListBox.
Henryk Birecki
"AliR \(VC++ MVP\)" <AliR@online.nospam> wrote:
I can't recommend a global listbox, because you will be chasing bugs
forever.
But I would recommend a virual list control. It fills in a second so you
can
actually have 3 different list controls without the preformance hit.
Here are some examples: (both by the same guy)
http://www.codeproject.com/listctrl/virtuallist.asp
http://www.codeproject.com/listctrl/quicklist.asp
AliR.
"Henryk Birecki" <soaringpilot@sbcglobal.net> wrote in message
news:suke33hn6dt53ecdj0ma6shprv3vho5b82@4ax.com...
In my MFC based application that shares code between PC and PocketPC I
have three CListBox type objects that I want to be able to share
between different Dialogs that are invoked with DoModal at different
times. CListBox contents are pretty much static, but it takes a long
time (especially on older PocketPCs) to initialize them with
information. I wanted to Create global CListBox windows and then share
them between dialogs as needed. So in InitDialog I create listboxes
(WS_CHILD|LBS_NOTIFY...) if they are not windows yet and fill them
with their content. Otherwise I just set the dialog as their parent
with SetDialog. In the dialog OnDestroy I set listbox parent to NULL
so it is not destroyed with the dialog. This almost works. The problem
is that depending on what is happening between dialog invocations,
second time a dialog is opened message mapping between dialog and
listbox is lost so for instance ON_LBN_SELCHANGE(IDC_ListBox1,
OnSelchangeList) in the dialog code has no effect (dialog never
receives notification), and the listbox does not get re-painted
properly (no erase of background).
Can someone point me to proper way of preserving listbox contents
between dialog invocations? Using a long lived nonmodal dialog will
not work for me as I need different ones at different times.
Thanks in advance,
Henryk Birecki