SelectObject 为何失败?该怎么解决

SelectObject 为何失败?
win2000下没有问题,但win98下有问题。开始是好的,滚动条上下拉10秒钟。整个电脑系统的字体都变得面目全非。程序关闭,系统字体就好了。分不足了,愿意现金补足。

问题:CFont*   pOldFont=dc.SelectObject(&font);10秒钟后返回null

class   CSaveDC   {
        public:
              CSaveDC(CDC   &   dc)   {   sdc   =   &dc;   saved   =   dc.SaveDC();   }
              CSaveDC(CDC   *   dc)   {   sdc   =   dc;   saved   =   dc-> SaveDC();   }
              virtual   ~CSaveDC()   {   sdc-> RestoreDC(saved);   }
        protected:
              CDC   *   sdc;
              int   saved;
};

void   CQGrid::OnPaint()
{

CPaintDC   dc(this);   //   device   context   for   painting
                  CSaveDC   sdc(dc);
CRect   rect;
GetClientRect(&rect);
dc.DrawEdge(&rect,EDGE_ETCHED,BF_RECT);
if(TopRowIndex> (RowCount-1))
return;
int   pheight=0;
int   pindex=TopRowIndex;
BottomRowIndex=TopRowIndex;
CPen   pen(PS_SOLID,1,m_GridLineColor);
CPen*   oldpen=dc.SelectObject(&pen);
while(pindex <RowCount   &&   pheight <rect.bottom)
{
int   rowheight=CacuRowHeight(pindex,dc);
      if(pindex==m_CurSelected)
{
CRect   hrect=rect;
        hrect.top=pheight;
//         hrect.bottom=pheight+(cells[pindex][0].m_rect.bottom-cells[pindex][0].m_rect.top+1);
hrect.bottom=pheight+rowheight+2*m_RowMargin;
CBrush   brush;
brush.CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
dc.FillRect(&hrect,&brush);
}

               
int   xwidth=0;
int   xindex=0;
                while(xindex <ColumnCount)
      {
        CRect   m_rect;
m_rect.left=xwidth;
m_rect.top=pheight;
        CRect   rect;
rect.left=xwidth+m_ColumnMargin;
                xwidth=xwidth+ColumnWidth[xindex];
m_rect.right=xwidth;
rect.right=xwidth-m_ColumnMargin;
rect.top=pheight+m_RowMargin;
rect.bottom=pheight+rowheight+m_RowMargin+1;
m_rect.bottom=pheight+rowheight+2*m_RowMargin;
cells[pindex][xindex].m_rect=m_rect;
DrawCell(rect,pindex,xindex,dc);
                xwidth=xwidth+1;
                xindex++;
      }
pheight=pheight+rowheight+2*m_RowMargin;
dc.MoveTo(0,pheight);
dc.LineTo(rect.right,pheight);
pheight+=1;
BottomRowIndex=pindex;
                pindex++;
}
pindex=0;
int   pwidth=0;
        while(pindex <(ColumnCount-1))
{
pwidth=pwidth+ColumnWidth[pindex];
dc.MoveTo(pwidth,0);
dc.LineTo(pwidth,pheight);
pwidth+=1;
                pindex++;
}
      ::DeleteObject(dc.SelectObject(oldpen));