18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING APPLICATIONS WITH C++ AND CONTROL WIDGETS<br />

c. Remember to clean up g_ipCustomizeDialog when the application closes.<br />

// Function called when WM_DELETE_WINDOW protocol is passed<br />

void CloseAppCallback(Widget w, XtPointer client_data, XtPointer<br />

call_data)<br />

{<br />

…<br />

delete g_dateTool;<br />

If the <strong>ArcGIS</strong> <strong>Engine</strong> commands are not appearing<br />

in the Customize dialog box, there is a<br />

problem with your registry. Those commands can<br />

be added from the file, and to have that option<br />

in the Customize dialog box, pass<br />

VARIANT_TRUE into put_ShowAddFromFile().<br />

g_ipPopupMenu = 0;<br />

g_ipFillSymbol = 0;<br />

g_ipCurrentExtent = 0;<br />

g_ipCustomizeDialog = 0;<br />

3. Call CreateCustomizeDialog from the main function sometime after the<br />

ToolbarControl is initialized. If this is done any earlier, the Customize dialog<br />

box will not be associated with the ToolbarControl. For this scenario, call the<br />

function after adding the toolbar items.<br />

AddToolbarItems();<br />

CreateCustomizeDialog();<br />

4. Create a callback function for the toggle button. When the user clicks the<br />

toggle button to the on state, you want to show the Customize dialog box.<br />

When it is clicked off, the Customize dialog box should disappear.<br />

a. Place the forward declaration in MapViewer.h.<br />

HRESULT CreateCustomizeDialog();<br />

void ToggleCallback(Widget w, XtPointer client_data, XtPointer call_data);<br />

b. At the bottom of MapViewer.cpp, place the definition of the callback.<br />

HRESULT CreateCustomizeDialog()<br />

{<br />

…<br />

}<br />

void ToggleCallback(Widget w, XtPointer client_data, XtPointer call_data)<br />

{<br />

XmToggleButtonCallbackStruct *customize =<br />

(XmToggleButtonCallbackStruct *) call_data;<br />

long hWnd;<br />

g_ipToolbarControl->get_hWnd(&hWnd);<br />

if (customize->set)<br />

g_ipCustomizeDialog->StartDialog(hWnd);<br />

else<br />

g_ipCustomizeDialog->CloseDialog();<br />

}<br />

c. Also set up the callback right after the customizeToggle has been created in<br />

FormSetup.<br />

g_customizeToggle = XtVaCreateWidget(…);<br />

XtAddCallback(g_customizeToggle, XmNvalueChangedCallback, ToggleCallback,<br />

NULL);<br />

404 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!