my_tool_window_1.sc:собен
Код: Выделить всё
using Microsoft.VisualStudio.Shell;
using System;
using System.Runtime.InteropServices;
namespace My_Tool_Wnd_1
{
[Guid("85455afd-c8d0-4208-b787-5577556fb994")]
public class My_Tool_Window_1 : ToolWindowPane
{
///
/// Initializes a new instance of the class.
///
public My_Tool_Window_1() : base(null)
{
this.Caption = "My_Tool_Window_1";
// This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
// we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
// the object returned by the Content property.
this.Content = new My_Tool_Window_1Control();
}
}
}
Код: Выделить всё
My_Tool_Window_1
Вопрос:
Как я могу получить доступ к этому окну из Arbitrary vs проекта? Я хотел бы написать в него немного текста из C ++ кода внутри некоторого проекта C ++ . Чего я хотел бы достичь, так это вывести текст в окно моего инструмента так же, как можно использовать метод outputDebugString для вывода строки отладки в окно вывода .
Я преуспел в доступе и написании в строку состояния ui , используя следующий C ++ код:
ui , используя следующий C ++ :
elemt
Код: Выделить всё
#define WIN32_LEAN_AND_MEAN
#include
#include
#include
// import EnvDTE
#pragma warning(disable : 4278)
#pragma warning(disable : 4146)
#import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("8.0") lcid("0") raw_interfaces_only named_guids
//#import "dte80a.olb" raw_interfaces_only named_guids
#pragma warning(default : 4146)
#pragma warning(default : 4278)
char buffer[100];
int main()
{
HRESULT result = S_OK;
CLSID clsid;
//CComBSTR solutionFullName;
//CComBSTR objNamee;
//size_t i=0;
result = ::CoInitialize(NULL);
if (FAILED(result)) {
sprintf_s(buffer, "CoInitialize failed: %s\n", std::system_category().message(result).c_str());
OutputDebugStringA(buffer);
buffer[0] = '\0';
return false;
}
result = ::CLSIDFromProgID(L"VisualStudio.DTE", &clsid);
if (FAILED(result)) {
sprintf_s(buffer, "CLSIDFromProgID failed: %s\n", std::system_category().message(result).c_str());
OutputDebugStringA(buffer);
buffer[0] = '\0';
return false;
}
CComPtr punk;
result = ::GetActiveObject(clsid, NULL, &punk);
if (FAILED(result)) {
sprintf_s(buffer, "GetActiveObject failed: %s\n", std::system_category().message(result).c_str());
OutputDebugStringA(buffer);
buffer[0] = '\0';
return false;
}
CComPtr pDTE = NULL;
CComPtr solution = NULL;
pDTE = punk;
CComPtr pStatusBar = NULL;
result = pDTE->get_StatusBar(&pStatusBar);
if (FAILED(result)) {
sprintf_s(buffer, "get_StatusBar failed: %s\n", std::system_category().message(result).c_str());
OutputDebugStringA(buffer);
buffer[0] = '\0';
return false;
}
BSTR MyBstr = SysAllocString(L"I am a happy BSTR");
result = pStatusBar->put_Text(MyBstr);
if (FAILED(result)) {
sprintf_s(buffer, "put_Text failed: %s\n", std::system_category().message(result).c_str());
OutputDebugStringA(buffer);
buffer[0] = '\0';
return false;
}
}
< /code>
Но не может найти способ «захватить» новое окно, которое я создал. Я исследовал Envdte спасибо за помощь заранее!
Подробнее здесь: https://stackoverflow.com/questions/796 ... ool-window
Мобильная версия