Step by step procedures for creating the VC/Ex1 example
- Make sure you have register the ActiveCDX.OCX, see install.htm for more information on this.
- Create a new project using MFC AppWiz. In step 1 select Dialog based for application type and then click finish.
- Insert the ActiveCDX Control.
Open the dialog editor, right click at the form, select CDXVisual Control and set the ID to
IDC_CDXVISUALCTRL.
- Remove the other buttons and control from the dialog form. We wouldn't need them.
- Open the MFC ClassWizard, select member variables tab, double click IDC_CDXVISUALCTRL, the Developer studio will ask you if you want to make a wrapper class for the control, click OK. Change the class name into CDXVisual, click OK. Enter m_Visual as the member variable name, click OK.
- Add a protected member m_Splash to the CEx1Dlg (the dialog class). This m_Splash is the handle of the Splash Surface and should have variable type of long.
- In the CEx1Dlg::OnPaint() of the "else" section, add this code:
static BOOL firstTime = TRUE;
if (firstTime)
{
firstTime = FALSE;
if (!m_Visual.CreateWindowed((long)GetSafeHwnd(), 640, 480))
{
MessageBox("Failed creating windowed CDX");
PostQuitMessage(0);
return;
}
m_Splash =
m_Visual.CreateSurface4("c:\\cdx\\acdx\\examples\\res\\splash.bmp", 2);
if (m_Splash == 0)
{
MessageBox("Failed loading
c:\\cdx\\acdx\\examples\\res\\splash.bmp");
PostQuitMessage(0);
return;
}
}
m_Visual.DrawFast(m_Visual.GetBack(), 0, 0, m_Splash);
m_Visual.Flip();
For the first time, the above code will create and initialize the CDX into
windowed mode. After that, it will create a surface containing the splash
bitmap. Value 2 for the last parameter indicated that the surface should be
located in the vidmem, and if it's not possible then the surface can be put
in the sysmem. It's the same value as CDXSYS_VIDTHENMEM.
After one time initialization, last two line of the code will blit the
Splash surface to the backbuffer. The Flip command will copy the backbuffer
to the primary buffer, thus allow the splash screen to be visible.