I have the HWND to a window. If it has the focus, I want it to lose the focus. I don't mind where the focus goes. Is there anyway I can do that using win32? Thanks.
Attachments: Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.
Why do you want it to lose focus?Do you want it to move to another window in your application, or some other application?
Ideally, I want the window to lose focus as if I have pressed the minimise button. Normally Windows decides which window gets the focus next. I have already sent the window to the back of the Z order. For it to retain focus is not useful.
Can you explain your scenario; how is this window gaining focus when you presumably don't want it to?
When you say "lose the focus" do you mean that the target window is the foreground window and you want a different window to become the foreground window?
The window starts with focus. How it obtains that focus isn't important. The focus behaviour I am looking for is as if I pressed the minimise button. Windows then assigns the focus to whichever other window it wants.
So the answer is "Yes, I want to make a different window the foreground window". There are various ways to steal the foreground from a window but generally its not a good idea. Take a look at Foreground activation permission is like love: You can’t steal it, it has to be given to you
If you want the same behaviour as minimize, why not use ShowWindow with SW_MINIMIZE ?
How about sending a alt+tab message?
How about getting the next window in z-order by using GetWindow() & GW_HWNDNEXT and call SetFocus() on that?
Maybe you mean CreateWindowEx(WS_EX_NOACTIVATE, ...) ?
13 people are following this question.
Modify WIA2 Default scan UI
ScreenBurn FrameMovement for All Desktop View
OpenSCManager API failed with AccessDenied for Remote Computer
How ignore file creation after calling CreateFile() Win32 API
UIAutomation not catching all elements