Kob*_*kie 4 c++ windows winapi
我有点坚持这一点,并希望得到帮助解决这个问题.我正在使用窗口GDI,并根据此链接,包括windows.h是使用TextOut函数所需的,但我仍然得到一些未定义的引用错误消息,我被卡住了.
**未定义引用`TextOutA @ 20'|
未定义引用`CreateDCA @ 16'|
未定义引用`Escape @ 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;
}
Run Code Online (Sandbox Code Playgroud)