开发者

Window does not get displayed(Maximized) after Minimizing

I have a Windows CE application which logs key strokes of the mobile device. There's a bu开发者_JAVA技巧tton to initialize the recording functionality, which forces the main window to minimize by calling:

ShowWindow (hWnd, SW_MINIMIZE);

Before minimizing the window, I register to the trigger button event (via a custom API). While the app is minimized I perform some button clicks and press the trigger button to end the session. When I receive the trigger button event, I call:

ShowWindow (hWnd, SW_MAXIMIZE);

The problem is that the window does not get maximized. If I debug the application, I could see that the ShowWindow function is called. I could bring it to the foreground via the TaskManager by switching to the application.

Can someone please explain the cause of this and suggest any solution that I can take?

EDIT: Solution: Call "SetForegroundWindow" before calling ShowWindow and use SW_RESTORE instead of SW_MAXIMIZE. SW_MAXIMIZE does not work.

SetForegroundWindow (g_hWndMain);
ShowWindow (g_hWndMain, SW_RESTORE);


Showwindow could fail by several reasons.

You could try:

1) Set foreground

SetForegroundWindow

For WinCE specifically refer to the following MSDN article.
http://msdn.microsoft.com/en-us/library/ms940024.aspx

SetForegroundWindow((HWND)(((ULONG) hwnd) | 0x01) );

2) Bring to front

BringWindowToTop
http://msdn.microsoft.com/en-us/library/ee504610.aspx


Second parameter in ShowWindow(HWND hWnd, int nCmdShow) can take a value:

SW_HIDE, SW_SHOW, SW_SHOWNA, SW_SHOWNORMAL

The last one activates and displays window; it will be restored to its original size and position.

About windows functions in WinCE you can read on MSDN.


Try to first restore window, then maximize.

I don't have Windows CE so can't test, but that should work.

Cheers & hth.,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜