我有点卡住这一点,并会感谢解决这个问题的帮助。 我正在使用窗口GDI,根据这个链接,包括windows.h是什么是需要使用TextOut函数等,但我仍然收到一些未定义的引用错误消息,我卡住了。
**未定义的引用“TextOutA @ 20”|
未定义的引用“CreateDCA @ 16”|
未定义的引用'逃生@ 20'|
对'DeleteDC @ 4'的未定义引用| **
#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应该可以解决问题。 🙂
哦,朋友,如果你遇到这种类型的错误在开发CPP,然后去工具 – > compliler选项 – >点击设置选项卡 – >连接器 – >改变不创建控制台窗口为“是” – >点击OK.Your问题可能得到解决。