設置窗口及按鈕背景圖片
来源:互联网 发布:华为手机查看网络制式 编辑:程序博客网 时间:2024/05/17 22:41
first, register a window class:
WNDCLASSEX wcex = { sizeof(wcex) };
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = _WndProc;
wcex.hInstance = _hInst;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
//wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
//set window background image
HBITMAP image;
image = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_BITMAP_IMAGE));
wcex.hbrBackground = (HBRUSH)CreatePatternBrush(image);
wcex.lpszClassName = c_szClassName;
return RegisterClassEx(&wcex)
then, create the windows:
_hWnd = CreateWindowEx(
WS_EX_TOPMOST|WS_EX_LAYERED,
c_szClassName,
c_szDisconnected,
WS_DLGFRAME,
x, y, width, height,
NULL,
NULL, _hInst, NULL);
the above text in red are how to set window background picture. My focus is the first parameter of LoadBItmap fucntion, g_inst.
ref to a network resource here:
http://blog.csdn.net/sandro_zhang/article/details/6837662
,the g_inst parameter is replaced by (HINSTANCE)GetModuleHandle(NULL).
this may be ok , but not for my case.
In my code, the window is created in dll, so the g_inst is in
STDAPI_(BOOL) DllMain(__in HINSTANCE hinstDll, __in DWORD dwReason, __in void *),
yes, it is the hinstaDll ,the DLL module instance.
How about to create Button? the code is below:
_hWndButton = CreateWindow(L"Button", L"xxx",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
x,y , width, height,
_hWnd,
NULL,
_hInst,
NULL);
then to set button background picture:
HBITMAP image;
image = LoadBitmap(g_hinst,MAKEINTRESOURCE(IDB_TILE_IMAGE));
::SendMessage(_hWndButton,BM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)(image));
- 設置窗口及按鈕背景圖片
- iPhone 自訂navigation bar全攻略 包含按鈕,高度及圖片背景
- android开发清除ImageView背景圖片
- 对话框背景位图片
- 如何实现在单文档的窗口背景上贴上图片?
- 始终拉伸填满窗口的背景及层的透明
- CMD窗口标题及字体颜色、背景颜色设置
- 主窗口及控件背景颜色信息设置
- VS简易示波器(一):窗口布局及背景绘制
- Qt学习(1):ui设计给窗口做背景及控件背景添加方法
- 48.java编程思想——创建窗口和程序片 按钮及事件
- Qt的窗口背景及窗口风格统一与焕肤
- Qt的窗口背景及窗口风格统一与焕肤
- 无边框图片背景窗体自由移动
- Android大图片背景性能优化篇
- 圖片
- java窗口背景
- DXUT窗口设置背景
- curl POST的数据大于1024字节
- WPF 应用程序开机自启动及窗体关闭按钮作用失效的解决办法
- android屏幕适配及尺寸研究
- RGB16转换RGB24
- Hibernate自身双向一对多关联
- 設置窗口及按鈕背景圖片
- xcode制作和使用静态库
- 关于谷歌地图API程序的一些预想
- V4L2 中error 22, Invalid argument的解决方法
- Android Intent 用法全面总结
- Windows的系统信息
- shell中并,或的用法
- Stagefright 之 AudioPlayback的流程
- linux中的MBR记录详解