Im looking for a command to test if m window is currently active. What i mean by active is - the user has actuated it and it is currently being worked on. I cant find it on msdn :(
The idea behind it is;
.if !window_is_being_worked_on
playsound
.endif
Try this:
The GetActiveWindow function retrieves the window handle of the active window associated with the thread that calls the function.
HWND GetActiveWindow(VOID)
Parameters
This function has no parameters.
Return Value
If the function succeeds, the return value is the handle of the active window associated with the thread that calls the function. If the calling thread does not have an active window, the return value is NULL.
Regards, P1 :8)
IsWindowEnabled ,can answer for any windows.You have to know it's handle and perhaps search it's class name to have it.
ToutEnMasm
My thought for this was, no parameter to mess with. Test for NULL when it come back, means not me.
But the real issue will be Loss of Focus, and what to do then.
Regards, P1 :8)
Quote from: P1 on June 21, 2006, 09:56:46 PM
My thought for this was, no parameter to mess with. Test for NULL when it come back, means not me.
IsWindowEnabled maybe a better function in the use of thread resources.
But the real issue will be Loss of Focus, and what to do then.
Regards, P1 :8)
RedXVII,
not clearly what you want:
where you use this code? (in msg proc?)
Quote.if !window_is_being_worked_on
playsound
.endif
Try to use: GetForegroundWindow() and GetAncestor()
Quote from: P1 on June 21, 2006, 09:56:46 PM
My thought for this was, no parameter to mess with. Test for NULL when it come back, means not me.
But the real issue will be Loss of Focus, and what to do then.
Regards, P1 :8)
I have used the WM_ACTIVATE message with great success, the message is sent to your window each time it is being activated or deactivated. Simple and easy to use without having to check all the time. Event driven programming is almost always more efficient than calling an API constantly, this way you have only to set a flag.
WM_ACTIVATE is really best solution! :red :U
(http://gta.com.ua/forum2/style_images/1/folder_post_icons/icon13.gif)
Does anybody known in what way I can prevent set active my window?
(My situation: MainWindow has hide status{icon in tray notify}, Wnd2 has show status, but not visible in Task Panel{On Alt+TAB it showed}. So.. When User open Notepad{or something else} and my App and user minimize Notepad — my app will show up{Such as user pressed Alt+TAB} :'(This is a problem.)
{And I don't want use keyboard hooks ::)}
WM_SETFOCUS ?
Will indicate gaining and losing 'focus' and also gives the handle of the window that had focus previously.
So to 'lose' focus, I assume you could just SetFocus to the hwnd given by WM_SETFOCUS in response to that message. However, I have a feeling this may not work all of the time. (Alternatively you could find the 'next' window for focus with GetWindow)
Tedd,
we have ONLY two program Notepad and MyProg. When user close notepad MyProg is stay one! So I can't use WM_SETFOCUS. :'(
Then there is only one window that can get focus - where else would the focus go?
I suppose you could try disabling your window (EnableWindow, hwnd,FALSE) and see if that gives you what you want -- it will stop the user being able to focus it by clicking (once it loses focus the first time), but it can still be brought to the foreground by selecting it in the taskbar.
Quote from: Tedd on June 27, 2006, 01:03:26 PMThen there is only one window that can get focus - where else would the focus go?
The Desktop can receive focus as well. I can not remember if a hidden( not shown ) window, can receive focus as well.
Regards, P1 :8)
Oh, guys! :dance:
GetDesktopWindow() return handle of desktop, so MyProg is not one in system.
Probably I have overheated. :bg In my room now 29°C (In the winter 21-24°C)