Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Обучение VC++ / VC++Баженова / Приложение.doc
Скачиваний:
36
Добавлен:
16.02.2016
Размер:
7.5 Mб
Скачать

Void ccontView::OnDraw(cdc* pDc) // Обработчик сообщения

{

CCONTDoc* pDoc = GetDocument();

ASSERT_VALID(pDoc);

// TODO: add draw code for native data here

// TODO: also draw all OLE items in the document

// Draw the selection at an arbitrary position. This code should be // removed once your real drawing code is implemented. This position // corresponds exactly to the rectangle returned by CCONTCntrltem, // to give the effect of in-place editing.

// TODO: remove this code when final draw code is complete.

if (m_pSelection == NULL)

{ POSITION pos = pDoc->GetStartPosition();

m_pSelection = (CCONTCntrItem*)pDoc->GetNextClientItem(pos);

}

if (m_pSelection != NULL)

m_pSelection->Draw(pDC, CRect(10, 10, 210, 210)); }

void CCONTView::OnInitialUpdate() // Обработчик сообщения

{

CView::OnInitialUpdate(); // Вызов метода базового класса // TODO: remove this code when final selection model code is written m_pSelection = NULL; // initialize selection

}

Illllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

// CCONTView printing

BOOL CCONTView::OnPreparePrinting(CPrintInfo* plnfo)

{ // default preparation

return DoPreparePrinting(pInfo); }

Void ccontView::OnBeginPrintiBg(cdc* /*pDc*/, cPrintlnfo* /*рШо*/) {

// TODO: add extra initialization before printing }

void CCONTView::OBEndPrinting(CDC* /*pDC*/, CPrintlnfo* /*plnfo*/) {

// TODO: add cleanup after printing }

Void ccontView::OnDestroy() {

// Deactivate the item on destruction; this is important // when a splitter view is being used. CView::OnDestroy();

COleCIientltem* pActiveltem = GetDocument()->GetInPlaceActiveItem(this); if (pActiveltem != NULL && pActiveItem->GetActiveView() == this) {

pActiveItem->Deactivate();

ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL); } >

Illllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

II OLE Client support and commands

BOOL CCONTView::IsSelected(const CObject* pDocItem) const

{

// The implementation below is adequate if your selection consists of

// only CCONTCntrltem objects. To handle different selection

// mechanisms, the implementation here should be replaced.

// TODO: implement this function that tests for a selected OLE client item

return pDocItem == m_pSelection; }

void CCONTView::OnInsertObject() {

// Invoke the standard Insert Object dialog box to obtain information

// for new CCONTCntrltem object.

COlelnsertDialog dig; // Отображение стандартного диалога

if (dlg.DoModal() != IDOK) // Insert Object для встраивания OLE-обмкгов return;

BeginWaitCiirsor();

CCONTCntrltem* pltem = NULL;

TRY

{ // Create new item connected to this document. CCONTDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); pltem = new CCONTCntrltem(pDoc); ASSERT_VALID(pItem); // Initialize the jtenj from the dialog data. if (!dlg.CreateItem(pItem))

AfxThrowMemoryExceptionO; // any exception will do ASSERT_VALID(pItem);

// If item created from class list (not from file) then launch // the server to edit the item. if (dlg.GetSelectionType() == COleInsertDialog::createNewItem)

pItem->DoVerb(OLEIVERB_SHOW, this); ASSERT_VALID(pItem);

// As an arbitrary user interface design, this sets the selection // to the last item inserted.

// TODO: reimplement selection as appropriate for your application mpSelection = pltem; // set selection to last inserted item pDoc->UpdateAllViews(NULL);

} CATCH(CException, e)

{

if (pltem != NULL)

{

ASSERT_VALID(pItem); pItem->Delete();

} AfxMessageBox(IDP_FAILED_TO_CREATE);

}

END_CATCH

EndWaitCursor();

}

// The following command handler provides the standard keyboard // user interface to cancel an in-place editing session. Here, // the container (not the server) causes the deactivation. void CCONTView::OnCancelEditCntr()

{

// Close any in-place active item on this view.

COleCIientltem* pActiveltem = GetDocument()->GetInPlaceActiveItem(this);

if (pActiveltem != NULL) // Закрываем активный элемент

{ pActiveItem->Close(); }

ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);

}

// Special handling of OnSetFocus and OnSize are required for a container // when an object is being edited in-place.

Соседние файлы в папке VC++Баженова