Visual Basic
Описываем переменную класса:
Dim mDAStatics As DAStatics
Создаем класс
Private Sub Form_Load()
Set mDAStatics = DAViewerControl1.PixelLibrary
End Sub
Уничтожаем при закрытии формы.
Private Sub Form_Terminate()
Set mDAStatics = Nothing
End Sub
Visual C++
Подключаем описание класса
......
//{{AFX_INCLUDES()
#include "da3viewercontrol.h"
//}}AFX_INCLUDES
#include "dastatics.h"
......
Описываем объект класса
......
class CVCDlg : public CDialog
{
// Construction
public:
CVCDlg(CWnd* pParent = NULL); // standard constructor
CDAStatics mDAStatics;
// Dialog Data
//{{AFX_DATA(CVCDlg)
enum { IDD = IDD_VC_DIALOG };
......
Вызываем создание библиотеки в OnInitDialog():
BOOL CVCDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// TODO: Add extra initialization here
......
mDAStatics=m_DirectControl.GetPixelLibrary();
return TRUE; // return TRUE unless you set the focus to a control
}
Освобождаем при закрытии диалога:
void CVCDlg::OnDestroy()
{
mDAStatics.ReleaseDispatch();
CDialog::OnDestroy();
// TODO: Add your message handler code here
}