Microsoft KB Archive/76551

= VB3 DDE Example Between VB and Windows Program Manager =

Article ID: 76551

Article Last Modified on 12/12/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
 * Microsoft Visual Basic 1.0 Standard Edition
 * Microsoft Windows 3.0 Standard Edition
 * Microsoft Windows 3.1 Standard Edition

-



This article was previously published under Q76551



SUMMARY
This article demonstrates how to send dynamic data exchange (DDE) interface commands to the Microsoft Windows Program Manager from Microsoft Visual Basic for Windows using DDE.

The interface commands available through DDE with the Windows Program Manager are as follows:

CreateGroup(GroupName,GroupPath)

ShowGroup(GroupName,ShowCommand)

AddItem(CommandLine,Name,IconPath,IconIndex,XPos,YPos)

DeleteGroup(GroupName)

ExitProgman(bSaveState)

A full explanation of the above commands can be found in Chapter 22, pages 19-22 of the &quot;Microsoft Windows Software Development Kit Guide to Programming&quot; version 3.1 manual.

An application can also obtain a list of Windows groups from the Windows Program Manager by issuing a LinkRequest to the &quot;PROGMAN&quot; item.



MORE INFORMATION
The following program demonstrates how to use four of the five Windows Program Manager DDE interface commands and the one DDE request:

 Run Visual Basic for Windows, or from the File menu, choose New Project (press ALT, F, N) if Visual Basic for Windows is already running. Form1 is created by default.  Create the following controls with the given properties on Form1:      Object     Name         Caption --         ---      TextBox    Text1 Button    Command1     Make Button    Command2     Delete Button    Command3     Request

(In Visual Basic version 1.0 for Window set the CtlName Property    for the above objects instead of the Name property.)

  Add the following code to the Command1_Click event: Sub Command1_Click Text1.LinkTopic = &quot;ProgMan|Progman&quot; Text1.LinkMode = 2              ' Establish manual link.

Text1.LinkExecute &quot;[CreateGroup(Test Group)]&quot; ' Make a group in Windows Program Manager.

Text1.LinkExecute &quot;[AddItem(c:\vb\vb.exe, Visual Basic)]&quot; ' Add an item to that group.

Text1.LinkExecute &quot;[ShowGroup(Test Group, 7)]&quot; ' Iconize the group and focus to VB application.

On Error Resume Next ' Disconnecting link with Windows Program Text1.LinkMode = 0   ' Manager causes an error in Windows 3.0. ' This is a known problem with Windows Program Manager.

End Sub   Add the following code to the Command2_Click event: Sub Command2_Click Text1.LinkTopic = &quot;ProgMan|Progman&quot; Text1.LinkMode = 2         ' Establish manual link.

Text1.LinkExecute &quot;[DeleteGroup(Test Group)]&quot; ' Delete the group and all items within it.

On Error Resume Next ' Disconnecting link with Windows Program Text1.LinkMode = 0   ' Manager causes an error in Windows 3.0. ' This is a known problem with Windows Program Manager.

End Sub   Add the following code to the Command3_Click event: Sub Command3_Click Text1.LinkTopic = &quot;ProgMan|Progman&quot; Text1.LinkItem = &quot;PROGMAN&quot; Text1.LinkMode = 2     ' Establish manual link. Text1.LinkRequest      ' Get a list of the groups.

On Error Resume Next ' Disconnecting link with Windows Program Text1.LinkMode = 0   ' Manager causes an error in Windows 3.0. ' This is a known problem with Windows Program Manager. End Sub  Press the F5 key to run the program.</li> Choose the Make button, then choose the Delete button. Note the result.</li> Choose the Request button. This will put a list of the groups in the Windows Program Manager to be placed in the text box. The individual items are delimited by a carriage return plus linefeed.</li></ol>

As noted in the Windows Software Development Kit (SDK) manual mentioned above, the ExitProgman command will only work if Windows Program Manager is NOT the shell (the startup program when you start Windows).

For a more comprehensive explanation of the CreateGroup, ShowGroup, AddItem, DeleteGroup, and ExitProgman commands, query on the following words in the Microsoft Knowledge Base:

DDE and CreateGroup

Additional query words: 2.00 3.00

Keywords: kbcode KB76551

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.