RichEdit的内容同步更新到Image上,发现慢一个字
我在RichEdit的Onchange事件中,有如下代码,目的是RichEdit输入什么,能同步的更新到Image上。运行以上代码以后,发现Image的显示比RichEdit上慢一些,不知如何解决了
BitBlt(Image1->Canvas->Handle, 0,0, RichEdit1->Width, RichEdit1->Height, GetDC(RichEdit1->Handle), 0,0, SRCCOPY); ReleaseDC(RichEdit1->Handle, GetDC(RichEdit1->Handle)); Image1->Refresh();
void __fastcall TForm2::RichEdit1Change(TObject *Sender){// Image1->Canvas->TextOutA(0,0,RichEdit1->Text);//RichEdit1->Refresh(); //加这一句或下面都可以 就好了RichEdit1->Repaint();BitBlt(Image1->Canvas->Handle, 0,0, RichEdit1->Width, RichEdit1->Height, GetDC(RichEdit1->Handle), 0,0, SRCCOPY); ReleaseDC(RichEdit1->Handle, GetDC(RichEdit1->Handle)); Image1->Refresh();}
[解决办法]
你在事件中不停的GetDC和ReleaseDC,效率不高。
[解决办法]
截获RichEdit的WM_PAINT,画到Image
[解决办法]
RichEdit1Change里加这句还慢?
//RichEdit1->Refresh(); //加这一句或下面都可以 就好了
RichEdit1->Repaint();