1. Modify fdrawtext or drawtext in the ondraw function;
2. allocate memory space for one variant variable in the frunningindesignmode () Process
Variant vtusermode;
// Add the following sentence:
Memset (& vtusermode, 0, sizeof (variant ));
Recompile in VC ++ and register dsoframer. ocx.
3. Obtain the Word document data stream and its data exchange with D7 variants
Ovoption: = emptyparam;
Ovformat: = 'rich text format ';
Framercontrol1.execolecommand ($7001, ovoption, ovformat, ovwbinary );
// Olecmdid_getdataformat = $7001; execute the OLE command to obtain the data stream
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); // Save the stream data to the database
Key code for writing stream data to Word documents:
Getwordbinaryfromdatabase (Stream); // read the question data stream from the database
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; execute the OLE command to write the question data stream to the Word document and submit the question content
Writing data streams to Windows clipboard
VaR
Pbuf, bufptr: pointer; hbuf: thandle; nrfetc, nsize: integer;
Begin
Nrfetc: = registerclipboardformat ('rich text format ');
Getwordbinaryfromdatabase (Stream); // read the question data stream from the database
Hbuf: = globalalloc (gmem_moveable, stream. size );
If hbuf = 0 then begin outofmemoryerror; exit; end;
Bufptr: = globallock (hbuf );
Try
Stream. Read (bufptr ^, stream. size); // write the question stream to the global memory
Clipboard. setashandle (nrfetc, hbuf); // place the global memory stream to the Windows clipboard
Pastecontentonwordpaper; // paste the exam data from the clipboard to the word exam
Finally
Globalunlock (hbuf );
End;
Globalfree (hbuf); stream. Free;
End;