Tips |
Author: |
Message: |
tryxter
Junior Member
A. Maia Ferreira @ PTnet
Posts: 51 Reputation: 1
35 / / –
Joined: Jan 2007
|
RE: Tips
JScript Reference
Since I'm starting using JScript for creating the plugins, I found a good JScript reference. It contains some examples too, so I though it could be useful to other programmers.
You can download it here here.
Continue the great work!
(Thank's markee )
Attachment: jsdoc.zip (578 KB)
This file has been downloaded 780 time(s).
This post was edited on 01-09-2007 at 01:13 AM by tryxter.
|
|
01-08-2007 06:46 PM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: Tips
quote: Originally posted by tryxter
JScript Reference
Since I'm starting using JScript for creating the plugins, I found a good JScript reference. It contains some examples too, so I though it could be useful to other programmers.
You can download it here here.
Continue the great work!
(Thank's markee )
Please never attach such official documentation. If MS updates it, people wont have the latest version... Instead only link to it.
Though, as a matter of fact, that official JScript 5.6 documentation is already available since a long time ago in the download section of the scripting database:
http://www.msgpluslive.net/scripts/browse/9/Others/
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
01-28-2007 01:15 AM |
|
|
Matti
Elite Member
Script Developer and Helper
Posts: 1646 Reputation: 39
32 / /
Joined: Apr 2004
|
RE: Tips
Change a ListViewControl's column header in real-time
When you're developing a big script for the mass, one day you'll want to add multilingual support. Most of the time, you can change the text of a control this with PlusWnd::SetControlText, but what if you have a nice ListViewControl with column headers to display interesting information? Formerly, developers simply re-wrote the XML file to make the change in the ListViewControl's <Columns> element, but this method can slow down your computer and is very impractical. Today, I'll show you a much more interesting way to do it.
The following method uses the LVM_SETCOLUMN message to set the column header's information. Not all options of the LVCOLUMN structure need to be used because we only want to change the text. Therefore, we also need to create a buffer to hold the string. The comments will clarify this.
code: /*
[bool] SetColumnHeader(
[hWnd] hWnd: Handle of the ListViewControl, retrieved with PlusWnd::GetControlHandle
[number] iCol: Column id, the first column is 0, second is 1 etc.
[string] sHeader: The new column header
)
Returns true if LVM_SETCOLUMNW succeeded, otherwise false.
*/
function SetColumnHeader(hWnd, iCol, sHeader) {
//Message constants
var LVM_FIRST = 0x1000;
var LVM_SETCOLUMNW = (LVM_FIRST + 96); //We'll use the Unicode instead of the ANSI version to have more characters supported
var LVCF_TEXT = 0x4;
//Create a buffer for the header
var pszText = Interop.Allocate((sHeader.length+1)*2); //Make a DataBloc where the header fits in perfectly
pszText.WriteString(0, sHeader); //Write the header in the DataBloc
//Create an LVCOLUMN structure
var LVCOLUMN = Interop.Allocate(16);
LVCOLUMN.WriteDWord(0, LVCF_TEXT); //mask: pszText is valid
LVCOLUMN.WriteDWord(12, pszText.DataPtr); //pszText: pointer to our buffer
//Call LVM_SETCOLUMNW to change the header and save the result
var Result = Interop.Call("user32", "SendMessageW", hWnd, LVM_SETCOLUMNW, iCol, LVCOLUMN);
//Clear the DataBlocs
pszText.Size = 0;
LVCOLUMN.Size = 0
//Return the result
return Result;
}
You may use and edit this snippet for your own scripts, but if you're going to release your script it'd be nice if you put a little credit in your script.
EDIT: Snippet now placed in a function for easier access.
This post was edited on 06-03-2007 at 08:11 AM by Matti.
|
|
06-02-2007 05:02 PM |
|
|
Matti
Elite Member
Script Developer and Helper
Posts: 1646 Reputation: 39
32 / /
Joined: Apr 2004
|
RE: Tips
Show a popup menu when you right-click a ListViewControl's item
This snippet will show you how you can create a popup menu which will pop up when the user right-clicks a ListViewControl's item, and how you should retrieve the response of the menu. It uses CreatePopupMenu to create the mnu, AppendMenuW to add items and TrackPopupMenu to open it and get the clicked menu item.
This snippet uses some parts of Matty's tray icon script, which initially was meant to create a tray icon with a popup menu. In this snippet, it was modified to only create a menu and show it on right-click. Much thanks to Matty to let me use his code in this snippet!
code: //Message constants for menu
//These should be declared on global scope, so at the top of your script, outside any function
var MF_CHECKED = 0x8;
var MF_APPEND = 0x100;
var MF_DISABLED = 0x2;
var MF_GRAYED = 0x1;
var MF_SEPARATOR = 0x800;
var MF_STRING = 0x0;
var TPM_LEFTALIGN = 0x0;
var TPM_RETURNCMD = 0x0100;
var TPM_VERNEGANIMATION = 0x2000;
//Variable to store our subclass window in, needed to retrieve messages from the menu
//We don't need those messages, but MSDN says that we must pass a window handle
//Therefore, you should add a new window to your XML file, like this:
/*
<Window Id="WndSubclass" Version="1">
<Attributes>
<ShowInTaskbar>False</ShowInTaskbar>
</Attributes>
<DialogTmpl/>
<Position Width="0" Height="0"/>
</Window>
*/
var subclass = false;
//This is an example function.
//It is just to demonstrate how you should place the menu creation code
//Original CreatePopupMenu and AppendMenuW code by Matty
function WindowOpen() {
var PlusWnd = MsgPlus.CreateWnd("Windows.xml", "MyWindow"); //Create our window
hMenu = Interop.Call("user32", "CreatePopupMenu"); //Create a new popup menu and get its handle
//Add menu items
Interop.Call("user32", "AppendMenuW", hMenu, MF_STRING, 101 /*This can be any number you want, and is identifier of the item*/, "Do this");
Interop.Call("user32", "AppendMenuW", hMenu, MF_STRING, 102, "Do that");
Interop.Call("user32", "AppendMenuW", hMenu, MF_SEPARATOR, 0, 0);
Interop.Call("user32", "AppendMenuW", hMenu, MF_CHECKED, 103, "I'm checked!");
//Do anything you want to do with your window after its creation...
}
//A sample function to process the menu click
function ProcessMenuItem(PlusWnd, LVItem, MnuItem) {
//Let's see what item is clicked and react on it
switch(MnuItem) {
case 101: //Do this
DoThis();
break;
case 102: //Do that
DoThat(PlusWnd.LstView_GetItemText("LVThing", LVItem, 0)); //Send the item text of the 1st column of the right-clicked item to the function
break;
case 103: //I'm checked
ToggleCheck();
break;
}
}
//The right-click event, probably the most important piece of this snippet
function OnMyWindowEvent_LstViewRClicked(PlusWnd, CtrlId, Index) {
if(CtrlId == "LVThing") { //If our ListViewControl is clicked...
if(Index < 0) { //If the click didn't occur on an item...
return; //...do nothing
} else {
//Original GetCursorPos and TrackPopupMenu code by Matty
if(!subclass) subclass = MsgPlus.CreateWnd("Windows.xml", "WndSubclass", 2); //Create our subclass window, if it's not yet created
var POINTAPI = Interop.Allocate(8); //Create a structure to store the position of the cursor
Interop.Call("user32", "GetCursorPos", POINTAPI); //Get the position of the cursor and store it
var Result = Interop.Call("user32", "TrackPopupMenu", hMenuMore, TPM_LEFTALIGN | TPM_RETURNCMD | TPM_VERNEGANIMATION, POINTAPI.ReadDWORD(0), POINTAPI.ReadDWORD(4), 0, subclass.Handle, 0); //Open the menu and store the result
ProcessMenuItem(PlusWnd, Index, Result); //Send the result to a function for further processing
}
}
}
This post was edited on 12-06-2007 at 08:20 PM by Matti.
|
|
06-07-2007 05:38 PM |
|
|
henry1817
New Member
Posts: 1
Joined: Dec 2009
|
RE: Tips
can any1 tell me how to open debugging window again when i closed it????
|
|
12-30-2009 04:13 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Tips
Click the Script icon on the main contact list window. Then click Show Script Debugging
Or in code by using:
Javascript code:
Debug.DebuggingWindowVisible = true;
This post was edited on 12-30-2009 at 04:30 PM by matty.
|
|
12-30-2009 04:20 PM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
RE: Tips
Creating a Modal Window
Create a modal dialog window, and keep it focused over a parent window.
Windows.xml
Spoiler: XML code:
<Interfaces xmlns="urn:msgplus:interface" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:msgplus:interface PlusInterface.xsd">
<Window Id="WndParent" Version="1">
<!-- no specific guidelines for the parent window -->
<Attributes>
<Caption>Modal Test</Caption>
</Attributes>
<TitleBar>
<Title>
<Prefix>Image</Prefix>
<Text>Modal Test</Text>
</Title>
</TitleBar>
<Position Width="300" Height="250">
<IsAbsolute>true</IsAbsolute>
</Position>
<DialogTmpl/>
<Controls>
<Control xsi:type="CodeEditControl" Id="EdtCode">
<Position Left="3" Top="0" Width="280" Height="171">
<Units>AllPixels</Units>
</Position>
</Control>
<Control xsi:type="ButtonControl" Id="BtnConfirm">
<Position Left="3" Top="177" Width="70">
<Units>AllPixels</Units>
</Position>
<Attributes>
<IsDefault>true</IsDefault>
</Attributes>
<StandardLook Template="Blue"/>
<Caption>&Confirm...</Caption>
<Help>Display the confirmation...</Help>
</Control>
<Control xsi:type="ButtonControl" Id="BtnCancel">
<Position Left="228" Top="177" Width="55">
<Units>AllPixels</Units>
</Position>
<Caption>&Close</Caption>
<Help>Close the window...</Help>
</Control>
</Controls>
</Window>
<Window Id="WndChild" Version="1">
<!-- child window should not have taskbar button, and should not be allowed to minimize -->
<Attributes>
<Caption>Confirm?</Caption>
<ShowInTaskbar>false</ShowInTaskbar>
</Attributes>
<TitleBar>
<AllowMinimize>false</AllowMinimize>
<AllowClose>false</AllowClose>
<Title>
<Prefix>Image</Prefix>
<Text>Confirm?</Text>
</Title>
</TitleBar>
<Position Width="120" Height="73">
<IsAbsolute>true</IsAbsolute>
</Position>
<DialogTmpl/>
<Controls>
<Control xsi:type="ButtonControl" Id="BtnOk">
<Position Left="2" Top="0" Width="40">
<Units>AllPixels</Units>
</Position>
<StandardLook Template="Blue"/>
<Caption>Ok</Caption>
</Control>
<Control xsi:type="ButtonControl" Id="BtnCancel">
<Position Left="44" Top="0" Width="60">
<Units>AllPixels</Units>
</Position>
<Caption>Cancel</Caption>
</Control>
</Controls>
</Window>
</Interfaces>
Modal Test.js
Spoiler: Javascript code:
// make the parent window, make a variable for the child window
var WndParent = MsgPlus.CreateWnd("Interface.xml", "WndParent");
var WndChild = null;
// use any event here, this is just an example
function OnWndParentEvent_CtrlClicked(PlusWnd, ControlId)
{
if (ControlId === "BtnConfirm")
{
// create the child, disable and monitor the parent
WndChild = MsgPlus.CreateWnd("Interface.xml", "WndChild");
Interop.Call("user32", "EnableWindow", WndParent.Handle, false);
WndParent.RegisterMessageNotification(0x0006);
}
}
// when the parent window is focused
function OnWndParentEvent_MessageNotification(PlusWnd, Message, wParam, lParam)
{
if (wParam !== 0)
{
try
{
// focus the child window
Interop.Call("user32", "SetFocus", WndChild.Handle);
Interop.Call("user32", "BringWindowToTop", WndChild.Handle);
}
catch (error)
{
}
}
}
function OnWndChildEvent_CtrlClicked(PlusWnd, ControlId)
{
switch (ControlId)
{
case "BtnOk":
// do whatever here, then close the child
PlusWnd.Close(1);
break;
}
}
function OnWndChildEvent_Destroyed(PlusWnd, ExitCode)
{
// enable and focus the parent window
Interop.Call("user32", "EnableWindow", WndParent.Handle, true);
Interop.Call("user32", "SetFocus", WndParent.Handle);
}
Attachment: Modal Test.plsc (2.12 KB)
This file has been downloaded 310 time(s).
This post was edited on 06-24-2010 at 10:56 AM by whiz.
|
|
06-24-2010 10:53 AM |
|
|
Pages: (2):
« First
«
1
[ 2 ]
Last »
|
|
|