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 WINDOWS CONTROLS<br />

4. Add a check box to the Form and give it the name ‘chkCustomize’ and the<br />

caption ‘Customize’.<br />

5. Display the form in design mode and select chkCustomize from the Properties<br />

window and display the chkCustomize events. Double-click CheckedChanged<br />

to add an event handler to the code window.<br />

6. Add the following code to the chkCustomize_ CheckedChanged event.<br />

private void chkCustomize_CheckedChanged(object sender, System.EventArgs<br />

e)<br />

{<br />

// Show or hide the Customize dialog box.<br />

if (chkCustomize.Checked == false)<br />

{<br />

m_CustomizeDialog.CloseDialog();<br />

axToolbarControl1.Customize = false;<br />

}<br />

else<br />

{<br />

m_CustomizeDialog.StartDialog(axToolbarControl1.hWnd);<br />

axToolbarControl1.Customize = true;<br />

}<br />

}<br />

7. Add the following OnStartDialog and OnCloseDialog event handlers. These<br />

functions will be wired to events raised whenever the Customize dialog box is<br />

opened or closed.<br />

private void OnStartDialog()<br />

{<br />

axToolbarControl1.Customize = true;<br />

}<br />

private void OnCloseDialog()<br />

{<br />

axToolbarControl1.Customize = false;<br />

chkCustomize.Checked = false;<br />

}<br />

8. Build and run the application and check the Customize box to put the<br />

ToolbarControl into customize mode and open the Customize dialog box.<br />

Chapter 6 • <strong>Developer</strong> scenarios • 353

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

Saved successfully!

Ooh no, something went wrong!