{"id":1460,"date":"2013-08-13T02:04:03","date_gmt":"2013-08-13T00:04:03","guid":{"rendered":"http:\/\/www.samlogic.net\/blog\/?p=1460"},"modified":"2019-07-07T21:50:01","modified_gmt":"2019-07-07T21:50:01","slug":"how-to-add-an-activex-control-to-a-visual-c-2010-project","status":"publish","type":"post","link":"https:\/\/www.samlogic.net\/blog\/2013\/08\/how-to-add-an-activex-control-to-a-visual-c-2010-project\/","title":{"rendered":"How to add an ActiveX control to a Visual C++ 2010 project"},"content":{"rendered":"<p>In a previous <a href=\"https:\/\/www.samlogic.net\/blog\/2013\/01\/how-to-add-an-activex-component-to-a-visual-basic-2010-project\/\">blog post<\/a> we showed how to add an ActiveX control to a <strong>Microsoft Visual Basic 2010<\/strong> project. In this blog post we will show how to add an ActiveX control to a <strong>Microsoft Visual C++ 2010<\/strong> project. We will also show how to create a variable that can be used to access properties and methods in the ActiveX control.<br \/>\n<img decoding=\"async\" class=\"alignright\" src=\"https:\/\/www.samlogic.net\/components-social-media\/twitter-component\/images\/twitter-bird.png\" alt=\"Twitter\" border=\"0\"><br \/>\nIn this step-by-step tip we will use the <a href=\"https:\/\/www.samlogic.net\/components-social-media\/twitter-component\/twitter-component.htm\">Twitter control<\/a> that is included in our <strong>SamLogic Social Media Components<\/strong> component library. This control can be used to send tweets to Twitter, and we will show how to add this control to a Visual C++ project. Although this tip will cover Microsoft Visual C++ 2010, the steps in other versions of Visual C++ are very similar.<\/p>\n<p><strong>How to add an ActiveX component to a Visual C++ 2010 project<\/strong><\/p>\n<p>1. Start Visual Studio 2010 and choose <strong>New project<\/strong> in the <strong>File<\/strong> menu.<\/p>\n<p>2. Select the <strong>MFC Application<\/strong> option in the <strong>Visual C++<\/strong> node in the <strong>New project<\/strong> dialog box.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-components-twitter\/visual-c-new-project-mfc-application.png\" alt=\"New Project - Visual C++ - MFC Application\" border=\"0\"><\/p>\n<p>3. In the <strong>MFC Application Wizard<\/strong> window that is shown, choose <strong>Dialog based<\/strong> in the <strong>Application Type<\/strong> step. We will create a dialog based Windows application.<\/p>\n<p>4. In the <strong>Advanced Features<\/strong> step in the <strong>MFC Application Wizard<\/strong>, make sure that the <strong>ActiveX controls<\/strong> option is selected.<\/p>\n<p>5. In the last step of the <strong>MFC Application Wizard<\/strong>, click on the <strong>Finish<\/strong> button.<\/p>\n<p>We have now created a basic Visual C++ \/ MFC project that uses a dialog based window. Next will show how to add the Twitter ActiveX control to the project:<\/p>\n<p>6. Right-click over the <strong>Toolbox<\/strong> window.<\/p>\n<p>7. Select the <strong>Choose items<\/strong> menu item in the local menu that is shown.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-components-twitter\/visual-c-menu-toolbox-choose-items.png\" alt=\"The 'Choose Items' menu item\" border=\"0\"><\/p>\n<p>8. The <strong>Choose Toolbox Items<\/strong> dialog box is now shown. In this dialog box, open the <strong>COM Components<\/strong> tab.<\/p>\n<p>9. If you have installed the Twitter component and want to use it, select the <strong>SLTwitCtrl<\/strong> control in the list. Otherwise, select the ActiveX component that you want to use.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-components-twitter\/visual-c-dlgbox-choose-toolbox-items.png\" alt=\"The 'Choose Toolbox Items' dialog box in Visual C++\" border=\"0\"><\/p>\n<p>10. Click <strong>OK<\/strong> to close the dialog box.<\/p>\n<p>11. The selected component should be visible in the <strong>Toolbox<\/strong> window; probably in the bottom of the window.<\/p>\n<p>12. Now drag and drop the component on the dialog box.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-components-twitter\/visual-c-editor-with-twitter-activex.png\" alt=\"The Twitter ActiveX control is placed in the dialog box\" border=\"0\"><\/p>\n<p>We have now included an ActiveX component into a Visual C++ 2010 project and put it in a dialog box. We will now show how to create a variable that can be used to access properties and methods in the ActiveX control.<\/p>\n<p>13. Right-click on the ActiveX control in the dialog box window.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-components-twitter\/visual-c-menu-add-variable.png\" alt=\"The 'Add Variable' menu item\" border=\"0\"><\/p>\n<p>14. Click on the <strong>Add Variable<\/strong> menu item in the local menu that is shown.<\/p>\n<p>15. Enter a variable name in the dialog box that is shown, for example: <strong>SLTwitterCtrl<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-components-twitter\/visual-c-add-member-variable-wizard.png\" alt=\"The 'Add Member Varible Variable' dialog box\" border=\"0\"><\/p>\n<p>15. Click <strong>Finish<\/strong> to close the dialog box and create the variable<\/p>\n<p>16. We have now created a variable that can be used to access properties and methods in the ActiveX control. The example below shows how to access the <strong>AppName<\/strong> property in SamLogic&#8217;s Twitter Control (it sets the ActiveX property to &#8220;Twitter Test Application&#8221;):<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-components-twitter\/visual-c-code-twitter-control-appname-property.png\" alt=\"Code example - How to access the AppName property in SamLogic's Twitter component in Visual C++\" border=\"0\"><\/p>\n<p><strong>Related Blog Posts<\/strong><br \/>\n<strong><span style=\"color: #ff0000;\">&gt;<\/span><\/strong> <a href=\"https:\/\/www.samlogic.net\/blog\/2013\/01\/how-to-add-an-activex-component-to-a-visual-basic-2010-project\/\">How to add an ActiveX component to a Visual Basic 2010 project<\/a><br \/>\n<strong><span style=\"color: #ff0000;\">&gt;<\/span><\/strong> <a href=\"https:\/\/www.samlogic.net\/blog\/2013\/01\/how-to-add-an-activex-component-to-an-excel-2010-sheet\/\">How to add an ActiveX component to an Excel 2010 sheet<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a previous blog post we showed how to add an ActiveX control to a Microsoft Visual Basic 2010 project. In this blog post we will show how to add an ActiveX control to a Microsoft Visual C++ 2010 project. We will also show how to create a variable that can be used to access &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.samlogic.net\/blog\/2013\/08\/how-to-add-an-activex-control-to-a-visual-c-2010-project\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to add an ActiveX control to a Visual C++ 2010 project&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[],"_links":{"self":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts\/1460"}],"collection":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/comments?post=1460"}],"version-history":[{"count":1,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts\/1460\/revisions"}],"predecessor-version":[{"id":6149,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts\/1460\/revisions\/6149"}],"wp:attachment":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/media?parent=1460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/categories?post=1460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/tags?post=1460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}