将图片和文字顺序打乱插入richtextbox中(winform),如何按照顺序读取出来?中间经过编辑,可能删减过图片,顺序按照最终richtextbox中显示的为准。就像发送彩信那样,读出来的文字和图片是有先后顺序的,而且要注明格式。

解决方案 »

  1.   

    应该要深入到RTF格式里,
    http://www.yinhe.net.cn/html/200608/16/20060816154849.htm
    这个应该对你有帮助。
      

  2.   

    to  Haiwangstar你的例子是往richtextbox里面插入图片的,这个我会
      

  3.   


    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() 
      

  4.   

    直接发richtextbox的Rtf是可以,但是是覆盖,而不能追加