PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

minimizing PocketHAL on Toshiba e805

After my program is minimized, and then brought back into focus again by the user, on a Toshiba e805, BeginScene() fails. Works fine otherwise on all the other devices my program has been tested on so far.

I had two different users replicate the problem to make sure it wasn't a problem with a specific user's e805.

Any idea what's causing this?
What messages are you using to detect when your app is minimized/restored?

Are you using WM_SETFOCUS and WM_KILLFOCUS?
Or are you using WM_ACTIVATE?
Some other method?
When I call my Minimize() function the first thing I do is add a message.
Code:
::PostMessage(m_hWindow, WM_USER_MINIMIZE, 0, 0);


Then when my WM_USER_MINIMIZE message is called in my WinProc I call this to actually minimize the window.
Code:
::ShowWindow(hWnd, SW_MINIMIZE);


Then I find my window and bring it back into focus if the user reloads my program.
Code:
HWND hWnd = ::FindWindow("Two Stunads", "SpaceTime 1.5");

if(hWnd)
{
::SetForegroundWindow((HWND)(((DWORD)hWnd) | 0x01));
return 0;
}


Should I be doing this differently?
No that's fine, I am just wondering what you use to decide that you have focus and call BeginScene(). Are you waiting for WM_SETFOCUS before trying to call BeginScene()?

I know SetForegroundWindow() is supposed to give your window focus... I am just trying to figure out what is going on. Could you add a call to SetFocus() right after and see if it works?

ex:
SetForegroundWindow( hwnd );
SetFocus( hwnd );
No problem. I'll try that and post the results.
Ok, I finally got around to doing this, but the problem is still there.

Any other ideas? I'm still using 0.6.5. Thanks!
What is the purpose of "((DWORD)hWnd) | 0x01" ?

Why aren't you just using hWnd ?
I have no idea. :) I pulled that minimize code from GapiDraw.

Would that make a difference?
It could. Why on earth are you missing with the HWND value anyways.

Have you tried PHAL 0.6.6? The problem might have been fixed.
Stunad wrote:Would that make a difference?


Only 50% of the time :)
Just tried 0.6.6 and change the "((DWORD)hWnd) | 0x01" to "hWnd", but the problem is still there. :(

Any other ideas?
This is also happening on an iPAQ 1945. I think for now I'm just going to make the minimize button in my program close my program instead of minimizing. Please let me know though if you ever find the problem of this or need further help finding the problem. I have beta testers that would probably be willing to help.
Code:
::SetForegroundWindow((HWND)(((DWORD)hWnd) | 0x01));


This should work fine. JHarbour's books used exactly the same code and GD too. I also used this ;-)


Better yet, can you post your minimize code? So we can help. Regards.
I don't know exactly what that "hwnd | 0x01" does, but if I remember correctly it only does something on Windows 3.1. You definitely do not need/want to do that. Just because J. Harbour's book and GD does it doesn't mean it's right.
I modified the "minimal" sample that comes with PocketHAL 0.7.1 and did the following:

1) Minimize with ShowWindow( hwnd, SW_MINIMIZE) in the Window proc (Win32Game::MessageHandler) when a key is pressed.

2) Disabled the Shutdown() call in Game::OnKeyDown().

And I have no problem whatsoever on any of my devices (E-125, Maestro, iPAQ 2210).

Could you update your code to use PHAL 0.7.1 and check if the problem persists?