Board index » delphi » Creating Program Manager Groups and Icons

Creating Program Manager Groups and Icons

I need code which will create a group in Program Manager and then to
create an icon in that group.

Thanks,

Larry Rutledge

 

Re:Creating Program Manager Groups and Icons


Quote
Larry J. Rutledge wrote:

> I need code which will create a group in Program Manager and then to
> create an icon in that group.
> Larry Rutledge

It's done via DDE.  MS documents this in a couple of Knowledge Base articles on
their web site.  Search on additem | addgroup or DDE & program manager.

Re:Creating Program Manager Groups and Icons


In article <4ol1pk$...@news.calweb.com>
           lar...@calweb.com "Larry J. Rutledge" writes:

Quote
> I need code which will create a group in Program Manager and then to
> create an icon in that group.

You need to open a DDE session with PROGMAN|PROGMAN!SYSTEM

Then You need to send commands (DDEExecute):

Create Group:
 [CreateGroup(<group name>)]
e.g.
 [CreateGroup(Demo Group)]

Delete Group:
 [DeleteGroup(<group name>)]
e.g.
 [DeleteGroup(DemoGroup)]

Add Item:
 [AddItem(<cmdLine>, <Name>)]
e.g.
 [AddItem(c:\windows\calc.exe,Calculator Program)]

BTW, The link should be Manual or it will be rejected!

Hope This Helps ;)

(Also works in Win95 for command Groups!)
(See Demo App DDE.MAK In visual basic 3.0 for more info)

--
Daniel Silverstone

Re:Creating Program Manager Groups and Icons


Quote
> I need code which will create a group in Program Manager and then to
> create an icon in that group.

Check the Delphi Super Page for the progmn11.zip component.
It is a subclassed DDE component - you just supply the group
name and item name (with some parameters), call a method,
and it adds the group and item to the Program Manager.

If you need to do other stuff besides creating icons, here's a
PM/DDE summary that I found on the web, plus some Delphi sample code.

==========================

Topic:  Windows Program Manager and DDE commands
          Thanks for the contribution from Stephen Bottomley 100237,464

#: 248167 S12/CW Adv. Features
    19-Dec-95  21:26:53
Sb: #248154-ProgMan Groups & Icons
Fm: Stephen Bottomley 100237,464

The CW docs on DDE give  you the basics. Here some other documentation on
Progman DDE commands (hope it formats reasonable well<g>):
--------------------------------------------------------------
Command-String Interface

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 to close
Program Manager. The following commands perform these actions:

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

The setup program for an application can use these commands, for example, to
instruct Program Manager to install the application's icon in a group.
Multiple commands may be concatenated; each command must be contained in
square brackets, and parameters must be contained in parentheses and separated
by commas. Quotation marks must be used to delimit arguments that contain
spaces, brackets, or parentheses. For example, the following set of commands
adds WINAPP.EXE to the Windows Applications group:

[CreateGroup("Windows Applications")]
[ShowGroup("MYGROUP.GRP",1)]
[AddItem(winapp.exe,Win App,winapp.exe,2)]

To use these commands, an application must first initiate a conversation with
Program Manager. The application and topic names for the conversation are both
PROGMAN. Then the application sends the WM_DDE_EXECUTE message, specifying the
appropriate command and its parameters.

Note:   The user can configure Windows to use a shell other than Program
Manager as the default. As a result, you should not design an application
assuming that Program Manager will be available for a DDE conversation.

The following sections describe Program Manager DDE command strings in detail.
In the syntax blocks in the following sections, brackets enclose optional
arguments.

CreateGroup

The syntax for the CreateGroup command has this form:
CreateGroup(GroupName[,GroupPath])
The CreateGroup command instructs Program Manager to create a new group or
activate the window of an existing group.
Following are the parameters for this command:

GroupName       Identifies the group to be created. This parameter is a
string. If a group already exists with the name specified by GroupName,
CreateGroup activates the group window.
GroupPath       Specifies the path of the group file. If your application does
not supply this parameter, Windows uses a default filename for the group in
the Windows directory.

ShowGroup

The syntax for the ShowGroup command has this form:
ShowGroup(GroupName,ShowCommand)
The ShowGroup command instructs Program Manager to minimize, maximize, or
restore the window of an existing group.
Following are the parameters for this command:

GroupName       Identifies the group window to be minimized, maximized, or
restored.
ShowCommand     Specifies the action that Program Manager is to perform on the
group window. This parameter is an integer. It must have one of the following
values:

Value   Meaning

1       Activates and displays the group window. If the window is minimized or
        maximized, Windows restores it to its original size and position.
2       Activates the group window and displays it as an icon.
3       Activates the group window and displays it as a maximized window.
4       Displays the group window in its most recent size and position. The
        window that is currently active remains active.
5       Activates the group window and displays it in its current size and
        position.
6       Minimizes the group window.
7       Displays the group window as an icon. The window that is currently
        active remains active.
8       Displays the group window in its current state. The window that is
        currently active remains active.

DeleteGroup

The syntax for the DeleteGroup command has this form:
DeleteGroup(GroupName)
The DeleteGroup command instructs Program Manager to delete an existing group.

Following is the parameter for this command:

GroupName       Identifies the group to be deleted.

Reload

The syntax for the Reload command has this form:
Reload(GroupName)
The ReloadGroup command instructs Program Manager to remove and reload an
existing group. An application that modifies group files can use this command
to cause Program Manager to update the groups when it has finished making
modifications.
Following is the parameter for this command:

GroupName       Identifies the group to be removed and reloaded. If the
GroupName parameter is not specified, Program Manager unloads all groups and
reloads the [Group] section of PROGMAN.INI. The [Settings] and [Restrictions]
sections are not reread.

AddItem

The syntax for the AddItem command has this form:

AddItem(CmdLine[,
    Name[,IconPath[,IconIndex[,xPos, yPos[,DefDir[,
    HotKey,[,fMinimize] ] ] ] ] ] ])

The AddItem command instructs Program Manager to add an icon to an existing
group.
Following are the parameters for this command:

CmdLine Specifies the full command line required to execute the application.
This parameter is a string. At a minimum, this string is the name of the
executable file for the application. It can also include the full path of the
application and any parameters required by the application.
Name    Specifies the title that is displayed below the icon in the group
window.
IconPath        Identifies the filename for the icon to be displayed in the
group window. This parameter is a string. This file can be either a Windows
executable file or an icon file. If the IconPath parameter is not specified,
Program Manager uses the first icon in the file specified by the CmdLine
parameter if that file is an executable file. If CmdLine specifies an
associated file, Program Manager uses the first icon of the associated
executable file. The association is taken from the registration database. (For
more information about the registration database, see The Windows Shell
Overview.) If CmdLine specifies neither an executable file nor an associated
executable file, Program Manager uses a default icon.

IconIndex       Specifies the index of the icon in the file identified by the
IconPath parameter. The IconIndex parameter is an integer. PROGMAN.EXE
contains five built-in icons that can be used for non-Windows programs.
xPos    Specifies the horizontal position of the icon in the group window.
This parameter is an integer. You must use both the xPos and yPos parameters
to specify the position of the icon. If you do not specify the position,
Program Manager places the icon in the next available space.
yPos    Specifies the vertical position of the icon in the group window. This
parameter is an integer. You must use both the xPos and yPos parameters to
specify the position of the icon. If you do not specify the position, Program
Manager places the icon in the next available space.

DefDir  Specifies the name of the default (or working) directory. This
parameter is a string.
HotKey Identifies a hot (or shortcut) key that is specified by the user.
fMinimize       Specifies whether an application window should be minimized
when it is first displayed.

ReplaceItem

The syntax for the ReplaceItem command has this form:
ReplaceItem(ItemName)
The ReplaceItem command instructs Program Manager to delete an item and record
the position of the deleted item. Program Manager will add a new item
(specified by the next AddItem command) at this recorded position.
Following is the parameter for this command:

ItemName        Specifies the item to be deleted. Its position is recorded by
Program Manager.

DeleteItem

The syntax for the DeleteItem command has this form:
DeleteItem(ItemName)
The DeleteItem command instructs Program Manager to delete an item from the
currently active group.
Following is the parameter for this command:

ItemName        Specifies the item to be deleted from the currently active
group.

ExitProgman

The syntax for the ExitProgman command has this form:
ExitProgman(bSaveGroups)
If Program Manager was started by another application, the ExitProgman command
instructs Program Manager to exit and, optionally, save its group information.

Following is the parameter for this command:

bSaveGroups     Specifies a Boolean value that, if nonzero, causes Program
Manager to save its group information before closing. If bSaveGroups is zero,
Program Manager does not save its group information.

Steve B.
[Team Topspeed]

=========================

Here's a Delphi sample using some of these commands.
It creates/updates a PM icon that represents a saved-game file.
PmDdeClient is a DDEClientConv component with DdeAutomatic on.

procedure SetOldGamePMIcon(ThisFileName : string);
{ add/update the Program Manager icon for the given saved game }
var
  MacroString, CommandLine : string;
  MacroPChar : array[0..255] of Char;
begin
  with MainForm, MainForm.PmDdeClient do
    if SetLink('progman','progman') = false then
      NormalPointerMessage('Couldn''t link to Program Manager.','Communication Error')
    else
      begin
      { create/activate the proper PM group }
      MacroString := '[CreateGroup("My Group")]' + chr(13) + chr(10);
      StrPCopy(MacroPChar,
...

read more »

Re:Creating Program Manager Groups and Icons


lar...@calweb.com (Larry J. Rutledge) wrote:

Quote
>I need code which will create a group in Program Manager and then to
>create an icon in that group.
>Thanks,
>Larry Rutledge

If you did a full install, (D1) there should be a program in the
delphi\demos directory entitled 'DDEDEMO'. This program illustrates
the use of DDE by creating a Program Group & item.

HTH
Peter Kott
p...@mars.superlink.net

Other Threads