For Programmers: Free Programming Magazines  


Home > Archive > Smartphone Developer Forum > March 2006 > Focus in Smartphone applications









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Focus in Smartphone applications
ArtemK

2006-03-27, 7:05 pm

Hello!

I have problems with focus of input in my application.
For example, I have application that has main window and several modal
dialogs. User runs application, starts dialog, then he wants to press "Home"
key.
He does what he wants, then he wants to return to the dialog in my app. He
runs my program again, it shows dialog in which user has stopped, but focus
is lost :(
And I cannot find where it is. How can I put focus in dialog window?

PS: When starts, my app looks for it's main window. If window is found, app
uses functions SetForegroundWindow() and ShowWindow() to make it visible.
If no , it runt itself.


Yaroslav Goncharov

2006-03-28, 4:08 am

Check out your single instance implemenation. Most likely you have something
like this:
::SetForegroundWindow(hWndExistingInstan
ce);

However, it does not activate a correct window. The code should be:
::SetForegroundWindow((HWND) (((ULONG) hWndExistingInstance) | 0x01));

Please let me know if it resolves your problem.

--
Yaroslav Goncharov
Spb Software House, http://spbsoftwarehouse.com
Pocket PC Developer Network, http://pocketpcdn.com


"ArtemK" <artemk@land.ru> wrote in message
news:OBo4DfaUGHA.3888@TK2MSFTNGP10.phx.gbl...
> Hello!
>
> I have problems with focus of input in my application.
> For example, I have application that has main window and several modal
> dialogs. User runs application, starts dialog, then he wants to press
> "Home" key.
> He does what he wants, then he wants to return to the dialog in my app. He
> runs my program again, it shows dialog in which user has stopped, but
> focus is lost :(
> And I cannot find where it is. How can I put focus in dialog window?
>
> PS: When starts, my app looks for it's main window. If window is found,
> app uses functions SetForegroundWindow() and ShowWindow() to make it
> visible.
> If no , it runt itself.
>
>



ArtemK

2006-03-28, 4:08 am

Yes, it helped. Also, I should not call ShowWindow() and other window
functions.

PS: what does it mean - (HWND) (((ULONG) hWndExistingInstance) | 0x01)?
Where it is described?


"Yaroslav Goncharov" <yaroslav@softspb.com> wrote in message
news:e1idOkjUGHA.1564@TK2MSFTNGP11.phx.gbl...
> Check out your single instance implemenation. Most likely you have
> something like this:
> ::SetForegroundWindow(hWndExistingInstan
ce);
>
> However, it does not activate a correct window. The code should be:
> ::SetForegroundWindow((HWND) (((ULONG) hWndExistingInstance) | 0x01));
>
> Please let me know if it resolves your problem.
>
> --
> Yaroslav Goncharov
> Spb Software House, http://spbsoftwarehouse.com
> Pocket PC Developer Network, http://pocketpcdn.com
>
>
> "ArtemK" <artemk@land.ru> wrote in message
> news:OBo4DfaUGHA.3888@TK2MSFTNGP10.phx.gbl...
>
>



Yaroslav Goncharov

2006-03-29, 4:11 am

It is a part of SetForegroundWindow documentation in MSDN:
"If the window being set to the foreground is minimized, the window may not
be visible to the end user. This function also does not reactivate the last
active child window by default. To ensure that the window is restored and
the last active child window is reactivated, combine the handle to the
window with 0x01 using the logical OR operator. For example:

SetForegroundWindow((HWND)(((ULONG) hwnd) | 0x01) );"
--
Yaroslav Goncharov
Spb Software House, http://spbsoftwarehouse.com
Pocket PC Developer Network, http://pocketpcdn.com


"ArtemK" <artemk@land.ru> wrote in message
news:%23atGbckUGHA.4792@TK2MSFTNGP14.phx.gbl...
> Yes, it helped. Also, I should not call ShowWindow() and other window
> functions.
>
> PS: what does it mean - (HWND) (((ULONG) hWndExistingInstance) | 0x01)?
> Where it is described?
>
>
> "Yaroslav Goncharov" <yaroslav@softspb.com> wrote in message
> news:e1idOkjUGHA.1564@TK2MSFTNGP11.phx.gbl...
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com