添加项目文件。
This commit is contained in:
parent
84fd5d26ed
commit
78f3996215
167
veinCur.cpp
Normal file
167
veinCur.cpp
Normal file
@ -0,0 +1,167 @@
|
||||
#include <windows.h>
|
||||
#include <gdiplus.h>
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
using namespace Gdiplus;
|
||||
using namespace std;
|
||||
#pragma comment (lib,"Gdiplus.lib")
|
||||
|
||||
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
Gdiplus::Graphics* graphics;
|
||||
ULONG_PTR gdiplusToken;
|
||||
HWND hwnd;
|
||||
mutex mtx;
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
|
||||
void CreateFullScreenTransparentWindow(const wchar_t* window_name, const wchar_t* class_name);
|
||||
int g_hotkeyId = 1;
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow)
|
||||
{
|
||||
|
||||
HANDLE hMutex = CreateMutex(NULL, FALSE, L"cursorAnim");
|
||||
if (hMutex == NULL) {
|
||||
return 1;
|
||||
}
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS) {
|
||||
MessageBox(nullptr, L"已运行", L"错误", MB_OK);
|
||||
CloseHandle(hMutex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
CreateFullScreenTransparentWindow(L"鼠标特效", L"cursor_anim");
|
||||
HHOOK hook = SetWindowsHookEx(WH_MOUSE_LL, MouseProc, NULL, 0);
|
||||
|
||||
|
||||
MSG msg;
|
||||
while (GetMessage(&msg, nullptr, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
Sleep(1);
|
||||
}
|
||||
CloseHandle(hMutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CreateFullScreenTransparentWindow(const wchar_t* window_name, const wchar_t* class_name)
|
||||
{
|
||||
WNDCLASS wc = {};
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.hInstance = GetModuleHandle(nullptr);
|
||||
wc.lpszClassName = class_name;
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(255, 0, 0));
|
||||
if (!RegisterClass(&wc))
|
||||
{
|
||||
MessageBox(nullptr, L"窗口类注册失败", L"错误", MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
hwnd = CreateWindowExW(WS_EX_TRANSPARENT | WS_EX_LAYERED | WS_EX_TOPMOST | WS_EX_TOOLWINDOW, class_name, window_name, WS_POPUP,
|
||||
0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
|
||||
nullptr, nullptr, GetModuleHandle(nullptr), nullptr);
|
||||
if (hwnd == nullptr)
|
||||
{
|
||||
MessageBox(nullptr, L"窗口创建失败", L"错误", MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
SetLayeredWindowAttributes(hwnd, RGB(255, 0, 0), 100, LWA_COLORKEY);
|
||||
ShowWindow(hwnd, SW_SHOW);
|
||||
UpdateWindow(hwnd);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
|
||||
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
|
||||
graphics = new Gdiplus::Graphics(hwnd);
|
||||
break;
|
||||
}
|
||||
case WM_TIMER:
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
{
|
||||
MessageBox(nullptr, L"关闭", L"关闭", MB_OK);
|
||||
delete graphics;
|
||||
UnregisterHotKey(hwnd, g_hotkeyId);
|
||||
Gdiplus::GdiplusShutdown(gdiplusToken);
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return DefWindowProc(hwnd, message, wparam, lparam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vine(int x1, int y1, float anchor, float turn, int speed, int cost, Color color, int count, int clone)
|
||||
{
|
||||
if (speed <= 0)
|
||||
{
|
||||
Sleep(300);
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
int x2 = x1 + (speed)*cos(anchor);
|
||||
int y2 = y1 + (speed)*sin(anchor);
|
||||
Pen penline(color, speed);
|
||||
penline.SetEndCap(LineCapRound);
|
||||
penline.SetStartCap(LineCapRound);
|
||||
mtx.lock();
|
||||
graphics->DrawLine(&penline, x1, y1, x2, y2);
|
||||
mtx.unlock();
|
||||
Sleep(1);
|
||||
if (clone > 0 && rand() % 10 == 0)
|
||||
{
|
||||
int x_copy = x1;
|
||||
int y_copy = y1;
|
||||
float anchor_copy = anchor + rand() % 10 / 26.0;
|
||||
float turn_copy = turn * (-1 + rand() % 2 * 2);
|
||||
int speed_copy = speed + rand() % 3;
|
||||
int cost_copy = cost + rand() % 3;
|
||||
thread t(vine, x_copy, y_copy, anchor_copy, turn_copy, speed_copy, cost_copy, Color(rand() % 50, 100 + rand() % 100, 20 + rand() % 50), 0, --clone);
|
||||
t.detach();
|
||||
}
|
||||
if (count % 10 == 0)
|
||||
speed -= cost;
|
||||
anchor += turn;
|
||||
if (count % 3 == 0)
|
||||
turn += turn / 2;
|
||||
if (turn > 0.6)
|
||||
speed = 0;
|
||||
vine(x2, y2, anchor, turn, speed, cost, color, count, clone);
|
||||
Sleep(count / 3);
|
||||
Pen erase(Color(255, 0, 0), speed * 2 + 3);
|
||||
erase.SetEndCap(LineCapRound);
|
||||
erase.SetStartCap(LineCapRound);
|
||||
mtx.lock();
|
||||
graphics->DrawLine(&erase, x1, y1, x2, y2);
|
||||
mtx.unlock();
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
|
||||
if (nCode >= 0) {
|
||||
if (wParam == WM_LBUTTONDOWN) {
|
||||
// 获取鼠标点击位置
|
||||
POINT p;
|
||||
GetCursorPos(&p);
|
||||
float base = rand() % 10 / 3;
|
||||
thread t0(vine, p.x, p.y, 0 + base, 0.02, 5, 2, Color(0, 255, 0), 0, 3);
|
||||
t0.detach();
|
||||
thread t1(vine, p.x, p.y, 2 + base, 0.010, 5, 2, Color(0, 255, 0), 0, 3);
|
||||
t1.detach();
|
||||
thread t2(vine, p.x, p.y, -2 + base, 0.025, 5, 2, Color(0, 255, 0), 0, 3);
|
||||
t2.detach();
|
||||
}
|
||||
}
|
||||
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||
}
|
||||
31
veinCur.sln
Normal file
31
veinCur.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35312.102
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "veinCur", "veinCur.vcxproj", "{7850B2FB-9E7D-4A88-A226-1B6C70D3F5C9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7850B2FB-9E7D-4A88-A226-1B6C70D3F5C9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{7850B2FB-9E7D-4A88-A226-1B6C70D3F5C9}.Debug|x64.Build.0 = Debug|x64
|
||||
{7850B2FB-9E7D-4A88-A226-1B6C70D3F5C9}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{7850B2FB-9E7D-4A88-A226-1B6C70D3F5C9}.Debug|x86.Build.0 = Debug|Win32
|
||||
{7850B2FB-9E7D-4A88-A226-1B6C70D3F5C9}.Release|x64.ActiveCfg = Release|x64
|
||||
{7850B2FB-9E7D-4A88-A226-1B6C70D3F5C9}.Release|x64.Build.0 = Release|x64
|
||||
{7850B2FB-9E7D-4A88-A226-1B6C70D3F5C9}.Release|x86.ActiveCfg = Release|Win32
|
||||
{7850B2FB-9E7D-4A88-A226-1B6C70D3F5C9}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {B17741C1-FBB6-41B2-A947-FCD09A623D05}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
135
veinCur.vcxproj
Normal file
135
veinCur.vcxproj
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{7850b2fb-9e7d-4a88-a226-1b6c70d3f5c9}</ProjectGuid>
|
||||
<RootNamespace>veinCur</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="veinCur.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
22
veinCur.vcxproj.filters
Normal file
22
veinCur.vcxproj.filters
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="veinCur.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Loading…
Reference in New Issue
Block a user