Microsoft KB Archive/104943: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - "&" to "&")
 
(2 intermediate revisions by the same user not shown)
Line 12: Line 12:
<div id="TitleRow">
<div id="TitleRow">


= <span id="KB104943"></span>VB3 Manipulate Groups &amp; Items in Program Manager Using DDE =
= <span id="KB104943"></span>VB3 Manipulate Groups & Items in Program Manager Using DDE =




Line 82: Line 82:
       On Error GoTo CGError
       On Error GoTo CGError
       text1.LinkMode = 0
       text1.LinkMode = 0
       text1.LinkTopic = &quot;Progman|Progman&quot;
       text1.LinkTopic = "Progman|Progman"
       text1.LinkMode = 2
       text1.LinkMode = 2
       cmd = &quot;[CreateGroup(&quot; + GGroup.Text + &quot;)]&quot;
       cmd = "[CreateGroup(" + GGroup.Text + ")]"
       text1.LinkExecute cmd
       text1.LinkExecute cmd
     CGDone:  text1.LinkMode = 0
     CGDone:  text1.LinkMode = 0
       Exit Sub
       Exit Sub
     CGError:
     CGError:
       MsgBox &quot;Error Adding Group&quot;
       MsgBox "Error Adding Group"
       Resume CGDone
       Resume CGDone
     End Sub
     End Sub
Line 99: Line 99:
       On Error GoTo DGError
       On Error GoTo DGError
       text1.LinkMode = 0
       text1.LinkMode = 0
       text1.LinkTopic = &quot;Progman|Progman&quot;
       text1.LinkTopic = "Progman|Progman"
       text1.LinkMode = 2
       text1.LinkMode = 2
       cmd = &quot;[DeleteGroup(&quot; + GGroup.Text + &quot;)]&quot;
       cmd = "[DeleteGroup(" + GGroup.Text + ")]"
       text1.LinkExecute cmd
       text1.LinkExecute cmd
     DGDone:  text1.LinkMode = 0
     DGDone:  text1.LinkMode = 0
       Exit Sub
       Exit Sub
     DGError:
     DGError:
       MsgBox &quot;Error Deleting Group&quot;
       MsgBox "Error Deleting Group"
       Resume DGDone
       Resume DGDone
     End Sub
     End Sub
Line 116: Line 116:
       On Error GoTo SGError
       On Error GoTo SGError
       text1.LinkMode = 0
       text1.LinkMode = 0
       text1.LinkTopic = &quot;Progman|Progman&quot;
       text1.LinkTopic = "Progman|Progman"
       text1.LinkMode = 2
       text1.LinkMode = 2
       cmd = &quot;[ShowGroup(&quot; + GGroup.Text + &quot;, 2&quot; + &quot;)]&quot;
       cmd = "[ShowGroup(" + GGroup.Text + ", 2" + ")]"
       text1.LinkExecute cmd
       text1.LinkExecute cmd
       cmd = &quot;[ShowGroup(&quot; + GGroup.Text + &quot;, 1&quot; + &quot;)]&quot;
       cmd = "[ShowGroup(" + GGroup.Text + ", 1" + ")]"
       text1.LinkExecute cmd
       text1.LinkExecute cmd
     SGDone:
     SGDone:
Line 126: Line 126:
       Exit Sub
       Exit Sub
     SGError:
     SGError:
       MsgBox &quot;Error Showing Group&quot;
       MsgBox "Error Showing Group"
       Resume SGDone
       Resume SGDone
     End Sub
     End Sub
Line 136: Line 136:
       On Error GoTo RLError
       On Error GoTo RLError
       text1.LinkMode = 0
       text1.LinkMode = 0
       text1.LinkTopic = &quot;Progman|Progman&quot;
       text1.LinkTopic = "Progman|Progman"
       text1.LinkMode = 2
       text1.LinkMode = 2
       cmd = &quot;[Reload(&quot; + GGroup.Text + &quot;)]&quot;
       cmd = "[Reload(" + GGroup.Text + ")]"
       text1.LinkExecute cmd
       text1.LinkExecute cmd
     RLDone:  text1.LinkMode = 0
     RLDone:  text1.LinkMode = 0
       Exit Sub
       Exit Sub
     RLError:
     RLError:
       MsgBox &quot;Error Reloading Group&quot;
       MsgBox "Error Reloading Group"
       Resume RLDone
       Resume RLDone
     End Sub
     End Sub
Line 153: Line 153:
       On Error GoTo AIError
       On Error GoTo AIError
       text1.LinkMode = 0
       text1.LinkMode = 0
       text1.LinkTopic = &quot;Progman|Progman&quot;
       text1.LinkTopic = "Progman|Progman"
       text1.LinkMode = 2
       text1.LinkMode = 2
       '*** The ShowGroup is necessary because AddItem changes the group
       '*** The ShowGroup is necessary because AddItem changes the group
       '*** with the focus. ShowGroup forces the group you want the
       '*** with the focus. ShowGroup forces the group you want the
       '*** action taken to get the focus.
       '*** action taken to get the focus.
       If (Len(GGroup.Text) &gt; 0) Then
       If (Len(GGroup.Text) > 0) Then
           cmd = &quot;[ShowGroup(&quot; + GGroup.Text + &quot;, 2&quot; + &quot;)]&quot;
           cmd = "[ShowGroup(" + GGroup.Text + ", 2" + ")]"
           text1.LinkExecute cmd
           text1.LinkExecute cmd
           cmd = &quot;[ShowGroup(&quot; + GGroup.Text + &quot;, 1&quot; + &quot;)]&quot;
           cmd = "[ShowGroup(" + GGroup.Text + ", 1" + ")]"
           text1.LinkExecute cmd
           text1.LinkExecute cmd
       End If
       End If
       cmd = &quot;[Additem(&quot; + ItemExe.Text + &quot;,&quot; + GItem.Text + &quot;)]&quot;
       cmd = "[Additem(" + ItemExe.Text + "," + GItem.Text + ")]"
       text1.LinkExecute cmd
       text1.LinkExecute cmd
     AIDone:
     AIDone:
Line 170: Line 170:
       Exit Sub
       Exit Sub
     AIError:
     AIError:
       MsgBox &quot;Error adding Item&quot;
       MsgBox "Error adding Item"
       Resume AIDone
       Resume AIDone
     End Sub
     End Sub
Line 180: Line 180:
       On Error GoTo DIError
       On Error GoTo DIError
       text1.LinkMode = 0
       text1.LinkMode = 0
       text1.LinkTopic = &quot;Progman|Progman&quot;
       text1.LinkTopic = "Progman|Progman"
       text1.LinkMode = 2
       text1.LinkMode = 2
       '*** ShowGroup is necessary because DeleteItem changes the group
       '*** ShowGroup is necessary because DeleteItem changes the group
       '*** with the focus. ShowGroup forces the group you want the action
       '*** with the focus. ShowGroup forces the group you want the action
       '*** taken to get the focus.
       '*** taken to get the focus.
       If (Len(GGroup.Text) &gt; 0) Then
       If (Len(GGroup.Text) > 0) Then
           cmd = &quot;[ShowGroup(&quot; + GGroup.Text + &quot;, 2&quot; + &quot;)]&quot;
           cmd = "[ShowGroup(" + GGroup.Text + ", 2" + ")]"
           text1.LinkExecute cmd
           text1.LinkExecute cmd
           cmd = &quot;[ShowGroup(&quot; + GGroup.Text + &quot;, 1&quot; + &quot;)]&quot;
           cmd = "[ShowGroup(" + GGroup.Text + ", 1" + ")]"
           text1.LinkExecute cmd
           text1.LinkExecute cmd
       End If
       End If
       cmd = &quot;[DeleteItem(&quot; + GItem.Text + &quot;)]&quot;
       cmd = "[DeleteItem(" + GItem.Text + ")]"
       text1.LinkExecute cmd
       text1.LinkExecute cmd
     DIDone:  text1.LinkMode = 0
     DIDone:  text1.LinkMode = 0
       Exit Sub
       Exit Sub
     DIError:
     DIError:
       MsgBox &quot;Error Deleting Item&quot;
       MsgBox "Error Deleting Item"
       Resume DIDone
       Resume DIDone
     End Sub
     End Sub
Line 206: Line 206:
       On Error GoTo RIError
       On Error GoTo RIError
       text1.LinkMode = 0
       text1.LinkMode = 0
       text1.LinkTopic = &quot;Progman|Progman&quot;
       text1.LinkTopic = "Progman|Progman"
       text1.LinkMode = 2
       text1.LinkMode = 2
       '*** ShowGroup forces the group you want the action taken on
       '*** ShowGroup forces the group you want the action taken on
       '*** to get the focus.
       '*** to get the focus.
       If (Len(GGroup.Text) &gt; 0) Then
       If (Len(GGroup.Text) > 0) Then
           cmd = &quot;[ShowGroup(&quot; + GGroup.Text + &quot;, 2&quot; + &quot;)]&quot;
           cmd = "[ShowGroup(" + GGroup.Text + ", 2" + ")]"
           text1.LinkExecute cmd
           text1.LinkExecute cmd
           cmd = &quot;[ShowGroup(&quot; + GGroup.Text + &quot;, 1&quot; + &quot;)]&quot;
           cmd = "[ShowGroup(" + GGroup.Text + ", 1" + ")]"
           text1.LinkExecute cmd
           text1.LinkExecute cmd
       End If
       End If
       cmd = &quot;[ReplaceItem(&quot; + GItem.Text + &quot;)]&quot;
       cmd = "[ReplaceItem(" + GItem.Text + ")]"
       text1.LinkExecute cmd
       text1.LinkExecute cmd
       cmd = &quot;[Additem(&quot; + ItemExe.Text + &quot;,&quot; + GItem.Text + &quot;)]&quot;
       cmd = "[Additem(" + ItemExe.Text + "," + GItem.Text + ")]"
       text1.LinkExecute cmd
       text1.LinkExecute cmd
     RIDone:
     RIDone:
Line 224: Line 224:
       Exit Sub
       Exit Sub
     RIError:
     RIError:
       MsgBox &quot;Error Replacing Item&quot;
       MsgBox "Error Replacing Item"
       Resume RIDone
       Resume RIDone
     End Sub
     End Sub
Line 230: Line 230:
<li>From the Run menu, choose Start (ALT, R, S) or press the F5 key to run the program. Enter the group you want created in the GGroup textbox and click the Create Group button. You will now see the group you created in Program Manager. To add an item to a group, enter the group in the GGroup textbox. Enter the item you want added in the GItem textbox and enter the command line in the ItemExe textbox. The item will now be in the group you specified.</li></ol>
<li>From the Run menu, choose Start (ALT, R, S) or press the F5 key to run the program. Enter the group you want created in the GGroup textbox and click the Create Group button. You will now see the group you created in Program Manager. To add an item to a group, enter the group in the GGroup textbox. Enter the item you want added in the GItem textbox and enter the command line in the ItemExe textbox. The item will now be in the group you specified.</li></ol>


For more information, refer to the &quot;Programmers Reference, Volume 1: Overview Microsoft Windows SDK,&quot; chapter 17, &quot;Shell Dynamic DataExchange Interface.&quot; Also, look in the Windows SDK Help file in the Progman topic.
For more information, refer to the "Programmers Reference, Volume 1: Overview Microsoft Windows SDK," chapter 17, "Shell Dynamic DataExchange Interface." Also, look in the Windows SDK Help file in the Progman topic.


</div>
</div>

Latest revision as of 12:24, 21 July 2020

Knowledge Base


VB3 Manipulate Groups & Items in Program Manager Using DDE

Article ID: 104943

Article Last Modified on 12/9/2003



APPLIES TO

  • Microsoft Visual Basic 2.0 Standard Edition
  • Microsoft Visual Basic 3.0 Professional Edition
  • Microsoft Visual Basic 2.0 Professional Edition
  • Microsoft Visual Basic 3.0 Professional Edition



This article was previously published under Q104943

SUMMARY

Program Manager has a DDE command-string interface that allows other applications to create, display, delete, and reload groups; add items to groups; replace items in groups; delete items from groups; and close Program Manager. The following commands perform these actions:

  • CreateGroup
  • Reload (Windows 3.1 only)
  • DeleteGroup
  • ShowGroup
  • ReplaceItem (Windows 3.1 only)
  • DeleteItem (Windows version 3.1 only)
  • AddItem


MORE INFORMATION

Perform the following steps to produce an application that manipulates Program Manager using DDE:

  1. Start Visual Basic or if Visual Basic is already running, choose New Project from the File menu (ALT, F, N). Form1 is created by default.
  2. Add a Textbox control (Text1) to Form1.
  3. Add a Label control (Label1) to Form1 and change the caption to Group.
  4. Add a Textbox control (Text2) to Form1 and change the name to GGroup.
  5. Add a Label control (Label2) to Form1 and change the caption to Item.
  6. Add a Textbox control (Text3) to Form1 and change the name to GItem.
  7. Add a Label control (Label3) to Form1 and change the caption to Command Line.
  8. Add a Textbox control (Text4) to Form1 and change the name to ItemExe.
  9. Add a Command Button control (Command1) to Form1 and name it CGroup for create group.
  10. Add the following code to the CGroup_Click event of Form1:

        Sub CGroup_Click ()
        Dim cmd As String
           On Error GoTo CGError
           text1.LinkMode = 0
           text1.LinkTopic = "Progman|Progman"
           text1.LinkMode = 2
           cmd = "[CreateGroup(" + GGroup.Text + ")]"
           text1.LinkExecute cmd
        CGDone:   text1.LinkMode = 0
           Exit Sub
        CGError:
           MsgBox "Error Adding Group"
           Resume CGDone
        End Sub
                            
  11. Add a Command Button control (Command2) to Form1 and name it DGroup for Delete Group.
  12. Add the following code to the DGroup_Click event of Form1:

        Sub DGroup_Click ()
        Dim cmd As String
           On Error GoTo DGError
           text1.LinkMode = 0
           text1.LinkTopic = "Progman|Progman"
           text1.LinkMode = 2
           cmd = "[DeleteGroup(" + GGroup.Text + ")]"
           text1.LinkExecute cmd
        DGDone:   text1.LinkMode = 0
           Exit Sub
        DGError:
           MsgBox "Error Deleting Group"
           Resume DGDone
        End Sub
                            
  13. Add a Command Button control (Command3) to Form1 and name it SGroup for ShowGroup.
  14. Add the following code to the SGroup_Click event of Form1:

        Sub SGroup_Click ()
           Dim cmd As String
           On Error GoTo SGError
           text1.LinkMode = 0
           text1.LinkTopic = "Progman|Progman"
           text1.LinkMode = 2
           cmd = "[ShowGroup(" + GGroup.Text + ", 2" + ")]"
           text1.LinkExecute cmd
           cmd = "[ShowGroup(" + GGroup.Text + ", 1" + ")]"
           text1.LinkExecute cmd
        SGDone:
           text1.LinkMode = 0
           Exit Sub
        SGError:
           MsgBox "Error Showing Group"
           Resume SGDone
        End Sub
                            
  15. Add a Command Button control (Command4) to Form1 and name it Reload.
  16. Add the following code to the Reload_Click event of Form1:

        Sub Reload_Click ()
        Dim cmd As String
           On Error GoTo RLError
           text1.LinkMode = 0
           text1.LinkTopic = "Progman|Progman"
           text1.LinkMode = 2
           cmd = "[Reload(" + GGroup.Text + ")]"
           text1.LinkExecute cmd
        RLDone:   text1.LinkMode = 0
           Exit Sub
        RLError:
           MsgBox "Error Reloading Group"
           Resume RLDone
        End Sub
                            
  17. Add a Command Button control (Command5) to Form1 and name it AItem for add item.
  18. Add the following code to the AItem_Click event of Form1:

        Sub AItem_Click ()
        Dim cmd As String
           On Error GoTo AIError
           text1.LinkMode = 0
           text1.LinkTopic = "Progman|Progman"
           text1.LinkMode = 2
           '*** The ShowGroup is necessary because AddItem changes the group
           '*** with the focus. ShowGroup forces the group you want the
           '*** action taken to get the focus.
           If (Len(GGroup.Text) > 0) Then
              cmd = "[ShowGroup(" + GGroup.Text + ", 2" + ")]"
              text1.LinkExecute cmd
              cmd = "[ShowGroup(" + GGroup.Text + ", 1" + ")]"
              text1.LinkExecute cmd
           End If
           cmd = "[Additem(" + ItemExe.Text + "," + GItem.Text + ")]"
           text1.LinkExecute cmd
        AIDone:
           text1.LinkMode = 0
           Exit Sub
        AIError:
           MsgBox "Error adding Item"
           Resume AIDone
        End Sub
                            
  19. Add a Command Button control (Command6) to Form1 and name it DItem for delete item.
  20. Add the following code to the DItem_Click event of Form1:

        Sub DItem_Click ()
           Dim cmd As String
           On Error GoTo DIError
           text1.LinkMode = 0
           text1.LinkTopic = "Progman|Progman"
           text1.LinkMode = 2
           '*** ShowGroup is necessary because DeleteItem changes the group
           '*** with the focus. ShowGroup forces the group you want the action
           '*** taken to get the focus.
           If (Len(GGroup.Text) > 0) Then
              cmd = "[ShowGroup(" + GGroup.Text + ", 2" + ")]"
              text1.LinkExecute cmd
              cmd = "[ShowGroup(" + GGroup.Text + ", 1" + ")]"
              text1.LinkExecute cmd
           End If
           cmd = "[DeleteItem(" + GItem.Text + ")]"
           text1.LinkExecute cmd
        DIDone:   text1.LinkMode = 0
           Exit Sub
        DIError:
           MsgBox "Error Deleting Item"
           Resume DIDone
        End Sub
                            
  21. Add a Command Button control (Command7) to Form1 and name it RItem for replace item.
  22. Add the following code to the RItem_Click event of Form1:

        Sub RItem_Click ()
        Dim cmd As String
           On Error GoTo RIError
           text1.LinkMode = 0
           text1.LinkTopic = "Progman|Progman"
           text1.LinkMode = 2
           '*** ShowGroup forces the group you want the action taken on
           '*** to get the focus.
           If (Len(GGroup.Text) > 0) Then
              cmd = "[ShowGroup(" + GGroup.Text + ", 2" + ")]"
              text1.LinkExecute cmd
              cmd = "[ShowGroup(" + GGroup.Text + ", 1" + ")]"
              text1.LinkExecute cmd
           End If
           cmd = "[ReplaceItem(" + GItem.Text + ")]"
           text1.LinkExecute cmd
           cmd = "[Additem(" + ItemExe.Text + "," + GItem.Text + ")]"
           text1.LinkExecute cmd
        RIDone:
           text1.LinkMode = 0
           Exit Sub
        RIError:
           MsgBox "Error Replacing Item"
           Resume RIDone
        End Sub
                            
  23. From the Run menu, choose Start (ALT, R, S) or press the F5 key to run the program. Enter the group you want created in the GGroup textbox and click the Create Group button. You will now see the group you created in Program Manager. To add an item to a group, enter the group in the GGroup textbox. Enter the item you want added in the GItem textbox and enter the command line in the ItemExe textbox. The item will now be in the group you specified.

For more information, refer to the "Programmers Reference, Volume 1: Overview Microsoft Windows SDK," chapter 17, "Shell Dynamic DataExchange Interface." Also, look in the Windows SDK Help file in the Progman topic.


Additional query words: 1.00 2.00 3.00

Keywords: kbcode KB104943