0

Here is the original code.

 #include <windows.h>

LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);

 int WINAPI Winmain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmdLine, int nCmdShow)
{

HWND hwnd;
MSG msg;
WNDCLASS WndClass;
WndClass.style = CS_HREDRAW | CS_VREDRAW;
WndClass.lpfnWndProc = WndProc;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hInstance = hInstance;
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.lpszMenuName = NULL;
WndClass.lpszClassName = "Window Class Name";
RegisterClass(&WndClass);
hwnd = CreateWindow("Window Class Name", "Window Title Name", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);

ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0))
{
    TranslateMessage(&msg);
    DispatchMessage(&msg);
}
return msg.wParam;
}

 LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
 {
HDC hdc;
PAINTSTRUCT ps;
RECT rect;

switch (iMsg)
{
case WM_CREATE:
    break;
case WM_PAINT:
    hdc = BeginPaint(hwnd, &ps);
    //TextOut(hdc, 0, 0, "HelloWorld", 10);
    rect.left = 50;
    rect.top = 40;
    rect.right = 200;
    rect.bottom = 120;
    DrawText(hdc, "HelloWorld", 10, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
    EndPaint(hwnd, &ps);
    break;
case WM_DESTROY:
    PostQuitMessage(0);
    break;
}
return DefWindowProc(hwnd, iMsg, wParam, lParam);

}

I think there is no problem in this code, but there is still fatal error LNK2019 & LNK1120.

I already tried changing to console to windows. But still same.

Can anybody help me? I cannot check anything in API programming.

Cyclonecode
  • 29,115
  • 11
  • 72
  • 93
Emphy
  • 9
  • 1
  • possible duplicate of [C++ compile error (LNK1120 and LNK2019) with Visual Studio](http://stackoverflow.com/questions/20870676/c-compile-error-lnk1120-and-lnk2019-with-visual-studio) – Cyclonecode Oct 06 '14 at 07:21
  • 1
    If you need help with an error message it would help tremendously to post said error message. – IInspectable Oct 06 '14 at 12:42

0 Answers0