Start with the project you created in Implementing the Paint Automation Initializing, Creating and Freeing.
Add the following declaration to the WndProc
function:
static pCONTAINERHANDLE pContainer ;
Add the following code to the WndProc
function after the ReleaseDC statement in the ID_FILE_OPEN of the WM_COMMAND
message:
{//AUTOMATION CONTAINER STUFF
CONTAINERPAINTDATA PaintData;
{//REMOVE THE OLD CONTAINER (IF ANY)
if (SUCCESS == L_ContainerIsValid(pContainer))
{
L_AutRemoveContainer(pAutomation, pContainer);
L_ContainerFree(pContainer);
}
}//REMOVE THE OLD CONTAINER (IF ANY)
PaintData.pBitmap = &hBitmap;
PaintData.hRestrictionPalette = hPalette;
L_ContainerInit(&pContainer);
L_ContainerCreate(pContainer, hWnd);
L_AutAddContainer(pAutomation, pContainer, &PaintData);
}//AUTOMATION CONTAINER STUFF
Add the following code before the L_AutFree function call in the WndProc
function in the WM_DESTROY
message:
if ( SUCCESS == L_ContainerIsValid ( pContainer ) )
{
L_AutRemoveContainer ( pAutomation, pContainer ) ;
L_ContainerFree ( pContainer ) ;
}
Add the following declaration to the WndProc
function:
VECTORPOINT vptScalarNum, vptScalarDen ;
Add the following lines before the OnSize
function call in the "case WM_SIZE:" in the WndProc
function:
if ( SUCCESS == L_ContainerIsValid ( pContainer ) )
{
L_ContainerGetScalar ( pContainer, &vptScalarNum, &vptScalarDen ) ;
nScalarNum = ( L_INT ) vptScalarNum.x ;
nScalarDen = ( L_INT ) vptScalarDen.x ;
}
Add the following container function call after the OnSize
function call in the "case WM_SIZE:" in the WndProc
function:
L_ContainerSetOffset ( pContainer, - rcView.left, - rcView.top, 0 ) ;
Add the following container function call after the OnHScroll
function call in the "case WM_HSCROLL:" in the WndProc
function:
L_ContainerSetOffset ( pContainer, - rcView.left, - rcView.top, 0 ) ;
Add the following container function call after the OnVScroll
function call in the "case WM_VSCROLL:" in the WndProc
function:
L_ContainerSetOffset ( pContainer, - rcView.left, - rcView.top, 0 ) ;
Compile and run the project by selecting Build->Execute tutorial.exe from the menu.