Ошибка WinApi C lang
Язык C
Visual Studio 19
SDK 10.0
Код:
#include <stdio.h>
#include <stdlib.h>
//#include "main.h"
#include <Windows.h>
wchar_t classname = L'window';
LRESULT WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
if (message == WM_DESTROY) {
PostQuitMessage(0);
return 0;
}
else if (message == WM_KEYDOWN)
printf("code = %d \n", wparam);
return DefWindowProcA(hwnd, message, wparam, lparam);
}
int main() {
HDC hDCScreen = GetDC(NULL);
int Horres = GetDeviceCaps(hDCScreen, HORZRES);
int Vertres = GetDeviceCaps(hDCScreen, VERTRES);
int cordX = (Horres / 2) - 120;
int cordY = (Vertres / 2) - 160;
WNDCLASSA wcl;
memset(&wcl, 0, sizeof(WNDCLASSA));
wcl.lpszClassName = classname;
wcl.lpfnWndProc = WndProc;
RegisterClassA(&wcl);
HWND hwnd;
hwnd = CreateWindow(classname, L"simple window", WS_OVERLAPPEDWINDOW, cordX, cordY, 240, 320, NULL, NULL, NULL, NULL);
ShowWindow(hwnd, SW_SHOWNORMAL);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
DispatchMessage(&msg);
}
return 0;
}
Ошибка:
Ошибка C2440 =: невозможно преобразовать "LRESULT (__cdecl *)(HWND,UINT,WPARAM,LPARAM)" в "WNDPROC" Interface C:\Users\pepe\source\repos\Interface\Interface\main.c 31 ```