Created
February 14, 2016 09:59
-
-
Save miahmie/87394ff316f546046d15 to your computer and use it in GitHub Desktop.
Window.beginMove Plugin (for kirikiriZ)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TITLE: Window.beginMoveプラグイン | |
AUTHOR: miahmie | |
●これはなに? | |
吉里吉里Zで実装されていない Window.beginMove() を追加するプラグインです。 | |
●使い方 | |
Plugins.linkするとWindow.beginMoveが追加されます。 | |
●コンパイル | |
tp_stub.h | |
tp_stub.cpp | |
と | |
premake4.exe | |
が必要です。 | |
premake4 vs20XX(XXには使っているVSの年号を入れる)にて | |
プロジェクトを作成の上,コンパイルしてください。 | |
●ライセンス | |
このプラグインのライセンスは吉里吉里Zに準拠してください。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include "tp_stub.h" | |
#define EXPORT(hr) extern "C" __declspec(dllexport) hr __stdcall | |
#ifdef _MSC_VER | |
#pragma comment(linker, "/EXPORT:V2Link=_V2Link@4") | |
#pragma comment(linker, "/EXPORT:V2Unlink=_V2Unlink@0") | |
#endif | |
int WINAPI | |
DllMain(HINSTANCE /*hinst*/, unsigned long /*reason*/, void* /*lpReserved*/) | |
{ | |
return 1; | |
} | |
static tjs_int GlobalRefCountAtInit = 0; | |
bool onV2Link(); | |
bool onV2Unlink(); | |
EXPORT(HRESULT) V2Link(iTVPFunctionExporter *exporter) | |
{ | |
TVPInitImportStub(exporter); | |
if (!onV2Link()) return E_FAIL; | |
GlobalRefCountAtInit = TVPPluginGlobalRefCount; | |
return S_OK; | |
} | |
EXPORT(HRESULT) V2Unlink() | |
{ | |
if (TVPPluginGlobalRefCount > GlobalRefCountAtInit || | |
!onV2Unlink()) return E_FAIL; | |
TVPUninitImportStub(); | |
return S_OK; | |
} | |
//-------------------------------------------------------------- | |
// Window.beginMove | |
class tWindowBeginMoveFunction : public tTJSDispatch | |
{ | |
typedef tWindowBeginMoveFunction Self; | |
static tjs_error BeginMove(iTJSDispatch2 *obj) { | |
static ttstr strHWND(TJS_W("HWND")); | |
tTJSVariant val; | |
if (obj && TJS_SUCCEEDED(obj->PropGet(0, strHWND.c_str(), strHWND.GetHint(), &val, obj))) { | |
HWND hwnd = (HWND)(val.AsInteger()); | |
::ReleaseCapture(); | |
::PostMessage(hwnd, WM_SYSCOMMAND, SC_MOVE|2, 0); | |
} | |
return TJS_S_OK; | |
} | |
public: | |
tjs_error TJS_INTF_METHOD FuncCall( | |
tjs_uint32 flag, const tjs_char * membername, tjs_uint32 *hint, | |
tTJSVariant *result, | |
tjs_int numparams, tTJSVariant **param, iTJSDispatch2 *objthis) | |
{ | |
if(membername) return TJS_E_MEMBERNOTFOUND; | |
return BeginMove(objthis); | |
} | |
static bool Link(iTJSDispatch2 *base, const tjs_char *name) { | |
if (base) { | |
Self *func = new Self(); | |
tTJSVariant val(func); | |
func->Release(); | |
return TJS_SUCCEEDED(base->PropSet(TJS_MEMBERENSURE, name, 0, &val, base)); | |
} | |
return false; | |
} | |
static bool Unlink(iTJSDispatch2 *base, const tjs_char *name) { | |
if (base) base->DeleteMember(0, name, 0, base); | |
return true; | |
} | |
}; | |
//-------------------------------------------------------------- | |
static iTJSDispatch2* GetObject(const ttstr &name, iTJSDispatch2 *target = 0) { | |
const tjs_char *p = name.c_str(); | |
const tjs_char *r = p; | |
if(!target) { | |
target = TVPGetScriptDispatch(); | |
if (!target) return NULL; | |
target->Release(); // NoAddRef. | |
} | |
while (*p != 0) { | |
while (*r && *r != '.') r++; | |
ttstr div(p, r-p); | |
if (!div.IsEmpty()) { | |
tTJSVariant val; | |
target = (TJS_SUCCEEDED(target->PropGet(0, div.c_str(), NULL, &val, target))) | |
? val.AsObjectNoAddRef() : 0; | |
if (!target) return 0; | |
} | |
if (*r) r++; | |
p = r; | |
} | |
return target; | |
} | |
bool onV2Link() { return tWindowBeginMoveFunction::Link( GetObject(TJS_W("Window")), TJS_W("beginMove")); } | |
bool onV2Unlink() { return tWindowBeginMoveFunction::Unlink(GetObject(TJS_W("Window")), TJS_W("beginMove")); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Premake 4.x build configuration script | |
-- | |
build_base = "./" | |
project_name = "windowBeginMove" | |
solution (project_name) | |
configurations { "Release", "Debug" } | |
location (build_base .. _ACTION) | |
objdir (build_base .. _ACTION .. "/obj") | |
targetdir ("bin") | |
flags | |
{ | |
"No64BitChecks", | |
-- "ExtraWarnings", | |
"StaticRuntime", -- set /MT(d) option. | |
"NoManifest", -- Prevent the generation of a manifest. | |
"NoMinimalRebuild", -- Disable minimal rebuild. | |
-- "NoIncrementalLink", -- Disable incremental linking. | |
"NoPCH", -- Disable precompiled header support. | |
} | |
includedirs | |
{ | |
-- "./", | |
} | |
configuration "Debug" | |
defines "_DEBUG" | |
flags { "Symbols" } | |
targetsuffix "-d" | |
configuration "Release" | |
defines "NDEBUG" | |
flags { "Optimize" } | |
project (project_name) | |
targetname (project_name) | |
language "C++" | |
kind "SharedLib" | |
files | |
{ | |
"tp_stub.cpp", | |
"Main.cpp", | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment