DIRECT3D Attributes Sample: Demonstrates Using Direct3D

The DIRECT3D attributes sample creates a control that draws a spinning triangle using the Direct3D graphics library.

Security noteSecurity Note:

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

To get samples and instructions for installing them:

  • On the Visual Studio Help menu, click Samples.

    For more information, see Visual Studio Samples.

  • The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.

To build and run this sample

  1. Open the solution file Direct3D.sln.

  2. From the Build menu, click Build Solution.

  3. After the sample builds, open Direct3D.htm in your Web browser.

You can test the control in the ActiveX Control Test Container. For details on accessing Test Container and using it to test a control, see Testing Properties and Events with Test Container.

This sample uses the following attributes:

coclass, default, dll, dual, helpstring, implements_category, module, name, object, pointer_default, progid, registration_script, support_error_info, uuid, vi_progid

This sample uses the following keywords:

Apartment; ATLASSERT; ATLTRACE; AtlWaitWithMessageLoop; BEGIN_COM_MAP; BEGIN_MSG_MAP; BEGIN_OBJECT_MAP; BEGIN_PROPERTY_MAP; CComCoClass; CComControl; CComControlBase::InPlaceActivate; CComModule::GetClassObject; CComModule::GetLockCount; CComModule::Init; CComModule::RegisterServer; CComModule::Term; CComModule::UnregisterServer; CComObjectRoot; CException::ReportError; CoGetInterfaceAndReleaseStream; CoInitialize; COM_INTERFACE_ENTRY; COM_INTERFACE_ENTRY_IMPL; COM_INTERFACE_ENTRY_IMPL_IID; CoMarshalInterThreadInterfaceInStream; CopyMemory; CoUninitialize; CreatePalette; CreateRectRgn; CreateThread; D3DEXECUTEBUFFERDESC; DDSURFACEDESC; DDSURFACEDESC; DECLARE_GET_CONTROLLING_UNKNOWN; DECLARE_REGISTRY_RESOURCEID; DirectDrawCreate; DirectDrawCreateClipper; DisableThreadLibraryCalls; END_OBJECT_MAP; GetClientRect; GetOurWindow; GetSystemPaletteEntries; IDataObjectImpl; IDirect3D::CreateLight; IDirect3D::CreateMaterial; IDirect3D::CreateViewport; IDirect3DDevice::AddViewport; IDirect3DDevice::BeginScene; IDirect3DDevice::CreateMatrix; IDirect3DDevice::DeleteMatrix; IDirect3DDevice::EndScene; IDirect3DDevice::Execute; IDirect3DViewport::AddLight; IDirect3DViewport::CreateMatrix; IDirect3DViewport::SetBackground; IDirect3DViewport::SetMatrix; IDirectDraw2::EnumDevices; IDirectDraw2::SetCooperativeLevel; IDirectDrawClipper::SetHWnd; IDirectDrawSurface2::AddAttachedSurface; IDirectDrawSurface2::GetSurfaceDesc; IDirectDrawSurface2::Restore; IDirectDrawSurface2::SetClipper; IDispatchImpl; IObjectSafetyImpl; IOleControlImpl; IOleInPlaceActiveObjectImpl; IOleInPlaceObjectWindowlessImpl; IOleInPlaceObjectWindowlessImpl::InPlaceDeactivate; IOleInPlaceObjectWindowlessImpl::SetObjectRects; IOleObjectImpl; IPersistStorageImpl; IPersistStreamInitImpl; IProvideClassInfo2Impl; IQuickActivateImpl; ISupportErrorInfo; IViewObjectExImpl; LPD3DDEVICEDESC; LPD3DINSTRUCTION; LPD3DPROCESSVERTICES; LPD3DSTATE; LPD3DTRIANGLE; LPD3DVERTEX; LPDIRECTDRAWCLIPPER ; MessageBox; OBJECT_ENTRY; OffsetRect; OnEraseBackground; PALETTEENTRY; QueryInterface; RenderScene; SelectClipRgn; SetPalette; WindowFromDC; ZeroMemory


Some of the samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task.

Community Additions