Set window size |
Author: |
Message: |
Neon_
New Member
Posts: 5
Joined: Oct 2007
|
O.P. Set window size
How would I go about writing code to set the width and height of the chat window to a specific size? or it this even possible? Thanks in advance for the help.
|
|
10-18-2007 10:01 PM |
|
|
deAd
Scripting Contest Winner
Posts: 1060 Reputation: 28
– / /
Joined: Jan 2006
|
|
10-18-2007 10:03 PM |
|
|
Neon_
New Member
Posts: 5
Joined: Oct 2007
|
O.P. RE: Set window size
So I think I have everything set except for the HWND param, I don't know what to put there exactly. This is what I wrote out for the rest of the line:
SetWindowPos(???, HWND_TOP, 0, 0, 700, 500, SWP_NOMOVE);
|
|
10-19-2007 02:07 AM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Set window size
HWND is the Handle to the window, a unique indetifier that Windows uses instead of a name. If you can access the ChatWnd object, you just use ChatWnd.Handle else you will have to iterate the chat windows for the one that you want
<Eljay> "Problems encountered: shit blew up"
|
|
10-19-2007 09:34 AM |
|
|
Neon_
New Member
Posts: 5
Joined: Oct 2007
|
O.P. RE: Set window size
All I'm trying to do is make a simple command that will resize my chat window to a specific size. Anyone think they can help me finish it? I'm kind of lost at the errors I'm getting. This is what I have so far:
code: function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
if (Message=="/sfix"){
SetWindowPos(ChatWnd.Handle, HWND_TOP, 0, 0, 700, 500, SWP_NOMOVE | SWP_NOZORDER);
return"";
}
}
This post was edited on 10-19-2007 at 08:45 PM by Neon_.
|
|
10-19-2007 08:45 PM |
|
|
felipEx
Scripting Contest Winner
Posts: 378 Reputation: 24
35 / /
Joined: Jun 2006
|
RE: RE: Set window size
quote: Originally posted by Neon_
All I'm trying to do is make a simple command that will resize my chat window to a specific size. Anyone think they can help me finish it? I'm kind of lost at the errors I'm getting. This is what I have so far:
code: function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
if (Message=="/sfix"){
SetWindowPos(ChatWnd.Handle, HWND_TOP, 0, 0, 700, 500, SWP_NOMOVE | SWP_NOZORDER);
return"";
}
}
it works fine here
code: function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
if (Message=="/sfix"){
Interop.Call("user32", "SetWindowPos", ChatWnd.Handle, 0, 0, 0, 700, 500, 2);
//SetWindowPos(ChatWnd.Handle, HWND_TOP, 0, 0, 700, 500, SWP_NOMOVE | SWP_NOZORDER);
return"";
}
}
|
|
10-19-2007 08:53 PM |
|
|
Neon_
New Member
Posts: 5
Joined: Oct 2007
|
O.P. RE: Set window size
Thanks a lot, works like a charm, much apreciated.
|
|
10-19-2007 11:08 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Set window size
API calls work differently. You need to use Interop.Call to call them and pass the DLL name and function name along with any paramaters the function will use, just so you know
<Eljay> "Problems encountered: shit blew up"
|
|
10-20-2007 05:43 PM |
|
|
Matti
Elite Member
Script Developer and Helper
Posts: 1646 Reputation: 39
32 / /
Joined: Apr 2004
|
RE: Set window size
And don't forget that those HWND_TOP and other constants aren't pre-defined in JScript, so you'll need to look up their values. A good resource for that would be m00.cx's Win32 API constants list.
I hope the following example (which is almost identical to the previous replies) will show you how all this is used practically in a way that you and any other developer can understand what it does:
code: //I define the constants globally, because you don't need to change them anymore in the script and you may need them in multiple parts of your script. If you're only planning to use those once, it may be more interesting to use something like DoThis(/* HWND_TOP */ 0) instead of using DoThis(HWND_TOP) with HWND_TOP defined globally.
var HWND_TOP = 0;
var SWP_NOMOVE = 0x2;
var SWP_NOZORDER = 0x4;
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
if(Message == "/sfix") {
Interop.Call("user32", "SetWindowPos", ChatWnd.Handle, HWND_TOP, 0, 0, 700, 500, SWP_NOMOVE | SWPNOZORDER);
}
}
|
|
10-21-2007 03:02 PM |
|
|
|