gpt4 book ai didi

c++ - VC++ win32 API编程 : how can I get the image out of the clipboard and display it in a windows?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:26:03 28 4
gpt4 key购买 nike

在内存 DC 上使用 SelectObject() 将位图选择到其中。这让我不解。看了msdn还是不知道SelectObject()的第二个参数怎么填。

最佳答案

调用OpenClipbard()打开剪贴板并调用 GetClipboardData()使用 CF_BITMAP 类型来获取存储在剪贴板上的图像数据的句柄。如果剪贴板上没有图像,则返回 NULL 句柄。

然后,在窗口的 WM_PAINT 处理程序中,使用 BeginPaint()获取用于绘制到窗口中的设备上下文,并使用 CreateCompatibleDC()为位图创建内存设备上下文。使用 SelectObject()在你的内存DC上选择位图进去,最后用BitBlt()将位图从内存 DC 传送到窗口的 DC。别忘了清理——调用DeleteDC()删除内存DC,调用EndPaint()结束绘图。

最后,调用CloseClipboard()当你完成时。请注意,剪贴板拥有位图句柄,一旦调用 CloseClipboard(),位图就会被销毁。因此,如果您想在关闭剪贴板后保留位图,则需要复制它。

关于c++ - VC++ win32 API编程 : how can I get the image out of the clipboard and display it in a windows?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1529342/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com