#include "stdinc.h" #include #include "atlhost.h" #include "controller.h" #include "FusionTrace.h" #pragma warning(disable:4018) /* signed/unsigned mismatch */ #pragma warning(disable:4189) #define IFFALSE_EXIT(x) do { if (!(x)) goto Exit; } while(0) static ATL::CComModule Module; BEGIN_OBJECT_MAP(ObjectMap) OBJECT_ENTRY(__uuidof(CSxApwControllerView), CSxApwControllerView) END_OBJECT_MAP() ATL::CComModule* GetModule() { return &Module; } ATL::_ATL_OBJMAP_ENTRY* GetObjectMap() { return ObjectMap; } const CLSID* GetTypeLibraryId() { return NULL; } std::wstring DoubleSlashes(const std::wstring& s) { std::wstring t; t.reserve(s.size() + 10); for (std::wstring::const_iterator i = s.begin() ; i != s.end() ; ++i) { if (*i == '\\') { t += L"\\\\"; } else { t += *i; } } return t; } STDMETHODIMP CSxApwControllerView::CreateWindow( HWND hwndParent ) { HRESULT hr = S_OK; RECT rc = { 0 }; ATL::CWindow parent(hwndParent); HMODULE exeHandle = 0; WCHAR path[MAX_PATH]; PWSTR exeFilePart = 0; PWSTR pluginFilePart = 0; CFindFile findFile; WIN32_FIND_DATAW findData; std::vector datasources; std::vector views; int i = 0; std::wstring html; int nview; int ndatasource; ATL::CAxWindow axWindow; IFFALSE_WIN32TOHR_EXIT(hr, parent.GetClientRect(&rc)); IFFALSE_WIN32TOHR_EXIT(hr, parent.ScreenToClient(&rc)); IFFALSE_WIN32TOHR_EXIT(hr, exeHandle = GetModuleHandleW(NULL)); IFFALSE_EXIT(GetModuleFileName(exeHandle, path, RTL_NUMBER_OF(path))); exeFilePart = 1 + wcsrchr(path, '\\'); wcscpy(exeFilePart, L"views\\"); pluginFilePart = exeFilePart + wcslen(exeFilePart); wcscpy(pluginFilePart, L"sxapw*.dll"); if (findFile.Win32Create(path, &findData)) { do { wcscpy(pluginFilePart, findData.cFileName); views.push_back(path); } while (FindNextFileW(findFile, &findData)); } wcscpy(exeFilePart, L"sources\\"); pluginFilePart = exeFilePart + wcslen(exeFilePart); wcscpy(pluginFilePart, L"sxapw*.dll"); if (findFile.Win32Create(path, &findData)) { do { wcscpy(pluginFilePart, findData.cFileName); datasources.push_back(path); } while (FindNextFileW(findFile, &findData)); } axWindow.Attach(hwndParent); html.reserve(MAX_PATH * (datasources.size() * 2 + views.size() * 2)); html += L"MSHTML:\n"; //html += L"
\n"; html += L"\n"; html += L"
\n"; html += L"\n"; nview = 0; ndatasource = 0; html += L" "; while (nview < views.size() || ndatasource < datasources.size()) { html += L" \n"; } html += L"
data sourcesdata views
"; if (ndatasource < datasources.size()) { html += L""; html += 1 + wcsrchr(datasources[ndatasource].c_str(), '\\'); ndatasource += 1; } html += L"\n"; if (nview < views.size()) { html += L""; html += 1 + wcsrchr(views[nview].c_str(), '\\'); nview += 1; } html += L"
"; html += L"

"; html += L""; html += L"

"; html += L""; html += L""; html += L"

"; //html += L"
\n"; printf("%ls\n", html.c_str()); if (FAILED(hr = axWindow.CreateControl(html.c_str()))) goto Exit; axWindow.SetExternalDispatch(this); Exit: return hr; }