Shoutbox

xml window position - 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)
+----- Thread: xml window position (/showthread.php?tid=77102)

xml window position by scutterman on 08-29-2007 at 07:35 PM

How can I change the position of an xml window on the screen.

Is there something in xml that will let me control it or is there something in mpls to control window position?

I've tried searching but I can't find anything

TIA
~~Scutterman~~


RE: xml window position by matty on 08-29-2007 at 07:50 PM

When Creating the Window using MsgPlus.CreateWnd the 3rd parameter if you set it to 1 will cause the window to not show on the screen. What you can do with this is then use the MoveWindow api to move it where you want to then call the ShowWindow api to show it. Other then that there is nothing in the XML that will allow you to set positions.


RE: xml window position by scutterman on 08-29-2007 at 07:53 PM

Thanks, I'll look into MoveWindow()

Am I right in thinking that I will need to hide the window again before I can move it to another position, then show it again?

Thanks
~~Scutterman~~


RE: xml window position by markee on 08-29-2007 at 11:27 PM

You can move it while the window is visable, but if you are moving it initially then it looks better if you don't display the window until it is in the position that you were initially wanting.


RE: xml window position by scutterman on 08-30-2007 at 08:58 AM

Ok, thanks for all of your help


RE: xml window position by scutterman on 08-30-2007 at 09:37 AM

ok, I've tried MoveWindow() but I can't seem to get it to work. If I have the last parameter in quotes, or left out I get an "object expected" error but if I have it out of quotes it comes up with "'FALSE' is undefined". Can someone give me an example MPL script please?

code:

function OnEvent_ChatWndReceiveMessage(oChatWnd, sOrigin, sMessage, nMessageKind)
{

    if (sMessage == "Testing")
    {
//    MsgPlus.DisplayToast("","Testing, Testing, 1, 2, 3")
    var Wnd = MsgPlus.CreateWnd("InterfaceTest.xml", "WndTest",1);
    var WndHandle = Wnd.Handle
    MoveWindow(WndHandle, 100, 100, 100, 100, FALSE);
    }
   
}



Thanks
~~Scutterman~~
RE: xml window position by Spunky on 08-30-2007 at 10:17 AM

change FALSE to false or replace it with a 0 (zero)


RE: xml window position by scutterman on 08-30-2007 at 11:26 AM

Thanks
~~Scutterman~~


RE: xml window position by scutterman on 08-30-2007 at 11:34 AM

GRRRRRRRRRRRRR
I changed the value to "false" and it's still saying "object expected"

any ideas
~~Scutterman~~


RE: xml window position by Matti on 08-30-2007 at 12:19 PM

MoveWindow is a Win32 API function in user32.dll. You should use Interop.Call(DllName, FunctionName, Param1, ...) to call it!

Source: MoveWindow on MSDN

code:
var Result = Interop.Call(
   "user32.dll", /* DLL name, you can find this on the MSDN page under Function Information */
   "MoveWindow", /* Function name */
   WndHandle, /* hWnd */
   100, /* X-position */
   100, /* Y-position */
   100, /* Width */
   100, /* Height */
   true /* bRepaint, set this to false if you're going to repaint the window yourself (which you better don't) */
);
Debug.Trace("MoveWindow result: "+Result);
The result of MoveWindow is zero if it failed. So, if you want to check if it failed, use if(Result == 0) ... and do whatever you want. (show error box, tell the debugger something, ...)

Of course, it's not needed that you place all these comments in your function call. It's just to let you know what each parameter stands for. Something like this can be used if you don't need all these comments:
code:
var Result = Interop.Call("user32.dll", "MoveWindow", WndHandle, 100, 100, 100, 100, true);
But I think you could've figured that out yourself too. :)

quote:
Originally posted by SpunkyLoveMuff
change FALSE to false or replace it with a 0 (zero)
Sorry, but that won't make any difference. FALSE is false. And false as parameter in an Interop.Call equals 0 too, the documentation explains:
quote:
Originally posted by Messenger Plus! Live Scripting Documentation
Here is how the data will be sent to the function depending on its type:
  • If the parameter is a plain number (positive or negative), it is sent as is.
  • If the parameter is a floating point number, it is rounded up and sent as a plain number.
  • If the parameter is a boolean, a number is sent: 1 for true, 0 for false.
  • If the parameter is null, 0 is sent.
  • If the parameter is a string, a pointer to a Unicode string is sent.
  • If the parameter is a DataBloc object, a pointer to its underlying data is sent.
  • If the parameter is any other object, a pointer to its IDispatch interface is sent. The reference count of the object is not increased.


RE: xml window position by scutterman on 08-30-2007 at 06:39 PM

Thanks, the MoveWindow is returning a value of 1 now and the ShowWindow is returning a value of 0. The window isn't showing up but I'm sure it's just a bug in my code

code:
    var Result2 = Interop.Call("user32.dll",     "ShowWindow", WndHandle, "SW_SHOW");
    var Result3 = Interop.Call("user32.dll", "UpdateWindow", WndHandle);



~~Scutterman~~
RE: xml window position by matty on 08-30-2007 at 07:01 PM

quote:
Originally posted by scutterman
code:
    var Result2 = Interop.Call("user32.dll",     "ShowWindow", WndHandle, "SW_SHOW");

~~Scutterman~~

SW_SHOW is not a string value it is an integer. Easiest way to find out what the values are is to google the following

define SW_SHOW

SW_SHOW's value is 5.
RE: xml window position by markee on 08-31-2007 at 12:15 AM

quote:
Originally posted by matty
quote:
Originally posted by scutterman
code:
    var Result2 = Interop.Call("user32.dll",     "ShowWindow", WndHandle, "SW_SHOW");

~~Scutterman~~

SW_SHOW is not a string value it is an integer. Easiest way to find out what the values are is to google the following

define SW_SHOW

SW_SHOW's value is 5.
Why use a DLL at all when Patchou has supplies us with a read/write property to do it?
code:
PlusWndObject.Visible = true;
And then magically it ill appear.  Make sure you change PlusWndObject to what the object actually is ;)
RE: xml window position by scutterman on 09-02-2007 at 01:38 PM

Thanks to everyone, the window is displaying fine now

~~Scutterman~~