acllib 2020-02-19 14:46 采纳率: 60%
浏览 939
已采纳

一个使用TransparentBlt()时出现的问题(使用Dev c++)

代码如下

/*本程序用来插入一张图片*/

#include

#pragma comment(lib,"msimg32.lib")

#define wnd_width 640 //窗口的宽
#define wnd_height 480 //窗口的高

HDC hdc; //窗口设备句柄
HDC memdc; //内存设备句柄
HDC bufmemdc; //内存设备句柄
HBITMAP bmp; //空位图
HBITMAP backbmp; //背景图片

LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
switch(Message) {
case WM_PAINT:{
BitBlt(hdc,0,0,500,500,memdc,0,0,SRCCOPY);

        break;
    }


    case WM_DESTROY: {
        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)(COLOR_WINDOW+1);
wc.lpszClassName = "WindowClass";
wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION); 
wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION); 

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

hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,"WindowClass","Caption",WS_VISIBLE|WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT, 
    CW_USEDEFAULT, 
    wnd_width, 
    wnd_height, 
    NULL,NULL,hInstance,NULL);



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



hdc       = GetDC(hwnd);
bufmemdc  = CreateCompatibleDC(hdc);
memdc     = CreateCompatibleDC(hdc);
bmp       = CreateCompatibleBitmap(hdc,wnd_width,wnd_height);
backbmp   = (HBITMAP)LoadImage(NULL,"./picture/n.bmp",IMAGE_BITMAP,500,500,LR_LOADFROMFILE);

SelectObject(memdc,bmp);
SelectObject(bufmemdc,backbmp);

TransparentBlt(memdc,0,0,500,500,bufmemdc,0,0,500,500,RGB(0,0,5));


while(GetMessage(&msg, NULL, 0, 0) > 0) { /* If no error is received... */
    TranslateMessage(&msg); /* Translate key codes to chars if present */
    DispatchMessage(&msg); /* Send it to WndProc */
}
return msg.wParam;

}

然后编译运行的时候,页面就跳转到MakeFile

Project: 插入图片

Makefile created by Dev-C++ 5.9.2

CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
OBJ = main.o
LINKOBJ = main.o
LIBS = -L"D:/devc++/dev-cpp_gr/dev-cpp_gr/Dev-Cpp/MinGW64/lib" -L"D:/devc++/dev-cpp_gr/dev-cpp_gr/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc -mwindows
INCS = -I"D:/devc++/dev-cpp_gr/dev-cpp_gr/Dev-Cpp/MinGW64/include" -I"D:/devc++/dev-cpp_gr/dev-cpp_gr/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"D:/devc++/dev-cpp_gr/dev-cpp_gr/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.8.1/include"
CXXINCS = -I"D:/devc++/dev-cpp_gr/dev-cpp_gr/Dev-Cpp/MinGW64/include" -I"D:/devc++/dev-cpp_gr/dev-cpp_gr/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"D:/devc++/dev-cpp_gr/dev-cpp_gr/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.8.1/include" -I"D:/devc++/dev-cpp_gr/dev-cpp_gr/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++"
BIN = 插入图片.exe
CXXFLAGS = $(CXXINCS)
CFLAGS = $(INCS)
RM = rm.exe -f

.PHONY: all all-before all-after clean clean-custom

all: all-before $(BIN) all-after

clean: clean-custom
${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
$(CC) $(LINKOBJ) -o $(BIN) $(LIBS)

main.o: main.c
$(CC) -c main.c -o main.o $(CFLAGS)

出现了如下的报错信息:

D:\dev-c++文档\插入图片\main.o main.c:(.text+0x39b): undefined reference to `__imp_TransparentBlt'

D:\dev-c++文档\插入图片\collect2.exe [Error] ld returned 1 exit status
25

D:\dev-c++文档\插入图片\Makefile.win recipe for target '插入图片.exe' failed

求助是什么原因,怎么解决

  • 写回答

1条回答 默认 最新

  • ALTaleX 2020-02-19 17:39
    关注

    很明显你的代码是从哪抄来的
    点击菜单:项目->项目属性->参数->链接
    复制一下内容到“链接”文本框
    "C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib32/libmsimg32.a"
    完成后点击确定

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 已采纳回答 2月6日

悬赏问题

  • ¥50 ZYNQ7020双核FLAHS烧写的问题
  • ¥20 ue 5 中想要实现第一人称人物左右行走摆动的效果,摄像头只向右摆动一次(关键词-结点)
  • ¥15 钢岔管添加弹性约束模拟围岩作用
  • ¥15 AD9164瞬时带宽1.8G,怎么计算出来?
  • ¥15 鼠标右键,撤销删除 复制 移动,要怎样删除
  • ¥15 使用MATLAB进行余弦相似度计算加速
  • ¥15 服务器安装php5.6版本
  • ¥15 我想用51单片机和数码管做一个从0开始的计数表 我写了一串代码 但是放到单片机里面数码管只闪烁一下然后熄灭
  • ¥20 系统工程中,状态空间模型中状态方程的应用。请猛男来完整讲一下下面所有问题
  • ¥15 我想在WPF的Model Code中获取ViewModel Code中的一个参数