首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 嵌入开发 > WinCE >

MediaPlayer全屏播放时 怎么让小弟我的应用程序置顶? 搜遍了以前的帖子没发现解决方法

2012-02-13 
MediaPlayer全屏播放时 如何让我的应用程序置顶?搜遍了以前的帖子没发现解决办法平台是wince编的嵌入式平

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

[解决办法]
最好先给MediaPlayer发出暂停消息(单击即可),然后再让程序置顶。
[解决办法]
或者是你先把Mediaplayer最小化,再让程序置顶。确实没做过这样的问题,我想这个问题可能和解码后播放器bitblt画面有关,在全屏状态下可能根本就不是把画面画到什么窗体上,而是自己绘到屏幕上,所以会有以上问题.

[解决办法]
用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);

[解决办法]
我估计Mediaplayer的窗口属性本来是HWND_TOPMOST,在操作系统上的优先级比你的窗口进程高.你或许可以换个思考方式,先用SetWindowPos将Mediaplayer的窗口退后(可以设为HWND_NOTTOPMOST),再将你的窗口置顶,完成后再将Mediaplayer窗口属性改回来.
[解决办法]
MediaPlayer应该也设置了HWND_TOPMOST,而且因为它一直在刷新显示,所以会出现别的窗口没办法置于最顶层的问题。不过我想你既然要把你的窗口放在最上面,那么此时MediaPlayer显示什么,对你来说是没有意义的,你是否可以在显示你的窗口的时候把它最小化,退出你的窗口的时候,在把它最大化?

热点排行