5015|11

54

帖子

0

TA的资源

一粒金砂(初级)

楼主
 

MediaPlayer全屏播放时 如何让我的应用程序置顶? 搜遍了以前的帖子没发现解决办法 [复制链接]

平台是wince编的嵌入式平台,当使用Mediaplayer全屏播放时,我想让自己的应用程序置顶,使用了API
SetWindowPos(v_hWndMain, HWND_TOPMOST, 0, 0, 0, 0, (SWP_NOSIZE | SWP_NOMOVE));
结果是窗口闪一下就又被Mediaplayer盖住了,延时置顶的方法会造成屏幕闪,不可取,还有什么办法么...

最新回复

jlctt(金) ----------- 照你的方法试过了..代码如下..还是不行,依然被MediaPlayer盖的严严实实的... HWND hWnd1 = GetForegroundWindow(); if(hWnd1) {     SetWindowPos(hWnd1, HWND_NOTOPMOST, 0, 0, 0, 0, (SWP_NOSIZE | SWP_NOMOVE));     SetWindowPos(v_hWndMain, HWND_TOPMOST, 0, 0, 0, 0, (SWP_NOSIZE | SWP_NOMOVE));        }  详情 回复 发表于 2007-9-11 17:01
点赞 关注

回复
举报

71

帖子

0

TA的资源

一粒金砂(初级)

沙发
 
最好先给MediaPlayer发出暂停消息(单击即可),然后再让程序置顶。
 
 

回复

57

帖子

0

TA的资源

一粒金砂(初级)

板凳
 
或者是你先把Mediaplayer最小化,再让程序置顶。确实没做过这样的问题,我想这个问题可能和解码后播放器bitblt画面有关,在全屏状态下可能根本就不是把画面画到什么窗体上,而是自己绘到屏幕上,所以会有以上问题.
 
 
 

回复

48

帖子

0

TA的资源

禁止发言

4
 
用SetWindowPos 函数,这是《Programming Microsoft Windows CE .NET, Third Edition》中的说明

Editing the window structure can be useful in a number of ways. The style bits of a window can be changed after the window has been created to change its default actions and look. For example, the title bar of a window can be shown or hidden by toggling the WS_CAPTION style bit. After changing any style flag that modifies the look of the window, it's customary to force the system to redraw the nonclient area of the window with a call to SetWindowPos.

SetWindowPos is one of those functions used all the time in Windows. It allows the application to move, size, change the Z-order of, and as in this case, redraw the nonclient area of the window. Its prototype is

BOOL SetWindowPos (HWND hWnd, HWND hWndInsertAfter, int X, int Y,
                   int cx, int cy, UINT uFlags);
The first parameter is the handle of the window that will be changed. The hWndInsertAfter parameter optionally allows the function to set the Z-order of the window. This parameter can be either a window handle or one of four flags that position the window either at the top or the bottom of the Z-order. The flags are shown here:

HWND_BOTTOM  The window underneath all windows on the desktop

HWND_TOP  The window on top of all windows

HWND_TOPMOST  The window to always be placed on top of other windows, even when the window is deactivated

HWND_NOTTOPMOST  The window on top of all other nontopmost windows but not marked as a topmost window so that it will be covered when another window is activated

The X, Y, cx, and cy parameters optionally specify the position and size of the window. The flags parameter contains one or more flags that describe the task to accomplish. The flags are as follows:

SWP_NOMOVE  Don't move the window.

SWP_NOSIZE  Don't resize the window.

SWP_NOZORDER  Don't set the window's Z-order.

SWP_NOACTIVATE  If the Z-order is set, don't activate the window.

SWP_DRAWFRAME  Redraw the nonclient area.

SWP_FRAMECHANGED  Recalculate the nonclient area, and then redraw.

Two other flags, SWP_SHOWWINDOW and SWP_HIDEWINDOW, show and hide the window, but it's easier to call the ShowWindow function to show or hide a window. To use SetWindowPos to force the frame to be redrawn after the style bits are changed, the call would be

SetWindowPos (hWnd, 0, 0, 0, 0, 0,
              SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
 
 
 

回复

77

帖子

0

TA的资源

一粒金砂(初级)

5
 
谢谢楼上各位..不过要求的程序是不影响wmp播放的.所以不能暂停或最小化Mediaplayer..
必须让它不受影响的播放,同时运行我的程序..
 
 
 

回复

75

帖子

0

TA的资源

一粒金砂(初级)

6
 
jlctt(金)
------------
SetWindowPos 函数我测试过了...别的情况都可以置顶,只有在Mediaplayer全屏播放的时候不好使.貌似是Mediaplayer把所有的东西都盖住了.
还有什么别的解决办法么..
 
 
 

回复

91

帖子

0

TA的资源

一粒金砂(初级)

7
 
我估计Mediaplayer的窗口属性本来是HWND_TOPMOST,在操作系统上的优先级比你的窗口进程高.你或许可以换个思考方式,先用SetWindowPos将Mediaplayer的窗口退后(可以设为HWND_NOTTOPMOST),再将你的窗口置顶,完成后再将Mediaplayer窗口属性改回来.
 
 
 

回复

84

帖子

0

TA的资源

一粒金砂(中级)

8
 
MediaPlayer应该也设置了HWND_TOPMOST,而且因为它一直在刷新显示,所以会出现别的窗口没办法置于最顶层的问题。不过我想你既然要把你的窗口放在最上面,那么此时MediaPlayer显示什么,对你来说是没有意义的,你是否可以在显示你的窗口的时候把它最小化,退出你的窗口的时候,在把它最大化?
 
 
 

回复

64

帖子

0

TA的资源

一粒金砂(初级)

9
 
嗯,楼上说的有道理!
 
 
 

回复

89

帖子

0

TA的资源

一粒金砂(初级)

10
 
yashi(老斩)
-------------
怪我没说清楚,我的程序只是一个提示的小窗口,不能影响MediaPlayer播放的


jlctt(金)
-----------
如果要设置MediaPlayer的属性,是不是需要线程注入..
可否大概说下思路.


不胜感激
 
 
 

回复

76

帖子

0

TA的资源

一粒金砂(初级)

11
 
jlctt(金)
-----------
上面的回复没过大脑..忽略..

我回去试试把MediaPlayer设为MediaPlayer试下
 
 
 

回复

70

帖子

0

TA的资源

一粒金砂(初级)

12
 
jlctt(金)
-----------

照你的方法试过了..代码如下..还是不行,依然被MediaPlayer盖的严严实实的...
HWND hWnd1 = GetForegroundWindow();
if(hWnd1)
{
    SetWindowPos(hWnd1, HWND_NOTOPMOST, 0, 0, 0, 0, (SWP_NOSIZE | SWP_NOMOVE));
    SetWindowPos(v_hWndMain, HWND_TOPMOST, 0, 0, 0, 0, (SWP_NOSIZE | SWP_NOMOVE));       
}
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表