```
#include <windows.h>
#include <cmath>
// 双缓冲绘图
HDC hdcBuffer;
HBITMAP hbmBuffer;
HBITMAP hOldBmp;
RECT rect;
// 颜色转换函数(完整实现)
COLORREF HSLtoRGB(float h, float s, float l) {
float c = (1 - fabs(2 * l - 1)) * s;
float x = c * (1 - fabs(fmod(h / 60.0f, 2) - 1));
float m = l - c / 2.0f;
float r, g, b;
if (h < 60) { r = c; g = x; b = 0; }
else if (h < 120){ r = x; g = c; b = 0; }
else if (h < 180){ r = 0; g = c; b = x; }
else if (h < 240){ r = 0; g = x; b = c; }
else if (h < 300){ r = x; g = 0; b = c; }
else { r = c; g = 0; b = x; }
return RGB((r + m) * 255, (g + m) * 255, (b + m) * 255);
}
// 窗口过程
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_PAINT: {
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
// 获取时间参数
static float t = 0.0f;
t += 0.01f;
// 初始化缓冲
hdcBuffer = CreateCompatibleDC(hdc);
GetClientRect(hwnd, &rect);
hbmBuffer = CreateCompatibleBitmap(hdc, rect.right, rect.bottom);
hOldBmp = (HBITMAP)SelectObject(hdcBuffer, hbmBuffer);
// 绘制背景
FillRect(hdcBuffer, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH));
// 绘制爱心
const float a = 50.0f; // 基础大小
for(float ii = 0; ii < 6.283f; ii += 0.001f) {
float r = a * (1 - sin(ii));
// 动态参数
float scale = 1.0f + 0.1f * sin(t * 5.0f); // 心跳效果
float phase = t * 50.0f; // 颜色相位
// 坐标变换
int x = (int)(scale * r * cos(ii) + rect.right/2);
int y = (int)(-scale * r * sin(ii) + rect.bottom/2);
// 设置彩虹颜色
SetPixel(hdcBuffer, x, y, HSLtoRGB(fmod(ii*30 + phase, 360), 1.0f, 0.5f));
}
// 交换缓冲
BitBlt(hdc, 0, 0, rect.right, rect.bottom, hdcBuffer, 0, 0, SRCCOPY);
// 清理资源
SelectObject(hdcBuffer, hOldBmp);
DeleteDC(hdcBuffer);
DeleteObject(hbmBuffer);
EndPaint(hwnd, &ps);
InvalidateRect(hwnd, NULL, FALSE); // 持续重绘
break;
}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
// 主函数
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) {
// 注册窗口类
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.hInstance = hInst;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszClassName = L"HeartWindow";
if(!RegisterClassEx(&wc)) return 0;
// 创建窗口
HWND hwnd = CreateWindowEx(
0,
L"HeartWindow",
L"Animated Heart",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
800, 600,
NULL, NULL, hInst, NULL
);
if(!hwnd) return 0;
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
// 消息循环
MSG msg;
while(GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}```[Error] cannot convert 'const wchar_t [12]' to 'LPCSTR {aka const char*}' in assignment
[Error] cannot convert 'const wchar_t*' to 'LPCSTR {aka const char*}' for argument '2' to 'HWND__* CreateWindowExA(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)'
请写出此题修改后的完整代码