gpt4 book ai didi

c++ - 未定义对 `TextOutA@20' 的引用

转载 作者:行者123 更新时间:2023-11-30 17:26:02 29 4
gpt4 key购买 nike

我有点卡在这个问题上,希望能帮助解决这个问题。我正在使用窗口 GDI,根据此链接,包括 windows.h 是使用 TextOut 函数等所需的内容,但我仍然收到一些未定义的引用错误消息,并且我陷入了困境。

**对“TextOutA@20”的 undefined reference |

对“CreateDCA@16”的 undefined reference |

对“Escape@20”的 undefined reference |

对“DeleteDC@4”的 undefined reference |**

#include <Windows.h>// HDC is a typedef defined in the windows.h library
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <strstream>
#include <string.h>
using namespace std;

#define IDM_QUIT 102
#define EXAMPLE 101
#define IDM_PRINT 27
#define IDM_SHOW 1

//this excerpt demonstrates how to get the handle to a device context ysing the BegingPaint() GDI function
long FAR PASCAL _export WINDOWPROCEDURE(HWND hwnd, UINT message, UINT wParam, LONG Param)
{
HDC hdc;
PAINTSTRUCT ps;
RECT area;
char PInfo[80]="";
char DriverName[20];
char DeviceName[40];
char Other[20];
int X,Y;
X=100;
Y=100;

switch(message)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
TextOut(hdc,X,Y, "Speed of Light", 14);
EndPaint(hwnd, &ps);

case IDM_SHOW:
hdc = GetDC(hwnd);
TextOut(hdc, X,Y, "Speed of Light", 14);
ReleaseDC(hwnd, hdc);

case IDM_PRINT:
GetProfileString("windows", "device", "", PInfo,80);
istrstream In(PInfo);
In.getline(DeviceName, 80, ',');
In.getline(DriverName, 80, ',');
In.getline(Other,80, ',');
hdc = CreateDC(DriverName, DeviceName, Other, NULL);
Escape(hdc,
STARTDOC,8,
(LPSTR)"EXAMPLE",0L);
TextOut(hdc, X, Y, "Speed of Light", 14);
Escape(hdc, NEWFRAME, 0,0L, 0L);
Escape(hdc, ENDDOC, 0,0L, 0L);
DeleteDC(hdc);
}

return 0;
}

最佳答案

链接到 gdi32.lib 应该可以解决问题。 :)

关于c++ - 未定义对 `TextOutA@20' 的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26897490/

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