diff --git a/DockLayout.vcxproj b/DockLayout.vcxproj index be8ac70..5e87a19 100644 --- a/DockLayout.vcxproj +++ b/DockLayout.vcxproj @@ -92,11 +92,13 @@ + + diff --git a/DockLayout.vcxproj.filters b/DockLayout.vcxproj.filters index 22cb163..caf4fc0 100644 --- a/DockLayout.vcxproj.filters +++ b/DockLayout.vcxproj.filters @@ -19,6 +19,9 @@ + + ソース ファイル + ソース ファイル @@ -27,6 +30,9 @@ + + ヘッダー ファイル + ヘッダー ファイル diff --git a/src/HostContext.cpp b/src/HostContext.cpp new file mode 100644 index 0000000..163196e --- /dev/null +++ b/src/HostContext.cpp @@ -0,0 +1,33 @@ +#include "HostContext.h" + +namespace dl { + +static CONFIG_HANDLE* g_config = nullptr; +static HWND g_host = nullptr; +static WNDPROC g_hostProc = nullptr; + +void SetConfigHandle(CONFIG_HANDLE* handle) { g_config = handle; } +void SetHostWindow(HWND window) { g_host = window; } +void SetHostWindowProc(WNDPROC proc) { g_hostProc = proc; } + +CONFIG_HANDLE* Config() { return g_config; } +HWND HostWindow() { return g_host; } +WNDPROC HostWindowProc() { return g_hostProc; } + +LRESULT CallHostWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { + return CallWindowProcW(g_hostProc, hwnd, msg, wp, lp); +} + +int LayoutSize(const char* key) { + return g_config ? g_config->get_layout_size(g_config, key) : 0; +} + +int ColorCode(const char* key) { + return g_config ? g_config->get_color_code(g_config, key) : 0; +} + +const wchar_t* MenuText(const wchar_t* text) { + return g_config ? g_config->get_language_text(g_config, L"Menu", text) : text; +} + +} diff --git a/src/HostContext.h b/src/HostContext.h new file mode 100644 index 0000000..847718c --- /dev/null +++ b/src/HostContext.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +#include "config2.h" + +namespace dl { + +void SetConfigHandle(CONFIG_HANDLE* handle); +void SetHostWindow(HWND window); +void SetHostWindowProc(WNDPROC proc); + +CONFIG_HANDLE* Config(); +HWND HostWindow(); +WNDPROC HostWindowProc(); +LRESULT CallHostWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp); + +int LayoutSize(const char* key); +int ColorCode(const char* key); +const wchar_t* MenuText(const wchar_t* text); + +} diff --git a/src/Plugin.cpp b/src/Plugin.cpp index 09644c4..fa5b290 100644 --- a/src/Plugin.cpp +++ b/src/Plugin.cpp @@ -1,5 +1,6 @@ #include +#include "HostContext.h" #include "Log.h" #include "plugin2.h" @@ -16,10 +17,13 @@ EXTERN_C __declspec(dllexport) COMMON_PLUGIN_TABLE* GetCommonPluginTable(void) { } EXTERN_C __declspec(dllexport) DWORD RequiredVersion() { return 2010000; } EXTERN_C __declspec(dllexport) void InitializeLogger(LOG_HANDLE* h) { SetLogHandle(h); } +EXTERN_C __declspec(dllexport) void InitializeConfig(CONFIG_HANDLE* h) { SetConfigHandle(h); } EXTERN_C __declspec(dllexport) bool InitializePlugin(DWORD) { return true; } -EXTERN_C __declspec(dllexport) void RegisterPlugin(HOST_APP_TABLE*) { - LogF(L"DockLayout registered"); +EXTERN_C __declspec(dllexport) void RegisterPlugin(HOST_APP_TABLE* host) { + SetHostWindow(host->create_edit_handle()->get_host_app_window()); + + LogF(L"DockLayout registered (host=%p)", (void*)HostWindow()); } EXTERN_C __declspec(dllexport) void UninitializePlugin() {