SetLayer()

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
Untoter
Posts: 22
Joined: Tue Nov 04 2014

SetLayer()

Post by Untoter »

hey,

http://www.amyuni.com/WebHelp/Amyuni_Do ... verter.htm

Code: Select all

void SetLayer( HDC hDC, LPWSTR LayerInfo )
{
switch ( ExtEscape( hDC, ESCAPE_SETLAYER, (int)((wcslen(LayerInfo) + 1)* sizeof(LayerInfo[0])),(LPCSTR)LayerInfo, 0, NULL ) )

i changed it a bit to

Code: Select all

bool SetLayer( HDC hDC, std::wstring sTest )
{
	auto iRet = ExtEscape( hDC, ESCAPE_SETLAYER, (int) ((wcslen( sTest.c_str( ) ) + 1)	* sizeof( sTest.c_str( ) )), (LPCSTR)sTest.c_str( ), 0, NULL );

My Question is, why u cast (LPCSTR). U receive a wchar_t and c cast it to ANSI? Most times this cant work.
Alexandre
Amyuni Team
Posts: 21
Joined: Tue Oct 01 2002
Contact:

Re: SetLayer()

Post by Alexandre »

Hello,

From MSDN documentation of ExtEscape we have:

int ExtEscape(
_In_ HDC hdc,
_In_ int nEscape,
_In_ int cbInput,
_In_ LPCSTR lpszInData,
_In_ int cbOutput,
_Out_ LPSTR lpszOutData
);

Where lpszInData is defined as:

lpszInData [in]
A pointer to the input structure required for the specified escape.

As you can see lpszInData is actually a pointer to raw data, not to an ANSI string. In this particular case, the "input structure required for the specified escape", happens to be a wide string, but it could have been something else, a pointer to a struct for example.
Get PDF Suite, the expert .NET developer toolkit for PDF conversion, creation and editing - www.amyuni.com/pdfsuite
Post Reply