此接口我们使用m_piResponse->BinaryWrite(vReturnBuffer);将读入内存的图像数据转发给用户浏览器。另外,为了灵活地改变图像字体,大小,字符集及图像长宽等,我们要为组件添加以下属性。STDMETHOD(get_bAutoHeighten)(/*[out, retval]*/ BOOL *pVal);
STDMETHOD(put_bAutoHeighten)(/*[in]*/ BOOL newVal);
STDMETHOD(get_l3D)(/*[out, retval]*/ long *pVal);
STDMETHOD(put_l3D)(/*[in]*/ long newVal);
STDMETHOD(get_lWeight)(/*[out, retval]*/ long *pVal);
STDMETHOD(put_lWeight)(/*[in]*/ long newVal);
STDMETHOD(get_lTop)(/*[out, retval]*/ long *pVal);
STDMETHOD(put_lTop)(/*[in]*/ long newVal);
STDMETHOD(get_lLeft)(/*[out, retval]*/ long *pVal);
STDMETHOD(put_lLeft)(/*[in]*/ long newVal);
STDMETHOD(get_lCSet)(/*[out, retval]*/ long *pVal);
STDMETHOD(put_lCSet)(/*[in]*/ long newVal);
STDMETHOD(put_bstrBgImg)(/*[in]*/ BSTR newVal);
STDMETHOD(put_bstrFilePath)(/*[in]*/ BSTR newVal);
STDMETHOD(put_bstrFont)(/*[in]*/ BSTR newVal);
STDMETHOD(put_bstrText)(/*[in]*/ BSTR newVal);
STDMETHOD(get_llfHeight)(/*[out, retval]*/ long *pVal);
STDMETHOD(put_llfHeight)(/*[in]*/ long newVal);
STDMETHOD(get_lHeight)(/*[out, retval]*/ long *pVal);
STDMETHOD(put_lHeight)(/*[in]*/ long newVal);
STDMETHOD(get_lWidth)(/*[out, retval]*/ long *pVal);
STDMETHOD(put_lWidth)(/*[in]*/ long newVal);
分别实现自定义图象长,宽,字体大小,字体名称等属性。如:设置图像文本
STDMETHODIMP CAspImage::put_bstrText(BSTR newVal)
{
bstrText = newVal;
return S_OK;
}
设置图像高度
STDMETHODIMP CAspImage::put_lHeight(long newVal)
{
lHeight = newVal;
return S_OK;
}
四、ASP程序使用此组件输出图像到用户浏览器,在使用之前首先在服务器上注册此组件,方法:
- 拷贝XTAspImage.dll 到系统目录,一般为C:\WINNT\SYSTEM32
- 运行-> regsvr32 XTAspImage.dll
逆风编程精品 如果安装成功,会有成功提示。此过程只使用一次。下面是在asp里调用方法:
1. <!--#include file="Config/Function.asp"-->
2. <!--#include file="Config/SiteInfo.asp"-->
3. <!--#include file="Config/DbConn.asp"-->
4. <%
a) Dim TeachID, PageTextLen, Page, SumPage, BodyLen, \
TemplateBody, Width, Height, FHeight, sEndStr
b) TeachID = INT(Request("TeachID"))
c) PageTextLen = INT(Request("PageTextLen"))
d) IF PageTextLen <= 0 THEN
i. PageTextLen = 300
e) END IF
f) Page = INT(Request("Page"))
g) Set Rs = Server.CreateObject("ADODB.Recordset")
h) Sql="select * from Article where id=" & TeachID
i) Rs.open sql,conn,1,1
j) IF NOT Rs.EOF THEN
i. TeachingBody = Rs("Content") & constEndStr
k) ELSE
i. Response.Write("记录不存在")
ii. Rs.Close
iii. Set Rs = Nothing
iv. Conn.Close
v. Set Conn = Nothing
vi. Response.End
l) END IF
m) BodyLen = len(TeachingBody)
n) SumPage = GetMaxPageNum(BodyLen, PageTextLen)
o) Dim sPageText
p) IF Page >= SumPage THEN
i. Page = SumPage
本文章更多内容:<<上一页 - 1 - 2 - 3 - 下一页>> |