OnDraw 文字如何重绘 打开提取文本时,文本框不显示文字,但只要手动去拉动放大缩小文本框,就会显示
加了Invalidate()后 就会不断的闪烁 求教~
void CReadboView::OnDraw(CDC* pDC)
{
CReadboDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CRect cr;
// TODO: add draw code for native data here
CString str1;
CMainFrame *ph = (CMainFrame *) AfxGetMainWnd();
CString fileName = ph->filename;
static int i=1;
if(fileName!="")
{
FILE *pFile=fopen(fileName,"r");
//MessageBox("fuck");
GetClientRect( &cr );
int seekf = ( cr.bottom - cr.top ) * ( cr.right - cr.left ) ;
char *pBuf;
fseek(pFile,0,SEEK_END);
int len=ftell(pFile);
if ( len < seekf ) seekf = len;
pBuf=new char[len+1];
rewind(pFile);
fread(pBuf,1,155,pFile);
pBuf[155]=0;
//CString str ;
//str.Format("%d",cr.right);
//MessageBox(str);
//pDC->BeginPath();
// Invalidate(FALSE);
pDC->DrawText(pBuf,CRect(0,0,cr.right,cr.bottom),DT_WORDBREAK );
//pDC->EndPath();
UpdateData(FALSE);
/*((CReadboView)(AfxGetMainWnd()->GetActiveView()))->*/
//UpdateWindow();
// fclose(pFile);
}
}新手一个 可以的话 详细点 谢谢~
加了Invalidate()后 就会不断的闪烁 求教~
void CReadboView::OnDraw(CDC* pDC)
{
CReadboDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CRect cr;
// TODO: add draw code for native data here
CString str1;
CMainFrame *ph = (CMainFrame *) AfxGetMainWnd();
CString fileName = ph->filename;
static int i=1;
if(fileName!="")
{
FILE *pFile=fopen(fileName,"r");
//MessageBox("fuck");
GetClientRect( &cr );
int seekf = ( cr.bottom - cr.top ) * ( cr.right - cr.left ) ;
char *pBuf;
fseek(pFile,0,SEEK_END);
int len=ftell(pFile);
if ( len < seekf ) seekf = len;
pBuf=new char[len+1];
rewind(pFile);
fread(pBuf,1,155,pFile);
pBuf[155]=0;
//CString str ;
//str.Format("%d",cr.right);
//MessageBox(str);
//pDC->BeginPath();
// Invalidate(FALSE);
pDC->DrawText(pBuf,CRect(0,0,cr.right,cr.bottom),DT_WORDBREAK );
//pDC->EndPath();
UpdateData(FALSE);
/*((CReadboView)(AfxGetMainWnd()->GetActiveView()))->*/
//UpdateWindow();
// fclose(pFile);
}
}新手一个 可以的话 详细点 谢谢~
在OnDraw中,执行你的pDC->DrawText(pBuf,CRect(0,0,cr.right,cr.bottom),DT_WORDBREAK );