您的位置:程序门 -> .net技术 -> c#



如何读取richtextbox中的图片和文字


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


如何读取richtextbox中的图片和文字
发表于:2008-01-22 16:42:57 楼主

将图片和文字顺序打乱插入richtextbox中(winform),如何按照顺序读取出来?

中间经过编辑,可能删减过图片,顺序按照最终richtextbox中显示的为准。

就像发送彩信那样,读出来的文字和图片是有先后顺序的,而且要注明格式。
发表于:2008-01-22 16:49:351楼 得分:0
mark
发表于:2008-01-22 17:20:382楼 得分:0
应该要深入到rtf格式里,
http://www.yinhe.net.cn/html/200608/16/20060816154849.htm
这个应该对你有帮助。
发表于:2008-01-22 21:06:383楼 得分:0
to     haiwangstar

你的例子是往richtextbox里面插入图片的,这个我会
发表于:2008-01-22 21:19:364楼 得分:0
c/c++ code
void wmftobmp(int width,int height,char *metafile)   {   //width为图片宽度,height为图片高度,*metafile为元文件名   static hmetafile hmf;   char num[4];   file *fh;   hdc hmemdc;   hbitmap hbmp,hold;   bitmapfileheader hdr;   lpbitmapinfoheader lpbmpih;   hglobal hg;      bitmapcount++;   if(bitmapcount==3)   {   width=128;   height=132;   }   if(bitmapcount==1)   {   width=80;   height=50;   }   tostring10(bitmapcount,num);   //把字符串转换成数字的函数   lstrcpy(bmpfile,filepath);   lstrcat(bmpfile,num);   lstrcpy(giffile,bmpfile);   lstrcat(bmpfile,".bmp");   lstrcat(giffile,".gif");   hmf=getmetafile(metafile);   hdisplaydc=createdc("display",null,null,null);   hmemdc=createcompatibledc(hdisplaydc);   hg=globalalloc(ghnd,sizeof(bitmapinfoheader));   lpbmpih=(lpbitmapinfoheader)globallock(hg);   lpbmpih->bisize=sizeof(bitmapinfoheader);   lpbmpih->biwidth=width;   lpbmpih->biheight=height;   lpbmpih->biplanes=1;   lpbmpih->bibitcount=8;   lpbmpih->bicompression=0;   hbmp=createcompatiblebitmap(hdisplaydc,width,height);   globalunlock(hg);   globalfree(hg);   hold=selectobject(hmemdc,hbmp);   setmapmode(hmemdc,mm_anisotropic);   setwindoworgex(hmemdc,0,0,null);   setviewportextex(hmemdc,width,height,null);   playmetafile(hmemdc,hmf);   hbmp=selectobject(hmemdc,hold);   if((fh=fopen(bmpfile,"w+b"))==null)   {   return;   }   hdr.bftype=0x4d42;   hdr.bfsize=sizeof(bitmapfileheader)+sizeof(bitmapinfoheader)+256*sizeof(rgbquad)+width*height;   hdr.bfreserved1=0;   hdr.bfreserved2=0;   hdr.bfoffbits=sizeof(bitmapfileheader)+sizeof(bitmapinfoheader)+256*sizeof(rgbquad);   fwrite((lpstr)&hdr,sizeof(bitmapfileheader),1,fh);   hg=globalalloc(ghnd,sizeof(bitmapinfoheader)+256*sizeof(rgbquad));   lpbmpih=(lpbitmapinfoheader)globallock(hg);   lpbmpih->bisize=sizeof(bitmapinfoheader);   lpbmpih->biwidth=width;   lpbmpih->biheight=height;   lpbmpih->biplanes=1;   lpbmpih->bibitcount=8;   lpbmpih->bicompression=0;   lpbmpih->bisizeimage=width*height;   lpbmpih->biclrused=256;   lpbmpih->biclrimportant=0;   j=getdibits(hmemdc,hbmp,0,height,null,(bitmapinfo*)lpbmpih,dib_rgb_colors);   lpbmpih->bisize=sizeof(bitmapinfoheader);   fwrite(lpbmpih,sizeof(bitmapinfoheader)+256*sizeof(rgbquad),1,fh);   getdibits(hmemdc,hbmp,0,height,(lpstr)filebuffer,(bitmapinfo*)lpbmpih,dib_rgb_cols);   fwrite(filebuffer,width*height,1,fh);   globalunlock(hg);   globalfree(hg);   fclose(fh);   deletedc(hmemdc);   deletedc(hdisplaydc);   deleteobject(hbmp);   deleteobject(hold);   deletemetafile(hmf);   }//end function wmftobmp()
发表于:2008-01-22 21:28:525楼 得分:0
mark帮顶一下
发表于:2008-01-23 16:12:356楼 得分:0
谢谢两颗红心的热忱。
继续等待最佳答案。


快速检索

最新资讯
热门点击