PageLayout.cpp
// Copyright 2010 ESRI // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // You may freely redistribute and use this sample code, with or // without modification, provided you include the original copyright // notice and use restrictions. // // See the use restrictions. // #include <stdio.h> #include <qapplication.h> #include <qvbox.h> #include <qsplitter.h> #include <ArcSDK.h> #include <AxCtl/qt3axctl.h> #include <Ao/AoControls.h> void add_toolbar_items(IToolbarControl* pToolbar); int main(int argc, char **argv) { // Initialize the Engine ::AoInitialize(NULL); { IAoInitializePtr ipInit(CLSID_AoInitialize); esriLicenseStatus status; ipInit->Initialize(esriLicenseProductCodeEngine, &status); if (status != esriLicenseCheckedOut) { printf("Invalid Licensing.\n"); AoExit(0); } } QApplication qapp(argc, argv); QVBox vbox(NULL); vbox.resize(500 , 400); QAxCtl tlb(AoPROGID_ToolbarControl, &vbox, "Toolbar Control"); tlb.setMinimumHeight(30); tlb.setMaximumHeight(30); QSplitter split(&vbox); QAxCtl toc(AoPROGID_TOCControl, &split, "TOC Control"); QAxCtl plc(AoPROGID_PageLayoutControl, &split, "PageLayout Control"); qapp.setMainWidget(&vbox); vbox.show(); { IToolbarControlPtr ipToolbar; IPageLayoutControlPtr ipPageLayout; ITOCControlPtr ipToc; HRESULT hr; hr = tlb.getInterface((IUnknown **)&ipToolbar); hr = toc.getInterface((IUnknown **)&ipToc); hr = plc.getInterface((IUnknown **)&ipPageLayout); if (ipToolbar != 0) ipToolbar->SetBuddyControl(ipPageLayout); if (ipToc != 0) ipToc->SetBuddyControl(ipPageLayout); add_toolbar_items(ipToolbar); } qapp.exec(); // Uninitialize the engine { IAoInitializePtr ipInit(CLSID_AoInitialize); ipInit->Shutdown(); } ::AoUninitialize(); AoExit(0); return 0; } void add_toolbar_items(IToolbarControl* pToolbarControl) { long itemIndex; CComVariant varTool; varTool = L"esriControlCommands.ControlsOpenDocCommand"; pToolbarControl->AddItem(varTool, 0, -1, VARIANT_FALSE, 0, esriCommandStyleIconOnly, &itemIndex); varTool = L"esriControlCommands.ControlsPageZoomInTool"; pToolbarControl->AddItem(varTool, 0, -1, VARIANT_TRUE, 0, esriCommandStyleIconOnly, &itemIndex); varTool = L"esriControlCommands.ControlsPageZoomOutTool"; pToolbarControl->AddItem(varTool, 0, -1, VARIANT_FALSE, 0, esriCommandStyleIconOnly, &itemIndex); varTool = L"esriControlCommands.ControlsPagePanTool"; pToolbarControl->AddItem(varTool, 0, -1, VARIANT_FALSE, 0, esriCommandStyleIconOnly, &itemIndex); varTool = L"esriControlCommands.ControlsPageZoomInFixedCommand"; pToolbarControl->AddItem(varTool, 0, -1, VARIANT_FALSE, 0, esriCommandStyleIconOnly, &itemIndex); varTool = L"esriControlCommands.ControlsPageZoomOutFixedCommand"; pToolbarControl->AddItem(varTool, 0, -1, VARIANT_FALSE, 0, esriCommandStyleIconOnly, &itemIndex); varTool = L"esriControlCommands.ControlsPageZoomPageToLastExtentBackCommand"; pToolbarControl->AddItem(varTool, 0, -1, VARIANT_FALSE, 0, esriCommandStyleIconOnly, &itemIndex); varTool = L"esriControlCommands.ControlsPageZoomPageToLastExtentForwardCommand"; pToolbarControl->AddItem(varTool, 0, -1, VARIANT_FALSE, 0, esriCommandStyleIconOnly, &itemIndex); varTool = L"esriControlCommands.ControlsSelectFeaturesTool"; pToolbarControl->AddItem(varTool, 0, -1, VARIANT_FALSE, 0, esriCommandStyleIconOnly, &itemIndex); varTool = L"esriControlCommands.ControlsSelectTool"; pToolbarControl->AddItem(varTool, 0, -1, VARIANT_FALSE, 0, esriCommandStyleIconOnly, &itemIndex); }