Click here to Skip to main content
16,004,836 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Limiting an application to single instance...problem? Pin
Waldermort14-Aug-06 2:10
Waldermort14-Aug-06 2:10 
GeneralRe: Limiting an application to single instance...problem...solution [modified] Pin
Vinod Sankaranarayanan14-Aug-06 2:36
Vinod Sankaranarayanan14-Aug-06 2:36 
GeneralRe: Limiting an application to single instance...problem? Pin
prasad_som15-Aug-06 18:49
prasad_som15-Aug-06 18:49 
QuestionHow to vopy data pointed by a "Void* " pointer to "CString" object Pin
VCSharp00713-Aug-06 23:15
VCSharp00713-Aug-06 23:15 
AnswerRe: How to vopy data pointed by a "Void* " pointer to "CString" object Pin
Waldermort14-Aug-06 1:59
Waldermort14-Aug-06 1:59 
AnswerRe: How to vopy data pointed by a "Void* " pointer to "CString" object Pin
ajisthekingofpop14-Aug-06 5:45
ajisthekingofpop14-Aug-06 5:45 
AnswerRe: How to vopy data pointed by a "Void* " pointer to "CString" object Pin
Joe Woodbury14-Aug-06 12:32
professionalJoe Woodbury14-Aug-06 12:32 
QuestionMulticolumn CListCtrl & custom DrawItem Pin
Martijn van Kleef13-Aug-06 22:30
Martijn van Kleef13-Aug-06 22:30 
Hi,

Can anyone please help me implement a custom (override) DrawItem method for a multicolumn CListCtrl, in particular for the individual columns / subitems? Here's what I have so far:

<br />
void CColoredListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)<br />
{<br />
	CString							csItemText = GetItemText(lpDrawItemStruct->itemID, 0);<br />
	CDC							dc;<br />
<br />
	dc.Attach(lpDrawItemStruct->hDC);<br />
<br />
	// Save these value to restore them when done drawing<br />
	COLORREF						crOldTextColor = dc.GetTextColor();<br />
	COLORREF						crOldBkColor = dc.GetBkColor();<br />
<br />
	if (lpDrawItemStruct->itemData != NULL)<br />
		dc.SetTextColor((COLORREF)lpDrawItemStruct->itemData);<br />
<br />
	if ((lpDrawItemStruct->itemAction | ODA_SELECT) && (lpDrawItemStruct->itemState & ODS_SELECTED))<br />
	{<br />
		dc.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));<br />
		dc.FillSolidRect(&lpDrawItemStruct->rcItem, ::GetSysColor(COLOR_HIGHLIGHT));<br />
	}<br />
	else<br />
	{<br />
		if ((lpDrawItemStruct->itemID % 2) == 1)<br />
			dc.FillSolidRect(&lpDrawItemStruct->rcItem, ::GetSysColor(COLOR_BTNFACE));<br />
		else<br />
			dc.FillSolidRect(&lpDrawItemStruct->rcItem, ::GetSysColor(COLOR_WINDOW));<br />
	}<br />
<br />
	// Draw the text<br />
	dc.DrawText(csItemText.GetBuffer(), csItemText.GetLength(), &lpDrawItemStruct->rcItem, DT_LEFT | DT_SINGLELINE | DT_VCENTER);<br />
<br />
	// Reset the background color and the text color back to their original values<br />
	dc.SetTextColor(crOldTextColor);<br />
	dc.SetBkColor(crOldBkColor);<br />
<br />
	dc.Detach();<br />
}<br />


I'm having trouble with the very first line in this method. It always gets the itemtext of the first column, but I'm having a multicolumn listctrl so I also need to know which subitem to get. This method is called from calls to CListCtrl::InsertItem and CListCtrl::SetItemText which get called in a multithreaded context. I was hoping the LPDRAWITEMSTRUCT would have subitem info but it doesn't seem to.

Also, does the lpDrawItemStruct->itemData member contain the info that was set by calls to CListCtrl::SetItemData??
AnswerRe: Multicolumn CListCtrl & custom DrawItem Pin
Milton Karimbekallil13-Aug-06 23:52
Milton Karimbekallil13-Aug-06 23:52 
AnswerRe: Multicolumn CListCtrl & custom DrawItem Pin
Hamid_RT14-Aug-06 1:18
Hamid_RT14-Aug-06 1:18 
QuestionAccess to other computer. How to? Pin
thangnvhl13-Aug-06 21:22
thangnvhl13-Aug-06 21:22 
AnswerRe: Access to other computer. How to? Pin
Milton Karimbekallil13-Aug-06 22:55
Milton Karimbekallil13-Aug-06 22:55 
GeneralRe: Access to other computer. How to? Pin
thangnvhl14-Aug-06 0:27
thangnvhl14-Aug-06 0:27 
GeneralRe: Access to other computer. How to? Pin
thangnvhl15-Aug-06 22:46
thangnvhl15-Aug-06 22:46 
GeneralRe: Access to other computer. How to? Pin
thangnvhl15-Aug-06 22:46
thangnvhl15-Aug-06 22:46 
QuestionCListCtrl Please Help ! [modified] Pin
Bravoone_200613-Aug-06 21:00
Bravoone_200613-Aug-06 21:00 
AnswerRe: CListCtrl Please Help ! Pin
Hamid_RT13-Aug-06 21:50
Hamid_RT13-Aug-06 21:50 
AnswerRe: CListCtrl Please Help ! Pin
Bravoone_200613-Aug-06 23:11
Bravoone_200613-Aug-06 23:11 
GeneralRe: CListCtrl Please Help ! Pin
Hamid_RT14-Aug-06 1:19
Hamid_RT14-Aug-06 1:19 
AnswerRe: CListCtrl Please Help ! Pin
prasad_som13-Aug-06 23:51
prasad_som13-Aug-06 23:51 
QuestionUninstall function Pin
cv_k3n13-Aug-06 19:38
cv_k3n13-Aug-06 19:38 
AnswerRe: Uninstall function Pin
Hamid_RT18-Aug-06 8:16
Hamid_RT18-Aug-06 8:16 
QuestionWorking Threads Pin
cv_k3n13-Aug-06 19:37
cv_k3n13-Aug-06 19:37 
AnswerRe: Working Threads Pin
prasad_som13-Aug-06 19:52
prasad_som13-Aug-06 19:52 
GeneralRe: Working Threads Pin
cv_k3n15-Aug-06 23:21
cv_k3n15-Aug-06 23:21 

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.