tailieunhanh - Developing Visual Studio .NET Macros and Add-Ins phần 5

Hình 1,7 cho thấy những gì Studio. Visual IDE trông giống như với MDI cửa sổ. Nếu bạn chọn tài liệu theo thẻ, cửa sổ tài liệu của bạn sẽ có tab ở nội dung của phương pháp này với các trình biên tập mã. Lập trình các tài liệu và các đối tượng giao diện người dùng | CHAPTER 7 Creating Add-ins for the IDE In this chapter I expand on the concepts presented in Chapter 6 to show you how you can build an add-in that includes a GUI and interacts with the IDE s command system and menu bar. In the code for each of the sample add-ins in this chapter you will notice a GUID value in the form of a GuidAttribute. These are the GUIDs that were assigned to me when I ran the wizard. Although you can certainly use the same GUID in your code if you decide to type in these samples I don t recommend doing so. The reason is that if you create a product that uses the GUID and by chance another reader does the same thing and both your add-ins end up on the same computer there will be a problem. Therefore I recommend that you run the Add-in wizard to get the project started and use the GUID that the wizard assigns to you. From there you can type in the code from the samples. Building an Add-in in C If you built your add-in in C you probably quickly noticed something disturbing The add-in does not use .NET and the C managed extensions by default That s not good. Fortunately you have a choice You can either add managed extensions or you 139 140 Chapter 7 can continue writing the add-in without the .NET framework accessing the automation objects through the COM objects that are passed into the functions in your addin s main CConnect class. Yes in C the class has a C in front of it. If you want to skip the .NET framework and the C managed extensions you can write your add-in continuing from the starter code the wizard generated for you. But if you want access to the .NET framework and the C managed extensions here are the steps you can follow to add it. If these steps seem a little strange it s because the compiler option for managed extensions is not compatible with several other compiler options. 1. Open the project properties. 2. In the treeview choose Configuration Properties1 General. In the properties on the right set Use Managed Extensions to Yes.