C++ TransparentBlt 问题

我使用的是DEV-C++,使用TransparentBlt函数时就编译错误了,求大神帮忙!以下是源代码:#include<windows.h>#include<cstdi... 我使用的是DEV-C++ ,使用TransparentBlt函数时就编译错误了,求大神帮忙!
以下是源代码:

#include <windows.h>
#include <cstdio>
#include <ctime>
#pragma comment(lib,"Msimg32.lib")
HDC g_hdc;
HDC m_hdc;
HDC mm_hdc;
HBITMAP bg;
HBITMAP flying[3];
HFONT hfont;
int x=0;

void game_Init(HWND hwnd)
{
char s[20];
srand(time(NULL)); sprintf(s,"BK%d",rand()%2);
HINSTANCE hInstance;

g_hdc = GetDC(hwnd);
m_hdc = CreateCompatibleDC(g_hdc);
mm_hdc = CreateCompatibleDC(m_hdc);

bg= LoadBitmap(hInstance,s);

flying[0]=LoadBitmap(hInstance,"BIRD00");
flying[1]=LoadBitmap(hInstance,"BIRD01");
flying[2]=LoadBitmap(hInstance,"BIRD02");
}

void game_Paint(HWND hwnd)
{
SelectObject(m_hdc,bg);
BitBlt(g_hdc,0,0,800,600,m_hdc,0,0,SRCCOPY);

SelectObject(m_hdc,flying[x]); x++; if(x>2) x=0;
TransparentBlt(m_hdc,115,200,50,50,mm_hdc,0,0,50,50,RGB(0,0,0));//ÕâÀïÓÐÎÊÌâ
BitBlt(g_hdc,115,200,50,50,m_hdc,0,0,SRCCOPY);
}

void game_Clear(HWND hwnd)
{
ReleaseDC(hwnd,g_hdc);
DeleteObject(hfont);
DeleteObject(bg);
DeleteObject(m_hdc);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {

switch(Message) {

case WM_PAINT:
ValidateRect(hwnd,NULL);
break;

case WM_DESTROY: {
game_Clear(hwnd);
PostQuitMessage(0);
break;
}

default:
return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
WNDCLASSEX wc; HWND hwnd;
MSG msg;

memset(&wc,0,sizeof(wc));
wc.cbSize = sizeof(WNDCLASSEX);
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);

wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
wc.lpszClassName = "WindowClass";
wc.hIcon = LoadIcon(hInstance,"DICO");
wc.hIconSm = LoadIcon(hInstance,"DICO");

if(!RegisterClassEx(&wc)) {
MessageBox(NULL, "Window Registration Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
return 0;
}

hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,"WindowClass","Flappy Bird",WS_VISIBLE|WS_OVERLAPPEDWINDOW,
370, 100, 297, 540, NULL,NULL,hInstance,NULL);

if(hwnd == NULL) {
MessageBox(NULL, "Window Creation Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
return 0;
}

game_Init(hwnd);

ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);

while (msg.message != WM_QUIT) {
if (PeekMessage(&msg,0,0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
game_Paint(hwnd);
Sleep(400);
}
}
return msg.wParam;
}
展开
 我来答
arongustc
科技发烧友

2017-01-26 · 智能家居/数码/手机/智能家电产品都懂点
知道大有可为答主
回答量:2.3万
采纳率:66%
帮助的人:5970万
展开全部
你错误信息呢?贴代码别人只能肉眼编译了:)
至少一点是错误的,RGB(0,0,0)是不能作为它最后一个参数的,你需要选择其他颜色。但是这不会导致编译错误
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式