gpt4 book ai didi

c - 错误 LNK1120 : 1 unresolved external - VS13 C

转载 作者:太空宇宙 更新时间:2023-11-04 07:01:05 24 4
gpt4 key购买 nike

<分区>

我试过编译这段代码:

#include <windows.h>
#include <commctrl.h>


#define ID_TABCTRL 1
#define ID_EDIT 2
#define BTN_ADD 3
#define BTN_DEL 4
#define BTN_CLR 5
#define MAX_TAB_LEN 15

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

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PWSTR pCmdLine, int nCmdShow) {

MSG msg;
WNDCLASSW wc = { 0 };
wc.lpszClassName = L"Tab control";
wc.hInstance = hInstance;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor(0, IDC_ARROW);

RegisterClassW(&wc);
CreateWindowW(wc.lpszClassName, L"Tab control",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 380, 230, 0, 0, hInstance, 0);

while (GetMessage(&msg, NULL, 0, 0)) {

TranslateMessage(&msg);
DispatchMessage(&msg);
}

return (int)msg.wParam;
}

WINCOMMCTRLAPI BOOL WINAPI InitCommonControlsEx(_In_ const INITCOMMONCONTROLSEX *picce);

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam) {

TCITEMW tie;
wchar_t text[4];
LRESULT count, id;
INITCOMMONCONTROLSEX icex;

switch (msg) {

case WM_CREATE:

icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icex);

hTab = CreateWindowW(WC_TABCONTROLW, NULL, WS_CHILD | WS_VISIBLE,
0, 0, 200, 150, hwnd, (HMENU)ID_TABCTRL, NULL, NULL);

hEdit = CreateWindowW(WC_EDITW, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,
250, 20, 100, 25, hwnd, (HMENU)ID_EDIT, NULL, NULL);

SendMessage(hEdit, EM_SETLIMITTEXT, MAX_TAB_LEN, 0);

CreateWindowW(WC_BUTTONW, L"Add", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
250, 50, 100, 25, hwnd, (HMENU)BTN_ADD, NULL, NULL);

CreateWindowW(WC_BUTTONW, L"Delete", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
250, 80, 100, 25, hwnd, (HMENU)BTN_DEL, NULL, NULL);

CreateWindowW(WC_BUTTONW, L"Clear", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
250, 110, 100, 25, hwnd, (HMENU)BTN_CLR, NULL, NULL);
break;

case WM_COMMAND:

switch (LOWORD(wParam)) {

case BTN_ADD:

GetWindowTextW(hEdit, text, 250);

if (lstrlenW(text) != 0) {

tie.mask = TCIF_TEXT;
tie.pszText = text;
count = SendMessageW(hTab, TCM_GETITEMCOUNT, 0, 0);
SendMessageW(hTab, TCM_INSERTITEMW, count,
(LPARAM)(LPTCITEM)&tie);
}
break;

case BTN_DEL:

id = SendMessageW(hTab, TCM_GETCURSEL, 0, 0);

if (id != -1) {

SendMessageW(hTab, TCM_DELETEITEM, 0, id);
}
break;

case BTN_CLR:

SendMessageW(hTab, TCM_DELETEALLITEMS, 0, 0);
break;
}
break;

case WM_DESTROY:

PostQuitMessage(0);
break;
}

return(DefWindowProcW(hwnd, msg, wParam, lParam));
}

看起来像这个库:

#include <commctrl.h>

给我以下错误:

error LNK2019: unresolved external symbol        __imp__InitCommonControlsEx@4 referenced in function _WndProc@16   C:\Users\User\Desktop\Magshimim\Magshimim EX1\Magshimim EX1\01.obj  Magshimim EX1

现在代码是来自此处的示例代码:http://zetcode.com/gui/winapi/advancedcontrols/

所以我发现我的编译器有问题...谁能帮我找到问题并改正?

编辑:这个问题不是重复的,因为被引用的重复以非常笼统的方式谈论错误本身,作为一个初学者,我没有能力从这样的问题中建立一个正确的答案,因为这个代码被许多检查过的人使用这个例子我认为它不能提出一个具体的问题

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com