修改Dsoframer源码支持D7


1.修改OnDraw函数中的FDrawText或DrawText;
2 为过程FRunningInDesignMode()中的1个变体变量分配内存空间

VARIANT vtUserMode;
//添加下面这句:
memset(&vtUserMode,0,sizeof(VARIANT));
在VC++中重新编译,注册dsoframer.ocx.

3.获取word文档数据流及其与D7变体的数据交换
ovOption:=EmptyParam;
ovFormat:='Rich Text Format';
FramerControl1.ExecOleCommand($7001, ovOption, ovFormat, ovWBinary);
//OLECMDID_GETDATAFORMAT=$7001; 执行OLE命令获取数据流
if VarType(ovWBinary)<>varEmpty then begin
pBuf := VarArrayLock(ovWBinary);
Stream.Size := VarArrayHighBound(ovWBinary, 1)-VarArrayLowBoundovWBinary, 1) + 1;
Stream.Position := 0;
Stream.Write(pBuf^, FS.Size);
VarArrayUnlock(ovWBinary);
WriteWordBinaryToDataBase(Stream);//保存流数据到数据库

向WORD文档中写入流数据关键代码:
GetWordBinaryFromDataBase(Stream);//从数据库读出试题数据流
ovWBinary:=VarArrayCreate([0,msStream.Size-1],varByte);
pBuf := VarArrayLock(ovWBinary);
Stream.Position:=0;
Stream.Read(pBuf^, Stream.Size);
VarArrayUnlock(ovWBinary);
FramerControl1.ExecOleCommand($7002, ovOption, ovFormat, ovWordBinary);
//OLECMDID_SETDATAFORMAT=$7002; 执行OLE命令向Word文档写入试题数据流,呈递试题内容
数据流写入Windows剪贴板
var
pBuf, bufptr: Pointer; hbuf : THandle; nRfetc,nSize:integer;
begin
nRfetc:=RegisterClipboardFormat('Rich Text Format');
GetWordBinaryFromDataBase(Stream); //从数据库读出试题数据流
hbuf := GlobalAlloc(GMEM_MOVEABLE, Stream.size);
if hbuf=0 then begin OutOfMemoryError; exit;end;
bufptr := GlobalLock(hbuf);
try
Stream.Read(bufptr^, Stream.size);//将试题流写入到全局内存
Clipboard.SetAsHandle(nRfetc, hbuf);//将全局内存流放置Windows剪贴板
PasteContentOnWordPaper;//从剪贴板中试题数据粘贴到Word试卷
finally
GlobalUnlock(hbuf);
end;
GlobalFree(hbuf); Stream.Free;
end;

 

你可能感兴趣的:(frame)