int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
WNDCLASS WinClass = { 0 };
WinClass.hInstance = hInstance;
WinClass.lpszClassName = ClassName;
WinClass.lpfnWndProc = WndProc;
WinClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WinClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WinClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
WinClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
int WinX = (GetSystemMetrics(SM_CXSCREEN) / 2) - (CL_WinWidth / 2),
WinY = (GetSystemMetrics(SM_CYSCREEN) / 2) - (CL_WinHeight / 2);
if (!RegisterClass(&WinClass))MessageBox(0, L"注册窗口类名失败!", NULL, MB_OK);
G_hWnd = CreateWindow(ClassName, L"萌萌大乱斗 DemoV1.0.1213",
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
WinX, WinY, CL_WinWidth, CL_WinHeight, NULL, NULL, hInstance, NULL);
if (!G_hWnd)MessageBox(0, L"创建窗口失败!", NULL, MB_OK);
ShowWindow(G_hWnd, SW_SHOW);
UpdateWindow(G_hWnd);
MSG msg = { 0 };
while (GetMessage(&msg,G_hWnd,NULL,NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
char path[256] = { 0 };
switch (uMsg)
{
case WM_CREATE: {
//CoInitialize(nullptr);
Ime.SetMaxLen(14);
GetExePathW(ExePath, sizeof(ExePath));
//初始化程序;
//if (!D2Dx9.InitD3D(hWnd, CL_WinWidth, CL_WinHeight, false)) { MessageBox(hWnd, L"初始化D3D失败!", nullptr, MB_OK); ExitProcess(NULL); }
if (!BASS_Init(-1, 44100, BASS_DEVICE_3D, hWnd, NULL)) { MessageBox(hWnd, L"初始化BASS音频库失败!", nullptr, MB_OK); ExitProcess(NULL); }
CreateWindowExA(NULL,
"EDIT", "",
WS_CHILD | WS_VISIBLE,
10, 10,
300, 300,
hWnd,
NULL,
NULL,
NULL);
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)D3DGameRun, NULL, NULL, NULL);
break;
}
case WM_CLOSE:
BASS_Free();
ExitProcess(0);
break;
case WM_KEYDOWN:
Ime.SetKeyState(TRUE);
ImeEvent(wParam);
break;
case WM_KEYUP:
Ime.SetKeyState(FALSE);
break;
case WM_MOUSEMOVE:
MousePoint.KeyCode = wParam;
MousePoint.x = GET_X_LPARAM(lParam);
MousePoint.y = GET_Y_LPARAM(lParam);
break;
case WM_LBUTTONDOWN:
MousePoint.KeyCode = wParam;
MousePoint.x = GET_X_LPARAM(lParam);
MousePoint.y = GET_Y_LPARAM(lParam);
break;
case WM_RBUTTONDOWN:
MousePoint.KeyCode = wParam;
MousePoint.x = GET_X_LPARAM(lParam);
MousePoint.y = GET_Y_LPARAM(lParam);
break;
case WM_LBUTTONUP:
MousePoint.KeyCode = wParam;
MousePoint.x = GET_X_LPARAM(lParam);
MousePoint.y = GET_Y_LPARAM(lParam);
break;
case WM_RBUTTONUP:
MousePoint.KeyCode = wParam;
MousePoint.x = GET_X_LPARAM(lParam);
MousePoint.y = GET_Y_LPARAM(lParam);
break;
default:
break;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}