The program gives the following error:

Error LNK2019 unresolved external symbol long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z) referenced in function _wWinMain@16 Win32_1 ... 
 #include <Windows.h> #include <tchar.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); TCHAR WinName[] = _T("MainFrame"); int APIENTRY _tWinMain(HINSTANCE This, HINSTANCE Prev, LPTSTR cmd, int mode) { HWND hWnd; MSG msg; WNDCLASS wc; wc.hInstance = This; wc.lpszClassName = WinName; wc.lpfnWndProc = WndProc; wc.style = CS_HREDRAW | CS_VREDRAW; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.lpszMenuName = NULL; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); if (!RegisterClass(&wc)) return 0; hWnd = CreateWindowW(WinName, _T("Windowsddd"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, nullptr, This, nullptr); ShowWindow(hWnd, mode); while (GetMessage(&msg, NULL, 0, 0)) { //TranslateMessge(&msg); //DispatchMessge(&msg); } return 0; } 

    1 answer 1

    You have this function, WndProc , declared at the beginning of the module.

     LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 

    but not defined anywhere. Therefore, a linker message is issued that he cannot determine the address of this function in the sentence

     wc.lpfnWndProc = WndProc; 

    You should define this function.

    This function can be defined in its simplest form, for example, as follows.

     LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch ( message ) { case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; }