首页
学习
活动
专区
圈层
工具
发布

截图
EN

Stack Overflow用户
提问于 2012-10-17 03:46:55
回答 2查看 371关注 0票数 3

我正在尝试使用以下代码:

代码语言:javascript
复制
bool SaveBMPFile(char *filename, HBITMAP bitmap, HDC bitmapDC, int width, int height);

bool ScreenCapture(int x, int y, int width, int height, char *filename){
// get a DC compat. w/ the screen
HDC hDc = CreateCompatibleDC(0);

// make a bmp in memory to store the capture in
HBITMAP hBmp = CreateCompatibleBitmap(GetDC(0), width, height);

// join em up
SelectObject(hDc, hBmp);

// copy from the screen to my bitmap
BitBlt(hDc, 0, 0, width, height, GetDC(0), x, y, SRCCOPY);

// save my bitmap
bool ret = SaveBMPFile(filename, hBmp, hDc, width, height);

// free the bitmap memory
DeleteObject(hBmp);

return ret;
}

它抛出以下错误:

代码语言:javascript
复制
bot.c|185|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'SaveBMPFile'|
bot.c|187|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ScreenCapture'|

我能做什么?尝试不同的代码将不起作用,并尝试使用Gdi+-也错误。

EN

回答 2

Stack Overflow用户

发布于 2012-10-17 03:51:26

我想你要错过#include <stdbool.h>了。

bool不是C中的原语类型。必须包含<stdbool.h>标头才能获得其定义。

票数 6
EN

Stack Overflow用户

发布于 2012-10-17 03:51:50

很可能您的错误实际上发生在您所显示的代码之前。错误消息说它需要这些东西中的一个;因此,在您所显示的代码片段之前,很可能有一行没有以分号(;)结束,或者一个函数没有以右大括号(})结束。一件事是确保你没有把它粘贴到另一个函数的中间;你不能在C中嵌套函数。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12922348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档