如何读取richtextbox中的图片和文字 将图片和文字顺序打乱插入richtextbox中(winform),如何按照顺序读取出来?中间经过编辑,可能删减过图片,顺序按照最终richtextbox中显示的为准。就像发送彩信那样,读出来的文字和图片是有先后顺序的,而且要注明格式。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 应该要深入到RTF格式里,http://www.yinhe.net.cn/html/200608/16/20060816154849.htm这个应该对你有帮助。 to Haiwangstar你的例子是往richtextbox里面插入图片的,这个我会 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() 直接发richtextbox的Rtf是可以,但是是覆盖,而不能追加 C#备份SQL数据库 C# 在Windows或WPF应用程序中,如何打开IE 浏览器指定页面 并找到某个TextBox 录入信息。 新手求助!关于C#程序打包的问题! 如何用C#在 Pocket PC 里读取主人信息呢? VS2008会影响IE? C#编写的Winform程序将数据存入数据库时报错。 用VS.net做安装部署程序时,如何设置系统环境变量,如PATH? 关于C#中无法建立ASP.NET应用程序的问题 一个傻问题:怎样随机生成1-100的序列(乱序的) C#將數據輸出為Excel問題 WINFORM如何获取当前文件的绝对路径?
http://www.yinhe.net.cn/html/200608/16/20060816154849.htm
这个应该对你有帮助。
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()