Click here to Skip to main content
15,891,951 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to communicate with Parallel Port Pin
Cohen6-Aug-04 0:35
Cohen6-Aug-04 0:35 
QuestionWhy do MS prefer to provide a new function, CWnd::CreateEx, rather than override CWnd::Create? Pin
bloggs19744-Aug-04 19:52
bloggs19744-Aug-04 19:52 
AnswerRe: Why do MS prefer to provide a new function, CWnd::CreateEx, rather than override CWnd::Create? Pin
Antti Keskinen4-Aug-04 22:12
Antti Keskinen4-Aug-04 22:12 
GeneralGetItemText returns bad CString & can't change subitem color in CustomDraw Pin
Mike Landis4-Aug-04 19:34
Mike Landis4-Aug-04 19:34 
GeneralRe: GetItemText returns bad CString & can't change subitem color in CustomDraw Pin
Tomasz Sowinski5-Aug-04 0:15
Tomasz Sowinski5-Aug-04 0:15 
GeneralRe: GetItemText returns bad CString & can't change subitem color in CustomDraw Pin
Mike Landis5-Aug-04 1:40
Mike Landis5-Aug-04 1:40 
GeneralRe: GetItemText returns bad CString & can't change subitem color in CustomDraw Pin
Tomasz Sowinski5-Aug-04 1:51
Tomasz Sowinski5-Aug-04 1:51 
GeneralRe: GetItemText returns bad CString & can't change subitem color in CustomDraw Pin
Mike Landis5-Aug-04 6:33
Mike Landis5-Aug-04 6:33 
I don't think eVC 3.0 will load the resource file if you have conflicting IDs in the same dialog (I've had to fix this after hand editing the resource files before). I have hundreds of calls where I cast from CWnd* to a *Ctrl of some sort - the eVC3 documentation for CWnd::GetDlgItem says:
This method retrieves a pointer to the specified control or child window in a dialog box or other window. The pointer returned is usually cast to the type of control identified by nID.

The struct pointed to by pCustomDraw looks normal as does the nmcd struct.

You're absolutely right that GetItemTxt() could be returning an empty string. Its returning an empty string for every subitem in the list control. Why would that happen? The following:

if ( cst.GetLength() > 0 )
{ bool red = ( cst[0] == '-' );
CDC* dc = CDC::FromHandle( nmcd.hdc );
dc->SetTextColor( red ? RGB(255,0,0) : RGB(0,0,0) );
}

prevents access violations, but doesn't explain why cst comes back "" for every subitem.

In watching the code that responds to the LVN_GETDISPINFO messages to the PosListCtrl just before the CustomDraw messages come in, I can see normal looking CString values coming out of the LVN_GETDISPINFO handler:

void CSPosDialog::OnGetDispInfoPosList( NMHDR* pNMHDR, LRESULT* pResult )
{ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
if ( pDispInfo->item.mask & LVIF_TEXT )
{ SPosListItemInfo* pItem =
(SPosListItemInfo*) pDispInfo->item.lParam;
CString cst = this->GetPosItemText( pDispInfo->item.iItem, pDispInfo->item.iSubItem );
LPTSTR pBuf = this->AddPool( &cst );
pDispInfo->item.pszText = pBuf;
}
*pResult = 0;
}

CString CSPosDialog::GetPosItemText( int rr, int si )
{ // get the sortCol for this subitem
CBOSListCtrl* pLC = (CBOSListCtrl*)this->GetDlgItem( IDC_PosList );
short msi = pLC->MapSubitem( si ); // column reordering
CHeaderCtrl* pHdr = pLC->GetHeaderCtrl();
short nItems = pHdr->GetItemCount();
if ( msi < 0 || msi >= nItems-1 ) return _T("");
SPosListItemInfo* pItem = (SPosListItemInfo*)pLC->GetItemData( rr );
if ( !pItem ) return _T(""); // impossible
CPos* pos = pItem->thePos;
bool itsTheTotalRow = ( pos == 0 );
double res;
if ( msi == 8 )
return itsTheTotalRow ? _T("") : pos->note;
unsigned short buf[20];
switch ( msi )
{ case 0:
swprintf( buf, "first col ..." );
// ...
case 7:
swprintf( buf, "other ..." );
}
CString cst( buf );
return cst;
}

CStrings coming out of OnGetDispInfoPosList(), feed AddPool(), and both look normal. Just after, in GetItemText(), all I get is "". That's the mystery.

Note, if I take all the conditions out of setting the text color in OnCustomDraw(), so it should paint subitem text in red no matter what, I still get black. That's the other mystery.

-Mike
GeneralRe: GetItemText returns bad CString &amp; can't change subitem color in CustomDraw Pin
Tomasz Sowinski5-Aug-04 7:39
Tomasz Sowinski5-Aug-04 7:39 
GeneralRe: GetItemText returns bad CString &amp; can't change subitem color in CustomDraw Pin
Mike Landis5-Aug-04 9:10
Mike Landis5-Aug-04 9:10 
GeneralRe: GetItemText returns bad CString &amp; can't change subitem color in CustomDraw Pin
Tomasz Sowinski5-Aug-04 9:27
Tomasz Sowinski5-Aug-04 9:27 
GeneralRe: GetItemText returns bad CString &amp; can't change subitem color in CustomDraw Pin
Mike Landis5-Aug-04 9:57
Mike Landis5-Aug-04 9:57 
GeneralRe: GetItemText returns bad CString &amp; can't change subitem color in CustomDraw Pin
Tomasz Sowinski5-Aug-04 10:14
Tomasz Sowinski5-Aug-04 10:14 
GeneralRe: GetItemText returns bad CString &amp; can't change subitem color in CustomDraw Pin
Mike Landis5-Aug-04 10:49
Mike Landis5-Aug-04 10:49 
GeneralRe: GetItemText returns bad CString &amp; can't change subitem color in CustomDraw Pin
Tomasz Sowinski5-Aug-04 11:03
Tomasz Sowinski5-Aug-04 11:03 
GeneralRe: GetItemText returns bad CString &amp; can't change subitem color in CustomDraw Pin
Tomasz Sowinski6-Aug-04 1:17
Tomasz Sowinski6-Aug-04 1:17 
GeneralRe: GetItemText returns bad CString &amp; can't change subitem color in CustomDraw Pin
Tomasz Sowinski5-Aug-04 2:18
Tomasz Sowinski5-Aug-04 2:18 
Generalthread stack overflow problem.. Pin
TssPrasad4-Aug-04 17:47
sussTssPrasad4-Aug-04 17:47 
GeneralRe: thread stack overflow problem.. Pin
palbano4-Aug-04 18:04
palbano4-Aug-04 18:04 
GeneralRe: thread stack overflow problem.. Pin
TssPrasad4-Aug-04 18:13
sussTssPrasad4-Aug-04 18:13 
GeneralRe: thread stack overflow problem.. Pin
Jijo.Raj4-Aug-04 19:01
Jijo.Raj4-Aug-04 19:01 
GeneralHelp needed!!!! Pin
pundit4-Aug-04 17:47
pundit4-Aug-04 17:47 
GeneralRe: Help needed!!!! Pin
Antti Keskinen4-Aug-04 22:15
Antti Keskinen4-Aug-04 22:15 
QuestionHow to distinguish file from directory ? Pin
Amarelia4-Aug-04 17:23
Amarelia4-Aug-04 17:23 
AnswerRe: How to distinguish file from directory ? Pin
PJ Arends4-Aug-04 17:52
professionalPJ Arends4-Aug-04 17:52 

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.