' preview, print and save as for embedded ie-control (semen's code)
' =================================================================
'
' this is a 5th version of "simple displaying and printing of text and
' graphics using ie-control".
'
' but this version is using the elegant super code for webbrowser without
' external dlls by semen matusovski, who i thank very much.
'
' nb: you need to save and use the include file in the
' following post.
'
' semens original code is at this link:
' http://www.powerbasic.com/support/pb...ad.php?t=24065
' semen's code includes preview, through which you can see and modify the
' page setup, print and save as. the latter is particularly interesting
' because you can save the code in the ie-control in various formats
' including the mht-format i.e. in a single file format which includes the
' graphics codes as an integral part of the file. all these features are
' utilized in this version which also provides an open (html, not mht) file option.
'
' this code should work for internet explorer version 4 or higher. however,
' with version 4 printing of enhanced metafile graphics may result in wrong
' colors. this is not a problem with verison 5 or later.
'
' using the ie-control you can display and print text and graphics output
' from your pb-programs in a simple and easy way. this program demonstrates
' how. the formating of the output is made using the standard html-tags.
' the most common of these tags are shown below.
'
' the text output from your program should be presented to the ie-control
' in condensed form as a single text-string with html-tags inserted where
' specific formatting features are needed. by letting your program insert
' the relevant html-tags, you can format your text as you wish. normally
' you would only need to use very few of them. it is important, however,
' that you supply the html-tagged text with a standardized starting and
' ending sequence like those shown in this program.
'
' graphics output from pb programs can be saved in enhanced metafiles, which
' can be inserted anywhere in the output text-string by placing a html
' image tag with an url referring to the graphics file in question. (by the
' way, image files in other formats can also be inserted.)
'
' by clicking the right mouse button you can obtain a shortcut menu (slightly
' different if you click over a picture or over the text) by which you can
' copy to the clipboard or print the content via the printer dialog box.
' version 6 of ie prints the enhanced metafile graphics in correct colors.
'
' good luck!
'
' best regards,
'
' erik christensen -------- [email protected] --------- may 17, 2004
------------------
[this message has been edited by erik christensen (edited may 01, 2005).]
' =================================================================
'
' this is a 5th version of "simple displaying and printing of text and
' graphics using ie-control".
'
' but this version is using the elegant super code for webbrowser without
' external dlls by semen matusovski, who i thank very much.

'
' nb: you need to save and use the include file in the
' following post.
'
' semens original code is at this link:
' http://www.powerbasic.com/support/pb...ad.php?t=24065
' semen's code includes preview, through which you can see and modify the
' page setup, print and save as. the latter is particularly interesting
' because you can save the code in the ie-control in various formats
' including the mht-format i.e. in a single file format which includes the
' graphics codes as an integral part of the file. all these features are
' utilized in this version which also provides an open (html, not mht) file option.
'
' this code should work for internet explorer version 4 or higher. however,
' with version 4 printing of enhanced metafile graphics may result in wrong
' colors. this is not a problem with verison 5 or later.
'
' using the ie-control you can display and print text and graphics output
' from your pb-programs in a simple and easy way. this program demonstrates
' how. the formating of the output is made using the standard html-tags.
' the most common of these tags are shown below.
'
' the text output from your program should be presented to the ie-control
' in condensed form as a single text-string with html-tags inserted where
' specific formatting features are needed. by letting your program insert
' the relevant html-tags, you can format your text as you wish. normally
' you would only need to use very few of them. it is important, however,
' that you supply the html-tagged text with a standardized starting and
' ending sequence like those shown in this program.
'
' graphics output from pb programs can be saved in enhanced metafiles, which
' can be inserted anywhere in the output text-string by placing a html
' image tag with an url referring to the graphics file in question. (by the
' way, image files in other formats can also be inserted.)
'
' by clicking the right mouse button you can obtain a shortcut menu (slightly
' different if you click over a picture or over the text) by which you can
' copy to the clipboard or print the content via the printer dialog box.
' version 6 of ie prints the enhanced metafile graphics in correct colors.
'
' good luck!

'
' best regards,
'
' erik christensen -------- [email protected] --------- may 17, 2004
Code:
'**************************************************************************** ' some common html-tags: '**************************************************************************** ' basic elements ' document type <html></html> (beginning and end of file) ' title <title></title> (must be in header) ' header <head></head> (descriptive info, such as title) ' body <body></body> (bulk of the page) ' ' structural definition ' heading <h?></h?> (the spec. defines 6 levels) ' align heading <h? align=left|center|right></h?> ' code <code></code> (for source code listings) ' large font size <big></big> ' small font size <small></small> ' ' presentation formatting ' bold <b></b> ' italic <i></i> ' underline <u></u> ' subscript <sub></sub> ' superscript <sup></sup> ' preformatted <pre></pre> (display text spacing as-is) ' center <center></center> (for both text and images) ' font size <font size=?></font> (ranges from 1-7) ' change font size <font size="+|-?"></font> ' font color <font color="#$$$$$$"></font> (order is red/green/blue) ' select font <font face="***"></font> ' point size <font point-size=?></font> ' weight <font weight=?></font> ' base font size <basefont size=?> (from 1-7; default is 3) ' marquee <marquee></marquee> ' ' positioning ' spacer <spacer> ' size <spacer size=?> ' ' graphics ' display image <img src="url"> ' alignment <img src="url" align=top|bottom|middle|left|right> ' alignment <img src="url" align=texttop|absmiddle|baseline|absbottom> ' dimensions <img src="url" width=? height=?> (in pixels) ' <img src="url" width=% height=%> (as percentage of page width/height) ' border <img src="url" border=?> (in pixels) ' runaround space <img src="url" hspace=? vspace=?> (in pixels) ' embed object <embed src="url"> (insert object into page) ' object size <embed src="url" width=? height=?> ' ' dividers ' paragraph <p></p> (closing tag often unnecessary) ' align text <p align=left|center|right></p> ' justify text <p align=justify></p> ' line break <br> (a single carriage return) ' clear textwrap <br clear=left|right|all> ' no break <nobr></nobr> (prevents line breaks) ' word break <wbr> (where to break a line if needed) ' ' backgrounds and colors ' tiled bkground <body background="url"> ' watermark <body bgproperties="fixed"> ' bkground color <body bgcolor="#$$$$$$"> (order is red/green/blue) ' text color <body text="#$$$$$$"> ' ' miscellaneous ' url of this file <base href="url"> (must be in header) ' base window name <base target="***"> (must be in header) ' '**************************************************************************** #compile exe #register none #dim all ' #include "win32api.inc" #include "comdlg32.inc" #include "comobj2.inc" ' %idd_form1_labelcomboutput = 100 %idd_form1_labelrawtext = 105 %idd_form1_labelgraphic1 = 110 %idd_form1_labelhtmltext = 115 %idd_form1_labelgraphwindow = 120 %idd_form1_butmakeoutput = 125 %idd_form1_butdisplcomboutp = 130 %idd_form1_buttonexit = 140 %idd_form1_texthtml = 145 %idd_form1_textraw = 150 %idd_form1_butprevfig = 155 %idd_form1_butnextfig = 160 %idd_form1_butpreview = 165 %idd_form1_butprint = 170 %idd_form1_butsaveas = 175 %idd_form1_butopenfile = 180 %id_ie1 = 185 ' global hform1 as dword global gerror as long ' stores the error variable global curgrano as long global totalgrano as long global currentpath as string global th$, tt$ ' th is for html-tagged text, tt is for plain text. global outmade& global memdc as long global hiect as dword global h&,w& ' %wm_forwardmsg = &h37f ' (895) ' '*************************************************************************** '*************************************************************************** ' function a(byval x1 as long) as long function = x1 * w / 396 end function ' function b(byval y1 as long) as long function = y1 * h / 280 end function ' function gcolor(byval i as long) as long select case i ' common rgb colors: case 0 : function = &h000000??? '%black - same as rgb(0,0,0) case 1 : function = &hff0000??? '%blue case 2 : function = &h00ff00??? '%green case 3 : function = &hffff00??? '%cyan case 4 : function = &h0000ff??? '%red case 5 : function = &hff00ff??? '%magenta case 6 : function = &h00ffff??? '%yellow case 7 : function = &hffffff??? '%white - same as rgb(255,255,255) case 8 : function = &h808080??? '%gray case 9 : function = &hc0c0c0??? '%ltgray ' additional colors can be added e.g. using the rgb function, ' e.g. case 10: function = rgb(164,164,164) ' and so on. case else : function = &h000000??? '%black end select end function ' ------------------------------------------------ function penstyle(byval i as long) as long select case i case 0 : function = %ps_solid ' _______ case 1 : function = %ps_dash ' ------- case 2 : function = %ps_dot ' ....... case 3 : function = %ps_dashdot ' _._._._ case 4 : function = %ps_dashdotdot ' _.._.._ case else: function = %ps_solid end select end function ' ------------------------------------------------ function makefont(byval fonttypesize as long,byval fontweight as long, _ byval italic as long, byval underline as long,byval strikeout as long, _ byval facename as string) as long local lffont as logfont ' logfont structure local hdc&,logpixelsy& hdc = getdc(%hwnd_desktop) 'retrieves device-specific information about the number 'of pixels per logical inch along the screen height '(depends on screen resolution setting). 'this is important to define appropriate font sizes. logpixelsy = getdevicecaps(hdc, %logpixelsy) releasedc %hwnd_desktop, hdc 'type logfont defines the attributes of a font. 'see logfont in the win32 help file lffont.lfheight = -muldiv(fonttypesize,logpixelsy,72) ' better than: -(fonttypesize * logpixelsy) \ 72 ' logical height of font lffont.lfwidth = 0 ' logical average character width lffont.lfescapement = 0 ' angle of escapement lffont.lforientation = 0 ' base-line orientation angle lffont.lfweight = fontweight ' font weight lffont.lfitalic = italic ' italic attribute flag (0,1) lffont.lfunderline = underline ' underline attribute flag (0,1) lffont.lfstrikeout = strikeout ' strikeout attribute flag (0,1) lffont.lfcharset = %ansi_charset ' character set identifier lffont.lfoutprecision = %out_tt_precis ' output precision lffont.lfclipprecision = %clip_default_precis ' clipping precision lffont.lfquality = %default_quality ' output quality lffont.lfpitchandfamily = %ff_dontcare ' pitch and family lffont.lffacename = facename ' typeface name string ' make font according to specifications function = createfontindirect (lffont) end function ' ------------------------------------------------ sub makegraph(byval hdc as long,rct as rect,byref da() as single, _ byref gtext() as string, byval nm as long) local hpen as long local gtex as asciiz * 200 local i as long local total as single local cumul as single local pi2 as single local pct as long, radius as long local recstart as long local rc as rect local hfont as long local xleft as long, ytop as long, xright as long, ybottom as long local xstart as long, ystart as long, xend as long, yend as long local xtext as long, ytext as long, korr as long local x1&,y1&, hbrush& x1&=rct.nright y1&=rct.nbottom fillrect hdc, rct, getstockobject(%white_brush) radius = y1&/3.6 xleft = x1&/2 - radius : xright = x1&/2 + radius ytop = y1&/2 - radius : ybottom = y1&/2 + radius total=0! : for i=1 to nm : total = total + da(i) : next local tc$ : tc$ = " for i=1 to nm tc = tc + left$(gtext(i)+space$(12),13)+using$("######.## ##.##%",da(i),da(i)*100!/total)+$crlf next tc = tc + $crlf tt = tt + tc : th = th + tc ' hfont = makefont(7,400,0,0,0,"arial") : selectobject hdc, hfont ' pi2=8!*atn(1#) : cumul=0! korr=-9 ' empiric correction for height of characters. this may be improved. for i=1 to nm cumul = cumul + da(i) : pct=fix(100*da(i)/total+0.5) xtext = int(x1&/2+(radius-korr)*cos(pi2 * (cumul - da(i)/2) / total)+0.5) ytext = int(y1&/2-(radius-korr)*sin(pi2 * (cumul - da(i)/2) / total)+0.5) if cos(pi2 * (cumul - da(i)/2) / total) >= 0 then settextalign hdc,%ta_left ' text on right side of diagram else settextalign hdc,%ta_right ' text on left side of diagram end if gtex=gtext(i)+" ("+ltrim$(str$(pct))+"%)" textout hdc, xtext, ytext+korr, gtex, byval len(gtex) next deleteobject hfont ' xstart=x1&/2+radius: ystart=y1&/2 ' select starting point for pie pieces cumul=0! for i=1 to nm cumul = cumul + da(i) xend = int(x1&/2+radius*cos(pi2 * cumul / total)+0.5) yend = int(y1&/2-radius*sin(pi2 * cumul / total)+0.5) hpen = createpen(penstyle(0), 0, gcolor(i)) : selectobject hdc, hpen hbrush = createsolidbrush(gcolor(i)) : selectobject hdc, hbrush pie hdc, xleft,ytop,xright,ybottom, xstart, ystart, xend, yend deleteobject hpen : deleteobject hbrush xstart=xend: ystart=yend next end sub ' sub showenhmetafile local hemf&,hgr1&,hdc&,rc as rect hemf = getenhmetafile(bycopy currentpath+"demonstration_figure"+trim$(str$(curgrano))+".emf" ) hgr1& = getdlgitem(hform1, %idd_form1_labelgraphwindow) getclientrect hgr1, rc hdc = getdc(hgr1) call playenhmetafile (hdc, hemf, rc) ' copy graphics onto virtual window. bitblt memdc,0,0, rc.nright, rc.nbottom, hdc,0,0,%srccopy deleteenhmetafile hemf releasedc hgr1, hdc control set text hform1, %idd_form1_labelgraphic1, "figure"+str$(curgrano) end sub ' function openhtmfile as long dim pwebbrowserdata as local webbrowserdata ptr pwebbrowserdata = strptr(szwebbrowserdata) local path as string local f as string local style as dword local x&, ttt$ path = curdir$ f = "*.html;*htm" style = %ofn_filemustexist or %ofn_hidereadonly or %ofn_longnames if openfiledialog(0, "open html/htm file", f, path, _ "html/htm files|*.html;*.htm|all files|*.*", "html", style) then x& = freefile open f for binary as #x& get$ #x&, lof(x&), ttt$ close #x& displayhtmlstring 1, ttt$ control enable hform1, %idd_form1_butpreview control enable hform1, %idd_form1_butprint control enable hform1, %idd_form1_butsaveas function = 1 end if end function callback function form1_dlgproc ' dim pwebbrowserdata as local webbrowserdata ptr local hdc&, rc as rect local x&, ttt$ local ps as paintstruct, hgr& ' select case cbmsg case %wm_paint hgr = getdlgitem(cbhndl, %idd_form1_labelgraphwindow) hdc = beginpaint(hgr, ps) getclientrect hgr, rc ' copy virtual window onto screen: bitblt hdc,0,0, rc.nright, rc.nbottom, memdc,0,0,%srccopy endpaint hgr, ps case %wm_destroy postquitmessage 0 case %wm_command pwebbrowserdata = strptr(szwebbrowserdata) select case cbctl case %idd_form1_butopenfile if cbctlmsg = %bn_clicked or cbctlmsg = 1 then if openhtmfile then end if end if case %idd_form1_butmakeoutput if cbctlmsg = %bn_clicked or cbctlmsg = 1 then call makeoutput end if case %idd_form1_butdisplcomboutp if cbctlmsg = %bn_clicked or cbctlmsg = 1 then x& = freefile open currentpath+"iecontrdemon5.html" for binary as #x& get$ #x&, lof(x&), ttt$ close #x& displayhtmlstring 1, ttt$ control enable hform1, %idd_form1_butpreview control enable hform1, %idd_form1_butprint control enable hform1, %idd_form1_butsaveas end if case %idd_form1_butpreview ' if cbctlmsg = %bn_clicked or cbctlmsg = 1 then call dword @pwebbrowserdata[0].@[email protected] using comfunction4 (byval @pwebbrowserdata[0].piwebbrowser2, byval %olecmdid_printpreview, byval 0, byval 0, byval 0) end if case %idd_form1_butprint if cbctlmsg = %bn_clicked or cbctlmsg = 1 then call dword @pwebbrowserdata[0].@piwebbrowser2[email protected] using comfunction4 (byval @pwebbrowserdata[0].piwebbrowser2, byval %olecmdid_print, byval 0, byval 0, byval 0) end if case %idd_form1_butsaveas if cbctlmsg = %bn_clicked or cbctlmsg = 1 then call dword @pwebbrowserdata[0].@[email protected] using comfunction4 (byval @pwebbrowserdata[0].piwebbrowser2, byval %olecmdid_saveas, byval 0, byval 0, byval 0) end if case %idd_form1_butnextfig if cbctlmsg=%bn_clicked or cbctlmsg = 1 then incr curgrano if curgrano > totalgrano then curgrano = totalgrano : exit if call showenhmetafile end if if curgrano > 1 then control enable hform1, %idd_form1_butprevfig if curgrano = totalgrano then control disable hform1, %idd_form1_butnextfig control set focus hform1, %idd_form1_butprevfig end if ' case %idd_form1_butprevfig if cbctlmsg=%bn_clicked or cbctlmsg = 1 then decr curgrano if curgrano < 1 then curgrano = 1 : exit if call showenhmetafile end if if curgrano < totalgrano then control enable hform1, %idd_form1_butnextfig if curgrano = 1 then control disable hform1, %idd_form1_butprevfig control set focus hform1, %idd_form1_butnextfig end if case %idd_form1_buttonexit if cbctlmsg = %bn_clicked or cbctlmsg = 1 then dialog end cbhndl, 0 end if case else end select case else end select end function ' function graphics(byval no as long,byref da() as single, _ byref gtext() as string, byval nm as long) as string local rct as rect, hgr1& static hdcref&,iwidthmm&,iheightmm&,iwidthpels&,iheightpels& local hdcemf&, hemf&, hdc&, i&, kk& local curpath as asciiz * 255, st$, pathandfile$, res& ' get handle to graphics window hgr1& = getdlgitem(hform1, %idd_form1_labelgraphwindow) ' if no = 1 then ' do this only the first time and remember results. ' obtain a handle to a reference device context. hdcref = getdc(hform1) ' ' determine the full display dimensions. ' iwidthmm is the display width in millimeters. ' iheightmm is the display height in millimeters. ' iwidthpels is the display width in pixels. ' iheightpels is the display height in pixels iwidthmm = getdevicecaps(hdcref, %horzsize) iheightmm = getdevicecaps(hdcref, %vertsize) iwidthpels = getdevicecaps(hdcref, %horzres) iheightpels = getdevicecaps(hdcref, %vertres) ' releasedc hform1, hdcref end if ' ' specify rectancle in 0.01 mm units for creation of metafile: ' ' retrieve the coordinates of the client rectangle, in pixels. getclientrect hgr1,rct ' convert client coordinates to .01-mm units. ' use iwidthmm, iwidthpels, iheightmm, and ' iheightpels to determine the number of ' .01-millimeter units per pixel in the x- and y-directions. rct.nleft = (rct.nleft * iwidthmm * 100)/iwidthpels rct.ntop = (rct.ntop * iheightmm * 100)/iheightpels rct.nright = (rct.nright * iwidthmm * 100)/iwidthpels rct.nbottom = (rct.nbottom * iheightmm * 100)/iheightpels ' ' create enhanced metafile hdcemf = createenhmetafile (%null, byval %null, rct, byval %null) ' get rectangle in pixels to display diagram getclientrect hgr1, rct call makegraph(hdcemf,rct,da(),gtext(),nm) hemf = closeenhmetafile (hdcemf) ' get handle to enhanced metafile ' if no = 1 then : curgrano = 1 : call showenhmetafile ' display first figure ' getmodulefilename getmodulehandle("), curpath, 255 'get current path & exe ' st$=curpath ' currentpath=left$(st$,instr(-1, st$, any ":\/")) pathandfile$=currentpath+"demonstration_figure"+trim$(str$(no))+".emf" ' res& = copyenhmetafile(hemf,bycopy pathandfile$) ' save to disk deleteenhmetafile hemf function = pathandfile$ end function ' sub makeoutput local i&, kk&, no&, graphfile$, txt$ dim da(5) as single, gtext(5) as string, su(5) as single ' ' th is the html text string to be used for the ie control ' *************************** ' first the html text header: ' *************************** th = "<html>"+$crlf ' start of html-document th = th +"<head>"+$crlf ' start of header th = th +"<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">"+$crlf ' technical specification txt = "ie display and print demonstration" ' title text th = th +"<title>"+txt+"</title>"+$crlf ' title th = th +"</head>"+$crlf ' end of header th = th +"<body>"+$crlf ' start of body of content th = th +"<pre>"+$crlf ' preformatted text th = th +"<font face="courier new" color="#0000ff">"+$crlf ' font type and color ' font color ' **************************** ' ' tt is the plain text for a textbox tt = txt + $crlf + $crlf ' th = th + txt + $crlf + $crlf ' kk = 0 ' data are completely imaginary ' they are only for illustration data food, house, clothes, leisure, travel for i=1 to 5 : incr kk : gtext(kk)=read$(kk) : next ' data 452.92, 665.40, 87.76, 186.54 ' expenses period 1 for i=1 to 4 : incr kk : da(i) = val(read$(kk)) : su(i) = su(i) + da(i) : next no = 1 tt = tt + " period"+str$(no)+$crlf th = th + " <b><i><u>period"+str$(no)+"</b></i></u>"+$crlf curgrano = 1 graphfile$ = graphics(no, da(), gtext(), 4) ' include this graph in the html-tagged text file. tt = tt + " figure"+str$(no)+$crlf+$crlf th = th + " figure"+str$(no) th = th + $crlf + "<img src=""+graphfile$+"">" + $crlf + $crlf ' data 438.39, 666.24, 130.65, 230.54 ' expenses period 2 for i=1 to 4 : incr kk : da(i) = val(read$(kk)) : su(i) = su(i) + da(i) : next incr no tt = tt + " period"+str$(no)+$crlf th = th + " <b><i><u>period"+str$(no)+"</b></i></u>"+$crlf graphfile$ = graphics(no, da(), gtext(), 4) ' include this graph in the html-tagged text file. tt = tt + " figure"+str$(no)+$crlf+$crlf th = th + " figure"+str$(no) th = th + $crlf + "<img src=""+graphfile$+"">" + $crlf + $crlf ' data 410.67, 766.56, 200.65, 250.23, 698.54 ' expenses period 3 for i=1 to 5 : incr kk : da(i) = val(read$(kk)) : su(i) = su(i) + da(i) : next incr no tt = tt + " period"+str$(no)+$crlf th = th + " <b><i><u>period"+str$(no)+"</b></i></u>"+$crlf graphfile$ = graphics(no, da(), gtext(), 5) ' include this graph in the html-tagged text file. tt = tt + " figure"+str$(no)+$crlf+$crlf th = th + " figure"+str$(no) th = th + $crlf + "<img src=""+graphfile$+"">" + $crlf + $crlf ' data 502.37, 685.23, 41.65, 146.87 ' expenses period 4 for i=1 to 4 : incr kk : da(i) = val(read$(kk)) : su(i) = su(i) + da(i) : next incr no tt = tt + " period"+str$(no)+$crlf th = th + " <b><i><u>period"+str$(no)+"</b></i></u>"+$crlf graphfile$ = graphics(no, da(), gtext(), 4) ' include this graph in the html-tagged text file. tt = tt + " figure"+str$(no)+$crlf+$crlf th = th + " figure"+str$(no) th = th + $crlf + "<img src=""+graphfile$+"">" + $crlf + $crlf ' local total! for i = 1 to 5 : total = total + su(i) : next incr no tt = tt + " results for all 4 periods"+$crlf th = th + " <b><i><u>results for all 4 periods</b></i></u>"+$crlf graphfile$ = graphics(no, su(), gtext(), 5) ' include this graph in the html-tagged text file. tt = tt + " figure"+str$(no)+$crlf+$crlf th = th + " figure"+str$(no) th = th + $crlf + "<img src=""+graphfile$+"">" + $crlf + $crlf ' tt = tt + " - - - - -"+$crlf th = th + " - - - - -"+$crlf ' ********************** ' end tags of html text: ' ********************** th = th +"</font>"+$crlf th = th +"</pre>"+$crlf th = th +"</body>"+$crlf th = th +"</html>"+$crlf ' *************************** ' totalgrano = no control set text hform1, %idd_form1_texthtml, th control set text hform1, %idd_form1_textraw, tt ' ' save html-string as a html-file local x& : x& = freefile open currentpath+"iecontrdemon5.html" for binary as #x& put$ #x&, th seteof #x& ' important if you use the same file name repeatedly with varying ourput. close #x& ' control disable hform1, %idd_form1_butprevfig control enable hform1, %idd_form1_butnextfig control enable hform1, %idd_form1_butdisplcomboutp outmade& = %true ' output flag set to true end sub ' ------------------------------------------------ function pbmain local umsg as tagmsg dim pwebbrowserdata as local webbrowserdata ptr local hdc&, hbit&, rc as rect local style&, exstyle&, x1&, y1&, x2&, y2& ' systemparametersinfo %spi_getworkarea,byval %null, byval varptr(rc),byval %null style& = %ws_popup or %ds_modalframe or %ws_caption or %ws_minimizebox or %ws_sysmenu or %ds_center or %ws_clipchildren exstyle& = 0 dialog new 0, "simple displaying and printing of text and graphics using the ie-control - vers. 5", 0, 0, 396, 264, style&, exstyle& to hform1 dialog pixels hform1, rc.nleft, rc.ntop to units x1, y1 dialog pixels hform1, rc.nright, rc.nbottom to units x2, y2 dialog set loc hform1, x1, y1 w = x2 - x1 : h = y2 - y1 dialog set size hform1, w, h control add button, hform1, %idd_form1_butopenfile, "&open", a(6), b(246), a(30), b(14), _ %ws_child or %ws_visible or %bs_pushbutton or %ws_tabstop control add button, hform1, %idd_form1_butmakeoutput, "&make output", a(42), b(246), a(56), b(14), _ %ws_child or %ws_visible or %bs_pushbutton or %ws_tabstop control add button, hform1, %idd_form1_butdisplcomboutp, "&show combined output", a(104), b(246), a(92), b(14), _ %ws_child or %ws_visible or %bs_pushbutton or %ws_tabstop or %ws_disabled control add button, hform1, %idd_form1_buttonexit, "e&xit", a(362), b(246), a(26), b(14), _ %ws_child or %ws_visible or %bs_pushbutton or %ws_tabstop control add label, hform1, %idd_form1_labelcomboutput, "combined text and graphics in ie-control", a(206), b(110), a(182), b(10), _ %ws_child or %ws_visible or %ss_center control add label, hform1, %idd_form1_labelrawtext, "plain text output", a(6), b(4), a(190), b(10), _ %ws_child or %ws_visible or %ss_center control add label, hform1, %idd_form1_labelgraphic1, ", a(196), b(28), a(42), b(10), _ %ws_child or %ws_visible or %ss_center control add label, hform1, %idd_form1_labelhtmltext, "text output with html-tags", a(6), b(122), a(190), b(10), _ %ws_child or %ws_visible or %ss_center control add label, hform1, %idd_form1_labelgraphwindow, ", a(238), b(6), a(150), b(98), _ %ws_child or %ws_visible or %ws_border or %ss_whiteframe control add textbox, hform1, %idd_form1_texthtml, ", a(6), b(132), a(190), b(104), _ %ws_child or %ws_visible or %es_readonly or %es_left or %ws_hscroll or %ws_vscroll or %ws_tabstop or %es_multiline, %ws_ex_clientedge control send hform1,%idd_form1_texthtml,%wm_setfont,getstockobject(%ansi_fixed_font),%true control add textbox, hform1, %idd_form1_textraw, ", a(6), b(14), a(190), b(104),_ %ws_child or %ws_visible or %es_readonly or %es_left or %ws_hscroll or %ws_vscroll or %ws_tabstop or %es_multiline, %ws_ex_clientedge control send hform1,%idd_form1_textraw,%wm_setfont,getstockobject(%ansi_fixed_font),%true control add button, hform1, %idd_form1_butprevfig, "&prev.", a(200), b(42), a(34), b(14), _ %ws_child or %ws_visible or %bs_pushbutton or %ws_tabstop or %ws_disabled control add button, hform1, %idd_form1_butnextfig, "&next", a(200), b(62), a(34), b(14), _ %ws_child or %ws_visible or %bs_pushbutton or %ws_tabstop or %ws_disabled control add button, hform1, %idd_form1_butpreview, "pre&view", a(208), b(246), a(44), b(14), _ %ws_child or %ws_visible or %bs_pushbutton or %ws_tabstop or %ws_disabled control add button, hform1, %idd_form1_butprint, "&print", a(258), b(246), a(42), b(14), _ %ws_child or %ws_visible or %bs_pushbutton or %ws_tabstop or %ws_disabled control add button, hform1, %idd_form1_butsaveas, "save &as", a(306), b(246), a(44), b(14), _ %ws_child or %ws_visible or %bs_pushbutton or %ws_tabstop or %ws_disabled control set color hform1,%idd_form1_labelgraphwindow ,0,rgb(255,255,255) control set color hform1,%idd_form1_textraw ,0,rgb(255,255,255) control set color hform1,%idd_form1_texthtml ,0,rgb(255,255,255) ' control add label, hform1, %id_ie1, ", a(206), b(120), a(182), b(116), %ws_visible or %ws_child control handle hform1, %id_ie1 to hiect ' embed, resize and initialize ie-browser: if embedbrowserobject (1, hform1, %id_ie1) then dialog post hform1, %wm_syscommand, %sc_close, 0 : exit function end if getclientrect getdlgitem(hform1, %id_ie1), rc resizebrowser 1, rc.nright, rc.nbottom displayhtmlstring 1, " ' "initialize" ' ' create a virtual window getclientrect getdlgitem(hform1, %idd_form1_labelgraphwindow), rc hdc = getdc(getdlgitem(hform1, %idd_form1_labelgraphwindow)) memdc = createcompatibledc(hdc) hbit = createcompatiblebitmap(hdc, rc.nright, rc.nbottom) selectobject memdc, hbit selectobject memdc, getstockobject(%white_brush) patblt memdc, 0, 0, rc.nright, rc.nbottom, %patcopy ' outmade& = %false ' start with output flag set to false. ' dialog show modeless hform1, call form1_dlgproc ' while getmessage(umsg, %null, 0, 0) ' pass keyboard messages to the ancestor ' returns 0 if the message was not processed, nonzero if it was if sendmessage(hiect, %wm_forwardmsg, 0, varptr(umsg)) = 0 then if isdialogmessage(hform1, umsg) = %false then translatemessage umsg dispatchmessage umsg end if end if wend ' deletedc memdc deleteobject hbit unembedbrowserobject 1 ' end function
[this message has been edited by erik christensen (edited may 01, 2005).]
Comment