Skip to content

Commit

Permalink
Fixed compiler errors on VC6
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot committed Oct 8, 2008
1 parent 46ca3d7 commit 289ae5c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
4 changes: 2 additions & 2 deletions CGridListCtrlEx/CGridColumnTraitCombo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void CGridEditorComboBox::EndEdit(bool bSuccess)
if (bSuccess)
{
dispinfo.item.mask = LVIF_TEXT | LVIF_PARAM;
dispinfo.item.pszText = str.GetBuffer();
dispinfo.item.pszText = str.GetBuffer(0);
dispinfo.item.cchTextMax = str.GetLength();
dispinfo.item.lParam = GetItemData(GetCurSel());
}
Expand Down Expand Up @@ -358,4 +358,4 @@ void CGridEditorComboBox::OnCloseUp()
UINT CGridEditorComboBox::OnGetDlgCode()
{
return DLGC_WANTALLKEYS;
}
}
6 changes: 3 additions & 3 deletions CGridListCtrlEx/CGridColumnTraitDateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void CGridEditorDateTimeCtrl::EndEdit(bool bSuccess)
if (m_Format.IsEmpty())
str = dt.Format(m_FormatFlags, m_FormatLCID);
else
str = dt.Format(m_Format.GetString());
str = dt.Format(static_cast<LPCTSTR>(m_Format));

// Send Notification to parent of ListView ctrl
LV_DISPINFO dispinfo = {0};
Expand All @@ -121,7 +121,7 @@ void CGridEditorDateTimeCtrl::EndEdit(bool bSuccess)
if (bSuccess)
{
dispinfo.item.mask = LVIF_TEXT;
dispinfo.item.pszText = str.GetBuffer();
dispinfo.item.pszText = str.GetBuffer(0);
dispinfo.item.cchTextMax = str.GetLength();
}
ShowWindow(SW_HIDE);
Expand Down Expand Up @@ -157,4 +157,4 @@ BOOL CGridEditorDateTimeCtrl::PreTranslateMessage(MSG* pMSG)
case WM_MOUSEWHEEL: EndEdit(true); return FALSE; // Don't steal event
}
return CDateTimeCtrl::PreTranslateMessage(pMSG);
}
}
4 changes: 2 additions & 2 deletions CGridListCtrlEx/CGridColumnTraitEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void CGridEditorText::EndEdit(bool bSuccess)
if (bSuccess)
{
dispinfo.item.mask = LVIF_TEXT;
dispinfo.item.pszText = str.GetBuffer();
dispinfo.item.pszText = str.GetBuffer(0);
dispinfo.item.cchTextMax = str.GetLength();
}
ShowWindow(SW_HIDE);
Expand Down Expand Up @@ -135,4 +135,4 @@ BOOL CGridEditorText::PreTranslateMessage(MSG* pMSG)
case WM_MOUSEWHEEL: EndEdit(true); return FALSE; // Don't steal event
}
return CEdit::PreTranslateMessage(pMSG);
}
}
39 changes: 27 additions & 12 deletions CGridListCtrlEx/CGridListCtrlEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ void CGridListCtrlEx::OnCreateStyle()
EnableToolTips(TRUE);

// Disable the builtin tooltip (if available)
if (GetToolTips()!=NULL && GetToolTips()->m_hWnd!=NULL)
GetToolTips()->Activate(FALSE);
CToolTipCtrl* pToolTipCtrl = (CToolTipCtrl*)CWnd::FromHandle((HWND)::SendMessage(m_hWnd, LVM_GETTOOLTIPS, 0, 0L));
if (pToolTipCtrl!=NULL && pToolTipCtrl->m_hWnd!=NULL)
pToolTipCtrl->Activate(FALSE);
}

int CGridListCtrlEx::OnCreate(LPCREATESTRUCT lpCreateStruct)
Expand Down Expand Up @@ -252,7 +253,7 @@ int CGridListCtrlEx::InsertColumnTrait(int nCol, const CString& columnHeading, i
}
}

int index = InsertColumn(nCol, columnHeading.GetString(), nFormat, nWidth, nSubItem);
int index = InsertColumn(nCol, static_cast<LPCTSTR>(columnHeading), nFormat, nWidth, nSubItem);
if (index != -1)
VERIFY( index == nCol );
else
Expand Down Expand Up @@ -320,8 +321,9 @@ void CGridListCtrlEx::SetCellMargin(double margin)

CListCtrl::SetFont(m_pGridFont);
GetHeaderCtrl()->SetFont(m_pCellFont);
if (GetToolTips()!=NULL && GetToolTips()->m_hWnd!=NULL)
GetToolTips()->SetFont(m_pCellFont);
CToolTipCtrl* pToolTipCtrl = (CToolTipCtrl*)CWnd::FromHandle((HWND)::SendMessage(m_hWnd, LVM_GETTOOLTIPS, 0, 0L));
if (pToolTipCtrl!=NULL && pToolTipCtrl->m_hWnd!=NULL)
pToolTipCtrl->SetFont(m_pCellFont);
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -864,7 +866,7 @@ void CGridListCtrlEx::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
// then just repeat the search
}
else
m_LastSearchString.AppendChar((TCHAR)nChar);
m_LastSearchString.Insert(m_LastSearchString.GetLength()+1, (TCHAR)nChar);

int nRow = GetFocusRow();
if (nRow < 0)
Expand All @@ -884,7 +886,7 @@ void CGridListCtrlEx::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
CString cellText = GetItemText(i, nCol);
if (cellText.GetLength()>=m_LastSearchString.GetLength())
{
cellText.Truncate(m_LastSearchString.GetLength());
cellText = cellText.Left(m_LastSearchString.GetLength());
if (cellText.CompareNoCase(m_LastSearchString)==0)
{
// De-select all other rows
Expand Down Expand Up @@ -932,7 +934,7 @@ BOOL CGridListCtrlEx::OnGetDispInfo(NMHDR* pNMHDR, LRESULT* pResult)
CString result;
if (CallbackCellText(nRow, nCol, result))
{
_tcsncpy(pNMW->item.pszText, result.GetBuffer(), pNMW->item.cchTextMax);
_tcsncpy(pNMW->item.pszText, static_cast<LPCTSTR>(result), pNMW->item.cchTextMax);
}
}

Expand Down Expand Up @@ -978,7 +980,11 @@ bool CGridListCtrlEx::CallbackCellTooltip(int nRow, int nCol, CString& text)
return false;
}

#if defined(_WIN64)
INT_PTR CGridListCtrlEx::OnToolHitTest(CPoint point, TOOLINFO * pTI) const
#else
int CGridListCtrlEx::OnToolHitTest(CPoint point, TOOLINFO * pTI) const
#endif
{
if (!ShowToolTipText(point))
return -1;
Expand Down Expand Up @@ -1021,14 +1027,14 @@ BOOL CGridListCtrlEx::OnToolNeedText(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
#ifndef _UNICODE
if (pNMHDR->code == TTN_NEEDTEXTA)
lstrcpyn(pTTTA->szText, tooltip.GetString(), sizeof(pTTTA->szText));
lstrcpyn(pTTTA->szText, static_cast<LPCTSTR>(tooltip), sizeof(pTTTA->szText));
else
_mbstowcsz(pTTTW->szText, tooltip.GetString(), sizeof(pTTTW->szText));
_mbstowcsz(pTTTW->szText, static_cast<LPCTSTR>(tooltip), sizeof(pTTTW->szText));
#else
if (pNMHDR->code == TTN_NEEDTEXTA)
_wcstombsz(pTTTA->szText, tooltip.GetString(), sizeof(pTTTA->szText));
_wcstombsz(pTTTA->szText, static_cast<LPCTSTR>(tooltip), sizeof(pTTTA->szText));
else
lstrcpyn(pTTTW->szText, tooltip.GetString(), sizeof(pTTTW->szText));
lstrcpyn(pTTTW->szText, static_cast<LPCTSTR>(tooltip), sizeof(pTTTW->szText));
#endif
return TRUE;
}
Expand Down Expand Up @@ -1571,6 +1577,15 @@ namespace {
}
}

// Define does not exist on VC6
#ifndef ListView_SortItemsEx
#ifndef LVM_SORTITEMSEX
#define LVM_SORTITEMSEX (LVM_FIRST + 81)
#endif
#define ListView_SortItemsEx(hwndLV, _pfnCompare, _lPrm) \
(BOOL)SNDMSG((hwndLV), LVM_SORTITEMSEX, (WPARAM)(LPARAM)(_lPrm), (LPARAM)(PFNLVCOMPARE)(_pfnCompare))
#endif

bool CGridListCtrlEx::SortColumn(int columnIndex, bool ascending)
{
// virtual lists cannot be sorted with this method
Expand Down
4 changes: 4 additions & 0 deletions CGridListCtrlEx/CGridListCtrlEx.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ class CGridListCtrlEx : public CListCtrl

//{{AFX_VIRTUAL(CGridListCtrlEx)
virtual void PreSubclassWindow();
#if defined(_WIN64)
virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO * pTI) const;
#else
virtual int OnToolHitTest(CPoint point, TOOLINFO * pTI) const;
#endif
//}}AFX_VIRTUAL

//{{AFX_MSG(CGridListCtrlEx)
Expand Down

0 comments on commit 289ae5c

Please sign in to comment.