What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » GetWindowPlacement api

GetWindowPlacement api
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: GetWindowPlacement api
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.

This post was edited on 07-19-2008 at 08:22 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-20-2006 07:36 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
GetWindowPlacement api - by TheGuruSupremacy on 12-20-2006 at 04:32 PM
RE: GetWindowPlacement api - by Matti on 12-20-2006 at 04:40 PM
RE: RE: GetWindowPlacement api - by TheGuruSupremacy on 12-20-2006 at 04:49 PM
RE: RE: GetWindowPlacement api - by CookieRevised on 12-20-2006 at 07:36 PM
RE: RE: RE: GetWindowPlacement api - by TheGuruSupremacy on 12-20-2006 at 09:21 PM
RE: GetWindowPlacement api - by Spunky on 12-20-2006 at 04:44 PM
RE: RE: GetWindowPlacement api - by TheGuruSupremacy on 12-20-2006 at 04:53 PM
RE: GetWindowPlacement api - by Spunky on 12-20-2006 at 04:50 PM
RE: GetWindowPlacement api - by Spunky on 12-20-2006 at 05:03 PM
RE: RE: GetWindowPlacement api - by TheGuruSupremacy on 12-20-2006 at 05:17 PM
RE: GetWindowPlacement api - by Spunky on 12-20-2006 at 05:29 PM
RE: RE: GetWindowPlacement api - by TheGuruSupremacy on 12-20-2006 at 05:36 PM
RE: GetWindowPlacement api - by Spunky on 12-20-2006 at 05:43 PM
RE: RE: GetWindowPlacement api - by TheGuruSupremacy on 12-20-2006 at 05:47 PM
RE: GetWindowPlacement api - by CookieRevised on 12-20-2006 at 09:49 PM
RE: RE: GetWindowPlacement api - by TheGuruSupremacy on 12-21-2006 at 10:27 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On