需要有关创建透明树视图控件的说明 [英] Need instructions for creating transparent Tree view control

查看:101
本文介绍了需要有关创建透明树视图控件的说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我想首先感谢所有花时间查看此主题并尝试提供帮助的人。



我在对话框中使用资源编辑器进行了树视图控制。



树视图也有图像,线条和按钮。



我只需要说明如何让它的背景透明。



Tree的节点也应该有透明的背景。



我认为我应该使用自定义绘图,但我不是很有经验,这就是我寻求帮助的原因。


代码示例或片段会非常有用,但我也很感谢书面说明,但请详细说明,因为我不是很有经验。



我使用 WIN32 API在MS Visual Studio Express 2008,Windows XP,C ++中工作。



这就是全部,再次感谢所有人试着帮忙。非常感谢你!



编辑#1:

------------ ------------------



我尝试了对树视图进行子类化,并让它具有透明背景,但是树的项目没有显示。



我在这里发布子类程序的代码,希望有人可以帮我提一些建议:



Hello everyone!

I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.

I have made a tree view control in dialog box, using resource editor.

Tree view also has images, lines and buttons.

I just need instructions on how to make it's background transparent.

Tree's nodes also should have transparent background.

I think that I should use custom draw for this, but I am not very experienced, that is why I ask for help.

Code example, or snippet would be very helpful, but I would also appreciate written instructions as well, but make them detailed please, since I am not very experienced.

I work in MS Visual Studio Express 2008, on Windows XP, in C++, using pure WIN32 API.

That would be all, again I thank everyone who tries to help.Thank you very very much!

EDIT #1:
------------------------------

I have tried subclassing the tree view, and got it to have transparent background, but tree's items don't show.

I am posting the code of the subclassing procedure here in hope that someone can help me with some advice:

LRESULT CALLBACK wpTree(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{

	case WM_PAINT:
		{
			PAINTSTRUCT ps;

			HDC hdc = BeginPaint(hWnd, &ps), 
                            hdcMem = CreateCompatibleDC(hdc);
		
			RECT r;

			GetClientRect( hWnd, &r );

			HBITMAP bmp = CreateCompatibleBitmap( hdcMem,
                                          r.right - r.left, r.bottom - r.top ),
                                bmpOld;

			bmpOld = (HBITMAP)SelectObject( hdcMem, bmp );

			TransparentBlt( hdc, 0, 0, r.right - r.left,
                                        r.bottom - r.top, hdcMem, 0, 0, 
                                        r.right - r.left,
                                        r.bottom - r.top, 
                                        RGB( 0, 0, 0 ) );

			SelectObject( hdcMem, bmpOld );

			DeleteObject(bmp);

			DeleteDC(hdcMem);

			EndPaint(hWnd, &ps);

		}
		return 0L;

	case WM_ERASEBKGND:
		
		return 0L;
	}

	return CallWindowProc( wp, hWnd, message, wParam, lParam );
}

推荐答案

以下是有关此区域的优秀且深入的信息:



Win32 API中的自定义控件:基础知识 [ ^ ]



看看这个:自定义绘制的TreeList控件 [ ^ ]



BTW:定制MS控件是一些繁重的,所以它不适合初学者; - )
Here is outstanding and deep information about this area:

Custom Controls in Win32 API: The Basics[^]

And look at this: A custom-drawn TreeList Control[^]

BTW: customizing a MS-control is some"heavy lifting", so it isnt suitable for a beginner ;-)


在StackOverflow上提供了一个作为项目文件链接的解决方案。



可悲的是,它最近删除了它/>


尽管如此,它帮助我制作了一个可接受的透明树视图控件。



这是指向关于StackOverflow的问题,如果解决方案的链接再次变为活动状态:



http://stackoverflow.com/questions/17888038/transparent-tree-view-control [ ^ ]
There was a solution provided as a link to the project file, on StackOverflow.

Sadly, the poster of it has deleted it recently.

Still, it helped me to make an acceptable transparent tree view control.

Here is the link to the question on StackOverflow, in case that link to the solution becomes active again:

http://stackoverflow.com/questions/17888038/transparent-tree-view-control[^]


这篇关于需要有关创建透明树视图控件的说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆