stolar
asked on
CListCtrl OK in Win95, BAD in WinNT
Environment: VC++ 4.0, Win95 / WinNT
Hello,
I have developed an MFC SDI application that works fine in Win95.
However, when the program runs in Win NT I have a problem --
The app's view is CListCtrl based, with state icons. In report view
the width of state icon plus label text ought to equal the width of the
first column's header button. Alas, instead of
| header1 | header2 | header3 | ...
-------------------------- ---------- ---------- -
| icon label | text | text |
. . .
| icon label | text | text |
I get
| header1 | header2 | header3 | ...
-------------------------- ---------- ---------- -
| icon label | text | text |
. . .
| icon label | text | text |
The size of the shift is the width of the icon in pixels,
I have tried various icon widths.
It seems that the following action of SetImageList function, described
in help on "CListCtrl", -- "If a state image list is specified, a list
view control reserves space to the left of each item's icon for a state
image." -- fails.
Again, no matter whether I compile in Win95 or WinNT, the described
effect DOES NOT OCCUR when running in Win95.
Any ideas or suggestions are cordially welcomed.
Moshe.
CODE fragments:
~~~~~~~~~~~~~~~
void CMyListView::OnInitialUpda te()
{
CListCtrl& ListCtrl=GetListCtrl();
m_StateImageList.Create(ID B_STATEICO NS,36,0,RG B(255,255, 255));
ListCtrl.SetImageList(&m_S tateImageL ist,LVSIL_ STATE);
int i;
LV_COLUMN lvc;
lvc.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
for(i=0; i<NUM_FIELDS; i++)
{
lvc.iSubItem = i;
lvc.pszText = header[i].szTag;
lvc.fmt = header[i].nJustification;
lvc.cx = header[i].nWidth;
ListCtrl.InsertColumn(i,&l vc);
}
CListViewEx::OnInitialUpda te();
}
void CMyListView::OnUpdate(CVie w* pSender,
LPARAM lHint,
CObject* pHint)
{
int i,j;
LV_ITEM lvi;
LPTSTR S;
CListCtrl& ListCtrl = GetListCtrl();
ListCtrl.DeleteAllItems();
for( i=0; i<LISTSIZE; i++ )
{
lvi.mask = LVIF_STATE | LVIF_PARAM;
lvi.iItem = i;
lvi.iSubItem = 0;
lvi.stateMask = LVIS_STATEIMAGEMASK;
lvi.state = INDEXTOSTATEIMAGEMASK( iState[i] );
lvi.lParam = ( LPARAM )( &( Item[i] ) );
ListCtrl.InsertItem( &lvi );
for( j=0; j<NUM_FIELDS; j++ ) //Set texts
{
S = ... //bla-bla-bla
ListCtrl.SetItemText( i, j, S );
}
}
CListViewEx::OnUpdate(pSen der, lHint, pHint);
}
Hello,
I have developed an MFC SDI application that works fine in Win95.
However, when the program runs in Win NT I have a problem --
The app's view is CListCtrl based, with state icons. In report view
the width of state icon plus label text ought to equal the width of the
first column's header button. Alas, instead of
| header1 | header2 | header3 | ...
--------------------------
| icon label | text | text |
. . .
| icon label | text | text |
I get
| header1 | header2 | header3 | ...
--------------------------
| icon label | text | text |
. . .
| icon label | text | text |
The size of the shift is the width of the icon in pixels,
I have tried various icon widths.
It seems that the following action of SetImageList function, described
in help on "CListCtrl", -- "If a state image list is specified, a list
view control reserves space to the left of each item's icon for a state
image." -- fails.
Again, no matter whether I compile in Win95 or WinNT, the described
effect DOES NOT OCCUR when running in Win95.
Any ideas or suggestions are cordially welcomed.
Moshe.
CODE fragments:
~~~~~~~~~~~~~~~
void CMyListView::OnInitialUpda
{
CListCtrl& ListCtrl=GetListCtrl();
m_StateImageList.Create(ID
ListCtrl.SetImageList(&m_S
int i;
LV_COLUMN lvc;
lvc.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
for(i=0; i<NUM_FIELDS; i++)
{
lvc.iSubItem = i;
lvc.pszText = header[i].szTag;
lvc.fmt = header[i].nJustification;
lvc.cx = header[i].nWidth;
ListCtrl.InsertColumn(i,&l
}
CListViewEx::OnInitialUpda
}
void CMyListView::OnUpdate(CVie
LPARAM lHint,
CObject* pHint)
{
int i,j;
LV_ITEM lvi;
LPTSTR S;
CListCtrl& ListCtrl = GetListCtrl();
ListCtrl.DeleteAllItems();
for( i=0; i<LISTSIZE; i++ )
{
lvi.mask = LVIF_STATE | LVIF_PARAM;
lvi.iItem = i;
lvi.iSubItem = 0;
lvi.stateMask = LVIS_STATEIMAGEMASK;
lvi.state = INDEXTOSTATEIMAGEMASK( iState[i] );
lvi.lParam = ( LPARAM )( &( Item[i] ) );
ListCtrl.InsertItem( &lvi );
for( j=0; j<NUM_FIELDS; j++ ) //Set texts
{
S = ... //bla-bla-bla
ListCtrl.SetItemText( i, j, S );
}
}
CListViewEx::OnUpdate(pSen
}
Hi!
Maybe it is something wrong with the message sequence (some messages disapear in the darkness of the framework?) Anyway.
try to find it out. Do something like a new menu entry, create a message handler and move the code from OnUpdate there.
If you don't have the problem after that... , well, lets think about where you better can place the code.
Albert
Maybe it is something wrong with the message sequence (some messages disapear in the darkness of the framework?) Anyway.
try to find it out. Do something like a new menu entry, create a message handler and move the code from OnUpdate there.
If you don't have the problem after that... , well, lets think about where you better can place the code.
Albert
ASKER
I really don't get your point. As I've said, the application functions perfectly well in Win95. What is the feature of WinNT that corrupts the performance? What handler could the code be moved to? Did I do anything that isn't standard?
Moshe.
Moshe.
ASKER
I solved it,
There is a Microsoft BUG in the SetImageList function in WinNT, and I have some simple code to prove it!
I want my points back, please.
Moshe.
There is a Microsoft BUG in the SetImageList function in WinNT, and I have some simple code to prove it!
I want my points back, please.
Moshe.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The idea is that in the first table ("instead of") the | -signs ought to make up three vertical lines, rendering three normal-looking columns.
In the second table ("I get") the columns ought to be "broken", specifically, the second and third rows of the first column ought to be narrower than the first row of the first column by the length of "icon", while the widths of the second and third columns are constant for all three rows.
I am adding another 50 points for the trouble of understanding this.
Moshe.