Click here to Skip to main content
15,905,316 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCant rebuild ClassView file Pin
Wheatbread19-May-04 4:50
Wheatbread19-May-04 4:50 
GeneralRe: Cant rebuild ClassView file Pin
valikac19-May-04 5:03
valikac19-May-04 5:03 
GeneralRe: Cant rebuild ClassView file Pin
Wheatbread19-May-04 5:06
Wheatbread19-May-04 5:06 
GeneralRe: Cant rebuild ClassView file Pin
jmkhael19-May-04 5:03
jmkhael19-May-04 5:03 
GeneralRe: Cant rebuild ClassView file Pin
Wheatbread19-May-04 5:07
Wheatbread19-May-04 5:07 
GeneralRe: Cant rebuild ClassView file Pin
bikram singh19-May-04 5:55
bikram singh19-May-04 5:55 
GeneralRe: Cant rebuild ClassView file Pin
*Dreamz20-May-04 19:28
*Dreamz20-May-04 19:28 
GeneralCustomDraw and ClistCtrl's SubItem Pin
amit_k_gupta19-May-04 4:41
amit_k_gupta19-May-04 4:41 
Hi,
I have a list ctrl with 10 rows (items) and 4 subitems. Initially color of 4th subitem for each row is green. I achieved it through Custom Draw feature. Now i am displaying a popup menu items on the right click of the any row(item). This popup menu item is having two menu items red and blue. I want that when i select red option then 4th subitem of the selected row turned to red from green. Now to implement this functionality, I am doing like below:

Handler of the OnRed() is :

void CTestListCtrlView::OnRed()
{
int iItemIndex;
iItemIndex = m_ListCtrl.GetSelectionMark();
LVITEM Item;
Item.mask = LVIF_PARAM;
Item.iItem = iItemIndex;
Item.iSubItem = 4;
Item.lParam = RED;
BOOL x = m_ListCtrl.SetItem(&Item);

m_ListCtrl.SendMessage(WM_NOTIFY,NM_CUSTOMDRAW,(LPARAM)&Item);

}

Custom Draw Handler is:

void CTestListCtrlView::OnCustomdrawMyList(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
*pResult = CDRF_DODEFAULT;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
COLORREF crText, crBkgnd;
LVITEM rItem;
ZeroMemory ( &rItem, sizeof(LVITEM) );
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
rItem.iItem = nItem;
m_ListCtrl.GetItem ( &rItem );
LPARAM lp = rItem.lParam;

if (pLVCD->iSubItem == 4 && rItem.lParam == 0 )
{
TRACE("In the Green List");
crText = RGB(0,0,0);
crBkgnd = RGB(0,255,0);
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
}
if (pLVCD->iSubItem == 4 && rItem.lParam== 1 )
{
TRACE("In the Red List");
crText = RGB(0,0,0);
crBkgnd = RGB(255,0,0);
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
}

*pResult = CDRF_DODEFAULT;
}
}


Initially when list control is first drawn i am getting 4th subitem as GREEN bot when i am selecting RED through pop up menu item, 4th subitem is not getting red. In fact application is getting crashed and application never reaches to "In the Red List".

Please help me what i am doing wrong?. I am attaching the code sample also,please heve a look into it.

Thanks in Advance
Amit



GeneralRe: CustomDraw and ClistCtrl's SubItem Pin
valikac19-May-04 5:07
valikac19-May-04 5:07 
GeneralRe: CustomDraw and ClistCtrl's SubItem Pin
amit_k_gupta19-May-04 20:42
amit_k_gupta19-May-04 20:42 
GeneralRe: CustomDraw and ClistCtrl's SubItem Pin
valikac20-May-04 5:13
valikac20-May-04 5:13 
GeneralDisplaying a short movie in same window over 3D display - need an advice Pin
robert_s19-May-04 3:50
robert_s19-May-04 3:50 
GeneralStatusbox and toolbar overwritten Pin
Wigwog19-May-04 2:42
Wigwog19-May-04 2:42 
GeneralFilling the Clipboard using the CDC Pin
Cedar Sith19-May-04 2:36
Cedar Sith19-May-04 2:36 
GeneralRe: Filling the Clipboard using the CDC Pin
ohadp19-May-04 3:09
ohadp19-May-04 3:09 
GeneralRe: Filling the Clipboard using the CDC Pin
Cedar Sith19-May-04 4:02
Cedar Sith19-May-04 4:02 
GeneralRe: Filling the Clipboard using the CDC Pin
Maximilien19-May-04 4:36
Maximilien19-May-04 4:36 
GeneralRe: Filling the Clipboard using the CDC Pin
Cedar Sith19-May-04 5:07
Cedar Sith19-May-04 5:07 
GeneralRe: Filling the Clipboard using the CDC Pin
Maximilien19-May-04 5:23
Maximilien19-May-04 5:23 
GeneralRe: Filling the Clipboard using the CDC Pin
John R. Shaw19-May-04 12:46
John R. Shaw19-May-04 12:46 
GeneralGlobal Variables Pin
asv19-May-04 2:32
asv19-May-04 2:32 
GeneralRe: Global Variables Pin
valikac19-May-04 5:09
valikac19-May-04 5:09 
GeneralRe: Global Variables Pin
asv19-May-04 6:26
asv19-May-04 6:26 
GeneralRe: Global Variables Pin
Andrew Quinn AUS19-May-04 6:06
Andrew Quinn AUS19-May-04 6:06 
GeneralRe: Global Variables Pin
asv19-May-04 6:36
asv19-May-04 6:36 

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.