Creating Additional Program Groups and Items
for applications created with
the Microsoft Access Developer's Toolkit(tm) (ADT)
Setup Wizard.

Microsoft Access VERSION: 2.00
OPERATING SYSTEM(S): Microsoft WINDOWS, Windows(tm) for Workgroups, or 
Windows NT(tm) operating system version 3.1 or later.


SUMMARY
=======

This article describes a sample Microsoft Access database (AddIcons.MDB) you
can run as an executable file immediately after the completion of your
Microsoft Access Developer's Toolkit(tm) (ADT) application's setup. This database
allows you to create multiple Progam Manager groups, as well as multiple
Progam Manager items within these groups.

The sample Access Basic function, called CreateProgmanGroupIcons(), uses
dynamic data exchange (DDE) to create additional icons in Microsoft Windows
Program Manager.


MORE INFORMATION
================

1. Create a new database called AddIcons.MDB.

2. Create a new macro called Autoexec.

   Macro Name     Action
   -------------------------
   Autoexec       RunCode
                  Quit

   Autoexec Actions
   ----------------
   RunCode
      Function Name:  CreateProgmanGroupIcons()
   Quit
      Options:        Exit

3. Create a new table called tbl_Progman designed as follows:

   Table: tbl_Program
   ------------------
   FieldName: mGroupName
      DataType: Text
      Field Size: 30
      Required:  Yes

   FieldName: mIconText
      DataType: Text
      Field Size: 40
      Required: Yes

   FieldName: mIconFile
      DataType: Text
      Field Size: 50

   FieldName: mIconNum
      DataType: Text
      Field Size: 5

   FieldName: mCommandLine
      DataType: Text
      Field Size: 120
      Required:  Yes

   FieldName: mIconDefault
      DataType: Text
      Field Size: 120

   Below is a breakdown of each field in the table and the information needed
   in each:

   mGroupName specifies the name of the group that you want the Program
   Manager icons to appear in. (Required entry in the table tbl_Progman).

   NOTE: Using the Setup Wizard you encounter the screen "What is the name of
   your application?" Whatever you enter in the Application Name text box
   here, should also be entered in the mGroupName field so that your
   additional icons will be directed to your application's program group.

   mIconText specifies the title to be displayed below the icon in
   the program group window. (Required entry in the table tbl_Progman).

   mIconFile specifies the icon's filename. If a filename is not specified
   then a default icon will be used.

   mIconNum specifies the index number of the icon in the file identified by
   the mIconFile field. For example, each icon in Progman.Exe would be
   represented by a number: 1, 2, 3, and so on. If an icon index is not
   specified then a default icon will be used.

   mCommandLine specifies the full command line required to execute the
   application. (Required entry in the table tbl_Progman).

   mIconDefault specifies the name of the default (or working) directory.
   If a default directory is not specified then the current directory that
   the AddIcons.MDB resides in will be used.

4. To set up the CreateProgmanGroupIcons() function, create a new
   module with the following code:

NOTE: In the following sample code, an underscore (_) is used as a
line-continuation character. Remove the underscore when re-creating
this code in Access Basic.

Option Explicit

'**********************************************
' FUNCTION: CreateProgmanGroupIcons
'
' PURPOSE:
'   To create icons in Program Manager after
'   your ADT distribution disks finish setup
'**********************************************

Function CreateProgmanGroupIcons ()
   Dim Mydb As Database, Rs  As Recordset, Rcount As Integer, Xyz As Integer
   Dim chan As Integer, Exe As String
   Dim GroupName$, IconText$, IconFile$, IconNum$, CommandLine$, IconDefault$

   On Error GoTo Creat_Errors
   DoCmd Hourglass False

   Set Mydb = DBEngine.Workspaces(0).Databases(0)
   Set Rs = mydb.OpenRecordset("tbl_Progman", DB_OPEN_DYNASET)
   Rs.MoveLast
   Rcount = Rs.recordcount
   Rs.MoveFirst

   'Begin a DDE Conversation with Program Manager
   chan = DDEInitiate("PROGMAN", "PROGMAN")

   For Xyz = 1 To Rcount
      GroupName$ = Rs![mGroupName]
      IconText$ = Rs![mIconText]
      IconFile$ = IIf(IsNull(Rs![mIconFile]), "", Rs![mIconFile])
      IconNum$ = IIf(IsNull(Rs![mIconNum]), "", Rs![mIconNum])
      CommandLine$ = Rs![mCommandLine]
      IconDefault$ = IIf(IsNull(Rs![mIconDefault]), CurDir, Rs![mIconDefault])

      'GroupName is a string that names the group to be created or
      'activated.
      'Executing the CreateGroup DDE command to PROGMAN
      DDEExecute chan, "[CreateGroup(" & GroupName$ & ")]"

      On Error Resume Next
      'If duplicate icons exist they will be replaced
      DDEExecute chan, "[ReplaceItem(" & IconText$ & ")]"

      'Instructs Program Manager to create a new program icon in
      'the active group specified by the variable GroupName
      'Executing the AddItem DDE command to PROGMAN
      Exe = "[AddItem(" & CommandLine$ & ", " & IconText$ & ", " & IconFile$_
      & ", " & IconNum$ & ",,, " & IconDefault$ & ")]"
      DDEExecute chan, Exe
      Rs.MoveNext
   Next Xyz
   DDETerminate chan
   DoCmd Hourglass False
   Exit Function
Creat_Errors:
   MsgBox Error$
   Exit Function
End Function

5. Enter the appropriate values into the tbl_Program table.

6. Run the ADT Setup Wizard to create the distribution disks for your
   application. At the "Add File" screen in the wizard, specify AddIcons.MDB.

7. At the screen "Do you want to run another application after Setup is
   finished? If so enter the application name and path." enter the following:

   Executable File Name: Msarn200.Exe
   Command Line:         Msarn200.Exe AddIcons.MDB

Below are some sample Program Manager items you can create with the
CreateProgmanGroupIcons function. Included is the appropriate data to enter
in the tbl_Progman table.

1. To repair and compact your application database:

Field: mGroupName
Value: NWIND Utilities

Field: mIconText
Value: Repair / Compact NWIND

Field: mIconFile
Value: Progman.Exe

Field: mIconNum
Value: 22

Field: mCommandLine
Value: Msarn200.Exe NWIND.MDB /Repair /Compact

Field: mIconDefault
Value: "Do not enter a value unless you want a specific directory"

2. To create icons to run additional database command switches:

Field: mGroupName
Value: NWIND Utilities

Field: mIconText
Value: Solutions Database

Field: mIconFile
Value: Progman.Exe

Field: mIconNum
Value: 9

Field: mCommandLine
Value: Msarn200.Exe NWIND.MDB /X OtherMacro

3. To display your own Readme.Txt file:

Field: mGroupName
Value: NWIND Utilities

Field: mIconText
Value: My Readme.Txt

Field: mCommandLine
Value: Notepad.Exe NWIND.TXT



