I'm trying to set focus to some an applications using WM_SETFOCUS, but the
windows won't respond. However, the windows do respond to WM_CLOSE messages.
I don't understand what's happening here. For example:
hAppInst = (HINSTANCE)WinExec("c:\\windows\\calc.exe", SW_SHOW);
...
hAppWnd = GetHWndFromHInstance(hAppInst);
::PostMessage(hAppWnd, WM_SETFOCUS, (WPARAM)HWindow, 0L);
Windows Calculator program does not get focus, however:
hAppInst = (HINSTANCE)WinExec("c:\\windows\\calc.exe", SW_SHOW);
...
hAppWnd = GetHWndFromHInstance(hAppInst);
::PostMessage(hAppWnd, WM_CLOSE, 0, 0L);
works beautifully... what's the catch?
thanks for your help, mark.
---= -=- -=- =---
..we come spinning out of nothingness scattering stars like dust; look at
these worlds spinning out of nothingness -- this is within your power. out
beyond ideas of right doing and wrong doing there is a field - i'll meet you
there. -- rumi
You should use the API function SetFocus(). The WM_SETFOCUS message does
not serve the purpose you want. Read the Windows API help.
Some messages have an *effect* (by way of default processing in DefWindowProc),
other messages are just notifications of things happening. WM_CLOSE is in the
former category. WM_SETFOCUS is in the latter category. Documentation is
often vague about this.
- Alf