ACC: How to Add an Icon to Program Manager Using DDEID: Q109394
|
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article describes a sample Access Basic function called
CreatePROGMANIcon() that you can use to create an icon in the Microsoft
Windows Program Manager using dynamic data exchange (DDE).
This article assumes that you are familiar with Access Basic and with
creating Microsoft Access applications using the programming tools provided
with Microsoft Access. For more information on Access Basic, please refer
to the "Introduction to Programming" manual in Microsoft Access version
1.x, or the "Building Applications" manual, Chapter 3, "Introducing Access
Basic" in version 2.0.
To set up the CreatePROGMANIcon() function, create a new module and enter
the code below.
NOTE: In the following sample code, an underscore (_) is used as a line-
continuation character. Remove the underscore from the end of the line when
re-creating this code in Access Basic.
Option Explicit
'**************************************************
' FUNCTION: CreatePROGMANIcon
'
' PURPOSE:
' To create an icon in the Windows Program Manager.
'
' ARGUMENTS:
' CommandLine - The command line argument to execute
' when the icon is double-clicked.
' IconText - The text to appear under the icon.
' GroupName - The name of the group to place the
' icon in.
' RESULT:
' An icon is placed in the specified group. If the
' group does not exist, a new group is created.
'
' *************************************************
Function CreatePROGMANIcon (CommandLine$, IconText$, GroupName$)
Dim ChanNum As Integer
Dim Groups As String
Dim Exe As String
' Begin a DDE conversation with Program Manager.
ChanNum = DDEInitiate("PROGMAN", "PROGMAN")
' Request a tab delimited list of Program Manager groups.
Groups = DDERequest(ChanNum, "Progman")
' See if the requested group exists in the list.
' If not, create the group.
If Not InStr(1, Groups, GroupName) Then
DDEExecute ChanNum, "[CreateGroup(" & GroupName & ")]"
End If
' Add an icon to the group with the specified text underneath.
Exe = "[AddItem(" & CommandLine & ", " & IconText & ",,)]"
DDEExecute ChanNum, Exe
DDETerminate ChanNum
End Function
? CreatePROGMANIcon("C:\WINDOWS\NOTEPAD.EXE C:\AUTOEXEC.BAT", _
"AUTOEXEC", "MAIN")
Function CreatePROGMANIcon2 (CommandLine$, IconText$, GroupName$, _
IconFile$, IconNum$)
Dim ChanNum As Integer
Dim Groups As String
Dim Exe As String
' Begin a DDE conversation with Program Manager.
ChanNum = DDEInitiate("PROGMAN", "PROGMAN")
' Request a tab delimited list of Program Manager groups.
Groups = DDERequest(ChanNum, "Progman")
' See if the requested group exists in the list.
' If not, create the group.
If Not InStr(1, Groups, GroupName) Then
DDEExecute ChanNum, "[CreateGroup(" & GroupName & ")]"
End If
' Add an icon to the group with the specified text underneath.
Exe$ = "[AddItem(" & CommandLine & ", " & IconText & ", _
" & IconFile & ", " & IconNum & ")]"
DDEExecute ChanNum, Exe
DDETerminate ChanNum
End Function
CreatePROGMANIcon2("C:\TEST\TEST.EXE ","My App","My Group",_
"C:\WINDOWS\MOREICONS.DLL","4")
CreatePROGMANIcon2("C:\TEST\TEST.EXE ","My App","My Group",_
"C:\ICONS\MY.ICO","")
Windows Software Development Kit "Guide to Programming," pages 19-22
For more information about DDE and Program Manager, please see the
following article in the Microsoft Knowledge Base:
Q119724 ADT2: How to Add an Icon to Program Manager Using DDE
Keywords : kbinterop
Version : 1.0 1.1 2.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: March 29, 1999