面白そうなので作ってみました。
なるべくDXライブラリだけでやるとしたらこんな感じですかね。
ひとつ目のプログラムを起動してから、ふたつ目のプログラムを起動してください。
コード:
#include "DxLib.h"
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
SetMainWindowText("ユニークな名前");
SetWindowStyleMode(2);
ChangeWindowMode(TRUE);
SetDrawScreen(DX_SCREEN_BACK);
SetGraphMode(200, 200, 32);
SetUseBackBufferTransColorFlag(TRUE);
SetBackgroundColor(0, 255, 0);
if (DxLib_Init() != 0) return 0;
SetTransColor(0, 255, 0);
while (ProcessMessage() == 0 && ScreenFlip() == 0 && ClearDrawScreen() == 0) {
DrawBox(0, 0, 200, 200, GetColor(0,255,0), TRUE);
DrawCircle(100, 100, 100, GetColor(0,0,255), TRUE);
}
DxLib_End();
return 0;
}
コード:
#include "DxLib.h"
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
ChangeWindowMode(TRUE);
if (DxLib_Init() != 0) return 0;
HWND hWnd = FindWindow("ユニークな名前", NULL); // なぜかクラス名に
while (ProcessMessage() == 0 && ScreenFlip() == 0 && ClearDrawScreen() == 0) {
int MouseX, MouseY;
GetMousePoint(&MouseX, &MouseY);
DrawCircle(MouseX, MouseY, 100, GetColor(255,0,0), TRUE);
if (hWnd) {
POINT pt = {MouseX, MouseY};
ClientToScreen(GetMainWindowHandle(), &pt);
int x = pt.x - 100;
int y = pt.y - 100;
SetWindowPos(hWnd, GetMainWindowHandle(), x, y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
}
}
DxLib_End();
return 0;
}