how to set image in dialogbox in c++ win32 API?(如何在 c++ win32 API 的对话框中设置图像?)
问题描述
我正在开发一个 C++ Api 项目.
i have developing a C++ Api project.
我将使用 dialogboxparam 创建一个对话框...
i will use dialogboxparam to create a dialogbox...
我已完成创建和设置文本框、标签和按钮...它的工作正常...
i done to create and set the textbox,labels and buttons... its work fine...
现在我想在对话框顶部添加一张图片...
now i want to add a image in the top of the dialogbox...
我确实在 WM_INITDIALOG 中使用了此代码:
i did use this code in WM_INITDIALOG:
HBITMAP hImage= (HBITMAP)LoadImage(NULL,L"C:\WINDOWS\system32\BMA-Images\login-header",IMAGE_BITMAP,LR_DEFAULTSIZE ,LR_DEFAULTSIZE ,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
SendMessage(_hwnd,STM_SETIMAGE,IMAGE_BITMAP,(LPARAM)hImage);
但它没有工作......任何人都可以帮助解决这个问题...提前致谢索努
But it didnt work... Can anyone help to resolve this... Thanks in advance Sonu
推荐答案
最简单的方法是覆盖窗口的 WM_PAINT 并在该点(在 BeginPaint 和 EndPaint 之间)调用绘制位图
The easiest way is to override the WM_PAINT for the window and paint the bitmap at that point (between the BeginPaint and EndPaint) calls
这里有一个基于 MFC 的示例:
There is an MFC based example here:
http://www.programmersheaven.com/mb/mfc_coding/113034/113034/how-do-i-set-a-background-picture-in-a-dialog-box-/
这篇关于如何在 c++ win32 API 的对话框中设置图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 c++ win32 API 的对话框中设置图像?
基础教程推荐
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- c++ STL设置差异 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
