quote:
Originally posted by Mattike
According to the MSDN site and the Win32 API Constants, this should do it:
code:
var WindowPlacment = Interop.Allocate(48);
function _getPlacement(hWnd){
if (hWnd > 0){
Interop.Call('user32', 'GetWindowPlacement', hWnd, WindowPlacement);
Debug.Trace('> .showCmd : '+WindowPlacement.ReadDWORD(8));
if (WindowPlacement.ReadDWORD(8) == 3){
Debug.Trace(' > .showCmd : Maximized');
} else if (WindowPlacement.ReadDWORD(8) == 2){
Debug.Trace(' > .showCmd : Minimized');
} else if (WindowPlacement.ReadDWORD(8) == 1){
Debug.Trace(' > .showCmd : Opened');
} else if(WindowPlacement.ReadDWORD(8) == 6){
Debug.Trace(' > .showCmd : Opened');
}
} else {
Debug.Trace(' > .showCmd : Closed');
}
}
No...
SW_MINIMIZE (0x6) is not the same as SW_SHOWMINIMIZED (0x2).
If you read the MSDN documentation on the GetWindowPlacement API it states:
quote:
If the window identified by the hWnd parameter is maximized, the showCmd member is SW_SHOWMAXIMIZED. If the window is minimized, showCmd is SW_SHOWMINIMIZED. Otherwise, it is SW_SHOWNORMAL.
So the only values you need to check for are:
SW_SHOWNORMAL (0x1)
SW_SHOWMINIMIZED (0x2)
SW_SHOWMAXIMIZED (0x3)
There will be no other value returned by the function in the WINDOWPLACEMENT structure.
Speaking of which, the MSDN docs also states:
quote:
The length member of WINDOWPLACEMENT must be set to sizeof(WINDOWPLACEMENT). If this member is not set correctly, the function returns FALSE.
but nevertheless the API will function though. (dodgy MS keeping stuff like this for compatibily reasons, instead of urging programmers to do the right thing in the first place).
---------------------------------
As for detecting if a chat window is minimized or not. That is far from straightforward when grouped chats are used. This because then Messenger Plus! controls what window is minimized, maximized or normal because the chat windows will become owned by a hidden Plus! window.
To see if grouped chats are in use, you must check if an owner window exist.
If so, you can not check with the GetWindowPlacement API like you normally would for the state of a chatwindow since Plus! will always disable automatically the chats which aren't visible and not minimize them (hence why you'll see 'normal' with the GetWindowPlacement API on those chats).
So if you see that a chat is 'normal' and you see that grouped chats is in use, you must use the IsWindowEnabled API in those cases to see if the chat window is disabled (aka minimized) or not.
But even then it isn't that straightforward. Only when _all_ chat windows are disabled, you could assume that the grouped chat as a whole has been truely minimized. In other cases it is quite possible that the chat window you're checking on will give you 'disabled', eventhough other windows are enabled and thus nothing is minimized at all.
TheGuruSupremacy, a solution for this extremely depends on what you want to do _exactly_. "
I want to check if a chat is minimized" is way to vague to give you a proper solution. It totally depends on _why_ you want to know that and what you're going to do with it. Since there is a difference, in case of grouped chatting, between the real state and the thing you see on your screen.