RightMargin Example for C++ 5.0 and later

ILEADRasterTwain_U * pRasterTwain;

HRESULT hr = ::CoCreateInstance(CLSID_LEADRasterTwain_U, NULL, CLSCTX_ALL, IID_ILEADRasterTwain_U, (void **)&pRasterTwain);
if (FAILED(hr) || !pRasterTwain)
{
	::MessageBox (NULL, _TEXT("Failed to create a Raster Twain Object"), _TEXT("Error"), MB_OK);
	return;
}

pRasterTwain->InitSession((long)GetSafeHwnd()); 
pRasterTwain->SelectSource();

ItwFrame_U * ptwFrame = NULL; 
float m_RightMargin; 
float m_LeftMargin; 
float m_BottomMargin; 
float m_TopMargin; 
ILEADRasterVariant_U * CapVal = NULL; 
CoCreateInstance(CLSID_LEADRasterVariant_U, NULL, CLSCTX_ALL, 
							   IID_ILEADRasterVariant_U, (void **)&CapVal); 

ICapability_U * pCapability = NULL; 
ICapabilityOneValue_U * pCapOV = NULL; 

::CoCreateInstance (CLSID_twFrame_U, NULL, CLSCTX_ALL, IID_ItwFrame_U, (void **)&ptwFrame); 
if (ptwFrame) 
{
	UpdateData (TRUE); 

	ptwFrame->put_RightMargin(m_RightMargin); 
	ptwFrame->put_LeftMargin(m_LeftMargin); 
	ptwFrame->put_TopMargin(m_TopMargin); 
	ptwFrame->put_BottomMargin(m_BottomMargin); 

	::CoCreateInstance (CLSID_LEADRasterTwainCapability_U, NULL, CLSCTX_ALL, IID_ICapability_U, (void **)&pCapability); 
	pCapability->QueryInterface (IID_ICapabilityOneValue_U, (void **)&pCapOV); 

	pCapability->EnableMethodErrors = FALSE; 
	pCapability->Capability = L_ICAP_FRAMES; 
	pCapability->ConType = L_TWON_ONEVALUE; 

	CapVal->Type = VALUE_DISPATCH; 
	CapVal->DispatchValue = ptwFrame; 


	pCapOV->put_OneValItemType (L_TWTY_FRAME); 
	pCapOV->put_OneValCapValue (CapVal); 

	pRasterTwain->SetCapability (pCapability, L_LTWAIN_CAPABILITY_SET); 

	ptwFrame->Release();
	pCapOV->Release();
	pCapability->Release();
}

CapVal->Release();