The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic
programming system for Windows, versions 1.0, 2.0, and 3.0
SUMMARY
Program Manager (Progman) has a DDE command-string interface that allows
other applications to view the groups and items that currently exist within
Progman.
MORE INFORMATION
Perform the following steps to produce an application that will retrieve
the group and items from Progman by using DDE:
- Start a new project in Visual Basic. Form1 is created by default.
- Add two Text box controls (tGroups and tItems) to Form1. Set the visible
property on both to false. The DDE link needs these controls.
- Add two Combo box controls (ComGroups and ComItems) to Form1.
- Add a Command button (cGroups) to Form1 and change the caption
property to Groups.
- Add the following code to the cGroups_Click () event:
Sub cGroups_Click ()
Dim sGroups As String
Dim pos As Integer
On Error GoTo GError
tGroups.LinkMode = 0
tGroups.LinkTopic = "Progman|Progman"
tGroups.LinkMode = 2
tGroups.LinkItem = "groups"
tGroups.LinkRequest
' Parse groups that come back:
sGroups = tGroups.Text
pos = InStr(1, sGroups, Chr(13))
While pos
ComGroups.AddItem RTrim$(Mid$(sGroups, 1, pos - 1))
sGroups = LTrim$(Mid$(sGroups, pos + 2))
' The + 2 on the previous line gets past the line feed chr(10)
pos = InStr(1, sGroups, Chr(13))
Wend
' Select first member in combo box:
ComGroups.ListIndex = 1
GDone:
tGroups.LinkMode = 0
Exit Sub
GError:
MsgBox "Error in getting groups"
Resume GDone
End Sub
- Add another Command button (cItems) to Form1, and change the caption to
Items.
- Add the following code to the cItems_Click () event:
Sub cItems_Click ()
Dim sItems As String
On Error GoTo IError
' Clear the combo box:
ComItems.Clear
If (Len(ComGroups.Text)) Then
tItems.LinkMode = 0
tItems.LinkTopic = "Progman|Progman"
tItems.LinkMode = 2
tItems.LinkItem = ComGroups.Text
tItems.LinkRequest
' Parse items that come back:
sItems = tItems.Text
pos = InStr(1, sItems, Chr(13))
While pos
ComItems.AddItem RTrim$(Mid$(sItems, 1, pos - 1))
sItems = LTrim$(Mid$(sItems, pos + 2))
' The + 2 on the previous line gets past the line feed chr(10)
pos = InStr(1, sItems, Chr(13))
Wend
End If
' Select first member in combo box:
ComItems.ListIndex = 1
IDone:
tItems.LinkMode = 0
Exit Sub
IError:
MsgBox "Error in getting items"
Resume IDone
End Sub
- From the Run menu, choose Start (ALT, R, S) or press the F5 key to run
the program. Press the Groups button and all the groups on Progman will
be loaded into the ComGroups Combo box. Then press the Items button
and all the items in the group selected in the ComGroups Combo box
will be put into the ComItems Combo box.
REFERENCES
More information can be found in:
- "Programmers Reference, Volume 1: Overview Microsoft Windows SDK,"
Chapter 17, "Shell Dynamic Data Exchange Interface DDEML."
- Progman topic in the Windows SDK Help menu.
|