<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; WSO + VBscript Вопрос о контекстном меню.]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=9171&amp;type=atom" />
	<updated>2014-04-08T14:51:28Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=9171</id>
		<entry>
			<title type="html"><![CDATA[Re: WSO + VBscript Вопрос о контекстном меню.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=81583#p81583" />
			<content type="html"><![CDATA[<p>Сам дал задачу - сам решил.<br />Вот JScript пример вызова контекстного меню в WSO:</p><div class="codebox"><pre><code>
o = new ActiveXObject(&quot;Scripting.WindowSystemObject&quot;) // Подключились к COM объекту
f = o.CreateForm(0,0,0,0)
f.ClientWidth = 550
f.ClientHeight = 350
f.CenterControl() // Создаем окно по центру экрана
f.Text = &quot;Press right mouse button on an item&quot;
f.BorderWidth = 10
f.MinWidth = 500
f.MinHeight = 350
Box = f.CreateListView(10,10,250,300,o.Translate(&quot;LVS_REPORT | LVS_SHOWSELALWAYS&quot;)) // Таблица в виде ListView report
Box.HotTrack = true
Box.RowSelect =true
Box.Align = o.Translate(&quot;AL_CLIENT&quot;);
 r1=Box.Columns.Add (&quot;ID&quot;, 40);
 r2=Box.Columns.Add (&quot;Sub 0&quot;, 90);
 r3=Box.Columns.Add (&quot;Sub 1&quot;, 250)    ;
 r4=Box.Columns.Add (&quot;Sub 2&quot;, 140)    ;
 r5=Box.Columns.Add (&quot;Sub 3&quot;, 40); // Всего 5 колонок
Box.BeginUpdate () // Метод запрещает обновление компонента после изменения коллекции, полезно вызывать этот метод перед добавлением большого количества элементов.
// Окно не будет моргать при заполнении таблицы
for (i = 0; i&lt;100000; i++) // Много тестовых значений
{
        Box.Add(&quot;Item &quot;+i)
        Box.item(i).SubItems(0)=&quot;SubItem &quot;+i
        Box.item(i).SubItems(1)=&quot;SubItem &quot;+i
        Box.item(i).SubItems(2)=&quot;SubItem &quot;+i
        Box.item(i).SubItems(3)=&quot;SubItem &quot;+i
}
Box.EndUpdate () //Метод разрешает обновление компонента после изменения коллекции.
Box.ReadOnly = false
Box.PopupMenu.Add(&quot;Select item&quot;).OnExecute = OnSelectItem // Вызов контекстного меню 1 пункт.
Box.PopupMenu.Add(&quot;Delete item&quot;).OnExecute = OnDell // Вызов контекстного меню 2 пункт.

function OnDell(Sender) // Действие вызванное нажатием Delete item
{
        var ListView = Sender.Control
        var Index = ListView.ItemIndex
        ListView.Remove(Index)
}

function OnSelectItem(Sender) // Действие вызванное нажатием Select item
{
        var ListView = Sender.Control
        var Index = ListView.ItemIndex
        if (Index &lt; 0) f.Text = &quot;No item selected&quot;; else        
                f.Text = ListView.Item(Index).Text + &quot; &quot;+ListView.item(ListView.ItemIndex).SubItems(1)
}
f.Show()
o.Run()
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Mat Skywalker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26275</uri>
			</author>
			<updated>2014-04-08T14:51:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=81583#p81583</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[WSO + VBscript Вопрос о контекстном меню.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=79386#p79386" />
			<content type="html"><![CDATA[<p>Собственно сабж. Есть ListView, как прикрутить к нему PopUpMenu.<br /><a href="http://www.veretennikov.org/WSO/Help/html/interface_control.html#320179a8b1045b7f4977e5b91be683e4">http://www.veretennikov.org/WSO/Help/ht … b91be683e4</a><br />Тут написано что то непонятное. Я пытался разобраться в примерах на JScript (которые есть в комплекте), но походу для ListView контекстного меню не бывает...<br />Вот пример кода (из примеров к WSO):<br /></p><div class="codebox"><pre><code>
Set o = WScript.CreateObject(&quot;Scripting.WindowSystemObject&quot;)

Set f = o.CreateForm(0,0,0,0)
f.ClientWidth = 600
f.ClientHeight = 300
f.CenterControl()
f.Text = &quot;ListView Sample&quot;

Set RightPanel = f.CreateFrame(0,0,100,0)
RightPanel.Align = o.Translate(&quot;AL_RIGHT&quot;)

Set View = f.CreateListView(0,0,0,0)
View.Align = o.Translate(&quot;AL_CLIENT&quot;)
View.RowSelect = true
View.Style = o.Translate(&quot;LVS_REPORT&quot;)
View.HideSelection = false

View.Columns.Add &quot;Column A&quot;,70
View.Columns.Add &quot;Column B&quot;,100
View.Columns.Add &quot;Column C&quot;,150

Set Images = o.CreateImageList()
Images.Load(ResourceDir()+&quot;ToolBar.bmp&quot;)

View.LargeImages = Images
View.SmallImages = Images

For counter = 1 To 10
    Set Item = View.Add(counter)
    Item.SubItems(0) = &quot;SubItem 1 of &quot;+CStr(counter)
    Item.SubItems(1) = &quot;SubItem 2 of &quot;+CStr(counter)
    Item.ImageIndex = counter Mod 15
Next

Set CloseButton = RightPanel.CreateButton(10,10,75,25,&quot;Close&quot;)
CloseButton.OnClick = GetRef(&quot;CloseFormHandler&quot;)

Set ExecuteItem = RightPanel.CreateButton(10,50,75,25,&quot;Execute&quot;)
ExecuteItem.OnClick = GetRef(&quot;ExecuteItemHandler&quot;)


Set AddItem = RightPanel.CreateButton(10,90,75,25,&quot;Add&quot;)
AddItem.OnClick = GetRef(&quot;AddItemHandler&quot;)

Set DeleteItem = RightPanel.CreateButton(10,130,75,25,&quot;Delete&quot;)
DeleteItem.OnClick = GetRef(&quot;DeleteItemHandler&quot;)

f.Show()
o.Run()

Sub CloseFormHandler(Sender)
    Sender.Form.Close()
End Sub

Sub ExecuteItemHandler(Sender)
    If View.ItemIndex &gt;= 0 Then
        f.MessageBox(&quot;Item &quot;+CStr(View.ItemIndex) +&quot; selected&quot;)
    Else
        f.MessageBox(&quot;No items selected&quot;)    
    End If
End Sub

Sub DeleteItemHandler(Sender)    
    View.BeginUpdate()

    For i = View.Count-1 To 0 Step -1

        if View.Item(i).Selected Then
            View.Remove(i)
        End If
    Next

    View.EndUpdate()
    View.ClearSelection()
End Sub

Sub AddItemHandler(Sender)
    Set Item = View.Add(counter)
    Item.SubItems(0) = &quot;SubItem 1 of &quot;+CStr(counter)
    Item.SubItems(1) = &quot;SubItem 2 of &quot;+CStr(counter)
    Item.ImageIndex = counter Mod 15
    counter = counter + 1
End Sub

Function ResourceDir()
    ResourceDir = StartupDir()+&quot;..\\Data\\&quot;
End Function

Function StartupDir()
    Dim s
    s = WScript.ScriptFullName
    s = Right(s,InStrRev(s,&quot;\\&quot;))
    StartupDir = s
End Function
</code></pre></div><p>Как сюда приделать PopupMenu ума не приложу.</p>]]></content>
			<author>
				<name><![CDATA[Mat Skywalker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26275</uri>
			</author>
			<updated>2014-01-21T05:25:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=79386#p79386</id>
		</entry>
</feed>
