位图顶部的静态控件 [英] Static Control on top of Bitmap

查看:96
本文介绍了位图顶部的静态控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用计时器在hdc上打印预先缓冲的位图. (我希望这是正确的说法)
现在,我想在所有这些之上看到一个静态控件.我尝试在调用WM_Create事件时创建它,然后在打印位图后将其移到顶部.但是它并没有显示在顶部.
我已经尝试过使用HWND_TOPMOST参数,BringWindowToTop和SetForegroundWindow设置SetWindowPos.它们都不会像函数成功一样返回NULL.
我想到的可能是问题,因为我每隔25毫秒调用一次计时器,因此在将静态控件设置为前台之前,位图已经被重新打印.

我希望有人对如何解决这个问题有所了解.

我真的不是Win32编程专家,所以请在这里解释我做错了什么.

Hi,
I''m using a timer to print a pre buffered bitmap on the hdc. (i hope this is the right way to say this)
Now I want to see a static control on top of all of this. I try to create it when the WM_Create event is called and then to move it to the top after the bitmap has been printed. But it just doesn''t show up on top.
I''ve tried SetWindowPos with the HWND_TOPMOST parameter, BringWindowToTop, and SetForegroundWindow. All of them don''t return NULL as if the function succeeds.
What I''ve thought of might be the problem is that the Bitmap already gets reprinted before the static control has been set into the foreground as I call the timer every 25 Milliseconds.

I hope someone has an idea how I could fix this.

I''m really no expert in Win32 programming, so please explain what I''ve done wrong here.

推荐答案

我恐怕您会这么做以错误的方式.在程序开始时,您只能调用一次CreatWindow().然后,您为WM_PAINT消息更新处理程序中的窗口内容,这时将(重新)绘制位图并写入文本.我不确定您要使用计时器做什么.如果您想要一个很好的简单教程来解释如何构建Windows程序,请查看 http://www.winprog.org/tutorial / [^ ].
I''m afraid you are going about this in the wrong way. You call CreatWindow() only once, at the beginning of your program. You then update the content of the window within your handler for the WM_PAINT message, at which time you would (re-)draw the bitmap and write the text. I am not sure what you are trying to do with the timer. If you want a good simple tutorial that explains how to build a Windows program then take a look at http://www.winprog.org/tutorial/[^].


如果您要在窗口的控件后面在窗口上绘制背景图片(没有动画和任何运动),则应从主窗口的消息WM_PAINT处理程序中绘制.在WM_PAINT内部,您应该使用 BeginPaint() [ EndPaint() [ ^ ]函数.您可以在我链接的BeginPaint()函数的文档中找到WM_PAINT处理程序的代码示例. BeginPaint()返回HDC供您使用.为避免过度绘制窗口的子控件,应使用WS_CLIPCHILDREN样式创建主窗口.设置此样式后,BeginPaint()返回一个HDC,在该HDC上,有效区域排除子控件占用的区域,因此您的绘图不应覆盖它们.
If all you want is drawing a background picture on your window (without animation and any movement) behind the controls on your window then you should draw from the message WM_PAINT handler of your main window. Inside your WM_PAINT you should use the BeginPaint()[^] and EndPaint()[^] functions. You can find a code example for the WM_PAINT handler in the documentation of the BeginPaint() function I linked. BeginPaint() returns a HDC for you to draw on. To avoid overdrawing the child controls of your window you should create your main window with WS_CLIPCHILDREN style. When this style is set your BeginPaint() returns a HDC on which the validatable region excludes the area occupied by child controls so your drawing should not overdraw them.


这篇关于位图顶部的静态控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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