如何在C ++ Win32 API的对话框中设置图像? [英] how to set image in dialogbox in c++ win32 API?
问题描述
我正在开发一个C ++ Api项目.
我将使用dialogboxparam创建一个对话框...
我已完成创建和设置文本框,标签和按钮的操作...工作正常...现在我想在对话框顶部添加图像...
我确实在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);
但是没用...任何人都可以帮助解决此问题...提前致谢声纳
最简单的方法是为窗口覆盖WM_PAINT并在该点(在BeginPaint和EndPaint之间)调用绘制位图
这里有一个基于MFC的示例:
i have developing a C++ Api project.
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...
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
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
There is an MFC based example here:
这篇关于如何在C ++ Win32 API的对话框中设置图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!