Shoutbox

Manipulating window position given hwnd - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: Manipulating window position given hwnd (/showthread.php?tid=51955)

Manipulating window position given hwnd by eSouL on 10-19-2005 at 10:21 AM

Hi,

My plugin hides a conversation window (IMessengerConversationWnd object) by changing its 'Left' property to -20000, before opening my own custom window using ShowWindow API (such that it is non-modular). I do this because I need the conversation window to be active (minimized is not good enough) yet not visible.

Problem is, I want to restore the conversation window position when the user closes my custom window, presumably during Form_QueryUnload event. Now I have the hwnd to the conversation window, but how do I change its Left property?

I am using VB6 by the way.

Please offer suggestions. Thanks in advance!


RE: Manipulating window position given hwnd by RaceProUK on 10-19-2005 at 01:58 PM

I think a better solution would be to hide the window the proper way, by using ShowWindow() with the HWND.


RE: Manipulating window position given hwnd by eSouL on 10-19-2005 at 03:02 PM

I can't use ShowWindow(). I need to PostMessage() to the conversation window so I have to activate the window for a brief moment before returning control to my custom window. If the conversation window is visible on screen, it will create flickerings when I do so. Hence it needs to stay at a negative x position area. But I want a way to bring it back. The MoveWindow() function is a bit buggy.


RE: Manipulating window position given hwnd by Millenium_edition on 10-19-2005 at 03:11 PM

GetWindowRect and SetWindowPos?


RE: Manipulating window position given hwnd by CookieRevised on 10-19-2005 at 08:03 PM

quote:
Originally posted by eSouL
I can't use ShowWindow(). I need to PostMessage() to the conversation window so I have to activate the window for a brief moment before returning control to my custom window. If the conversation window is visible on screen, it will create flickerings when I do so. Hence it needs to stay at a negative x position area. But I want a way to bring it back. The MoveWindow() function is a bit buggy.
API's like MoveWindow(), etc aren't buggy at all. They work absolutely perfect. The use of them (aka your own code) is most likely buggy if you experience abnormalities.

Instead of hiding a window you can also minimize it. in general speaking, activating a window, showing/hiding it, restoring/minimizing it are three different independant things.

Also, why do you need PostMessage()? It is quite possible that with another method you do not need the 'PostMessage() approach' at all. Also, in normal circumstances, this API doesn't require you to activate a window, since it send its message to the handle of a window, not to the activate window. But all this depends on what you want do and what your current code is.

But why do you ask how to change the 'Left' coordinate of a window when you first said:
quote:
Originally posted by eSouL
My plugin hides a conversation window (IMessengerConversationWnd object) by changing its 'Left' property to -20000
Don't this mean you already know how to set the 'Left'?...

Finally, to simply change a coordinate you indeed could also use SetWindowPos(), like ME said. But this is in general, it highly depends on your overall code. Because most stuff can be greatly optimized or done in another shorter approach. And many Window API's already contain ways to set coordinates strait away, without using additional API's. So it all strongly depends on your current code to do it in the proper and/or efficient way.

PS: notice that I linked all the API's talked about to the MSDN Library. This should be your number one stop to get info about the API's (not some other website which only provides half the info) ;)
RE: Manipulating window position given hwnd by eSouL on 10-20-2005 at 04:03 AM

Thanks for the reply Cookie. After reading them, I tried to rewrite some part of my code and indeed, much to my delight, PostMessage can be sent to a hidden window :D SetWindowPos worked fine too but now that I don't need to change coordinates, I return to the good old ShowWindow function. Thanks again!


RE: Manipulating window position given hwnd by RaceProUK on 10-27-2005 at 12:04 PM

quote:
Originally posted by eSouL
I return to the good old ShowWindow function.
Which is what I suggested before!
quote:
Originally posted by raceprouk
I think a better solution would be to hide the window the proper way, by using ShowWindow() with the HWND.