Home > Software engineering >  How do you know a COM interface VARIANT parameter to preach in what content
How do you know a COM interface VARIANT parameter to preach in what content

Time:09-25

 
LPDISPATCH AddTextEffect (long PresetTextEffect, LPCTSTR Text, LPCTSTR FontName, float FontSize, long FontBold, long FontItalic, float Left, float Top, the VARIANT * Anchor)
{
LPDISPATCH result;
The static BYTE parms []=VTS_I4 VTS_BSTR VTS_BSTR VTS_R4 VTS_I4 VTS_I4 VTS_R4 VTS_R4 VTS_PVARIANT;
InvokeHelper (0 x12, DISPATCH_METHOD VT_DISPATCH, (void *) & amp; Result, parms PresetTextEffect, Text, FontName, FontSize, FontBold, FontItalic, Left, Top, Anchor);
return result;
}

This function from MSWORD. OLB file into, I want to use it to add a watermark doc file, but the execution times wrong "without this member", presumably parameter wrong,

Stickers, by the way my code, please take a look at what's the problem with
 
Void CWordComAppDlg: : OnBnClickedButtonWord ()
{
CApplication0 m_App;
CDocuments0 m_Docs;

//define variables
COleVariant vNull (L "");
COleVariant varTrue (short (1), VT_BOOL);
COleVariant varFalse (short (0), VT_BOOL);
COleVariant vT (SHORT (TRUE)), vF (SHORT (FALSE));
COleVariant vE (_T (" "));
COleVariant where v0 (SHORT (0)) and v1 (SHORT (1)), v2 (SHORT (2)), v5 (SHORT (5)), v6 (SHORT (6)), v12 (SHORT) (12), v22 (SHORT (22));

if (! M_App. CreateDispatch (_T (" Word. Application "), NULL))
{
return;
}

//interface invisible
M_App. Put_Visible (FALSE);

M_Docs=m_App. Get_Documents ();
M_Docs. AttachDispatch (m_App get_Documents ());
M_Docs. Open2000 (COleVariant (L "C: \ \ aaa. Doc"), varFalse, varFalse, varFalse, vNull, vNull, varFalse, vNull, vNull, varTrue, varTrue, varTrue);

CDocument1 doc0=m_App. Get_ActiveDocument ();
CSelection0 select=m_App. Get_Selection ();

////write text
//select. TypeText (L "hello world! \n");
//
////choice form
//CTables1 tabs.=doc0 get_Tables ();
//CTable1 tab1=tabs. The Item (1);

//CCell0 cell=tab1. Cell (1, 2);
//cell. The Select ();
//select TypeText (L "1, 2");

//cell=tab1. Cell (2, 1);
//cell. The Select ();
//select TypeText (L "2, 1");

//add watermark text
CHeaderFooter headfooter=select. Get_HeaderFooter ();
CShapes shapes=headfooter. Get_Shapes ();
Shapes. AddTextEffect (2, _T (" hello "), _T (" new song typeface "), 40, FALSE, FALSE, 0, 0, NULL);
//shapes. AddTextEffect (2, CComBSTR (L "hello"). M_str, CComBSTR (" new song typeface "L) m_str, 40, FALSE, FALSE, 0, 0, & amp; VNull);

Doc0. The Save ();

Shapes. ReleaseDispatch ();
Headfooter. ReleaseDispatch ();
Select the ReleaseDispatch ();

//cell. ReleaseDispatch ();
//tabs. ReleaseDispatch ();
//tab1. ReleaseDispatch ();

Doc0. ReleaseDispatch ();
M_Docs. ReleaseDispatch ();
M_App. Quit (vF, vF, vF);
M_App. ReleaseDispatch ();
}

CodePudding user response:

AddTextEffect method (Word)

  • Related