VB icon

Creating Program Manager Groups & Icons

Email
Submitted on: 1/1/2015 2:43:00 AM
By: VB Tips and Source Code (from psc cd)  
Level: Not Given
User Rating: By 2 Users
Compatibility: VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 1031
 
     Create program manager groups and icons from your code!
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Creating Program Manager Groups & Icons
' Description:Create program manager groups and icons from your code!
' By: VB Tips and Source Code (from psc cd)
'
' Inputs:It requires 3 arguments to be passed to it. They are: 
1.The form that contains Label1 (x) 2.A string variable containing the group's name (GroupName$) 3.A string variable containing the path to the group (*.GRP) file (GroupPath$)
'**************************************

The first step is to add a label to a form. This example assumes you are using a label named "Label1". This label will be used in the DDE conversation between Program Manager and your proram. This example contains two SUBs. Both are placed into a BAS module. The first SUB creates the Program Manager Group, and the second SUB creates an icon within that group. These SUBs are called independantly (to allow for flexibility and clarity of illustration). 
The following SUB creates the Program Manager group. It requires 3 arguments to be passed to it. They are: 
1.The form that contains Label1 (x) 2.A string variable containing the group's name (GroupName$) 3.A string variable containing the path to the group (*.GRP) file (GroupPath$) 
Sub CreateProgManGroup (x As Form, GroupName$, GroupPath$)
Dim i%, z%'Declare required working variables
Screen.MousePointer = 11 'hourglass mousepointer while working
On Error Resume Next 'Not good to have program crash :-)
' Set LinkTopic & LinkMode parameters
x.Label1.LinkTopic = "ProgMan|Progman"
x.Label1.LinkMode = 2
For i% = 1 To 10 ' Give the DDE process time to take place
 z% = DoEvents() 
Next 
x.Label1.LinkTimeout = 100 
' Actually create the group now
x.Label1.LinkExecute "[CreateGroup(" + GroupName$ + Chr$(44) + GroupPath$ + ")]"
' Reset label properties and mousepointer
x.Label1.LinkTimeout = 50
x.Label1.LinkMode = 0
Screen.MousePointer = 0
End Sub
The following SUB creates the Program Manager icon. It requires 3 arguments to be passed to it. They are: 
1.The form that contains Label1 (x) 2.A string variable containing the icon's Command Line (CmdLine$) 3.A string variable containing the icon's Caption (IconTitle$) 
Sub CreateProgManItem (x As Form, CmdLine$, IconTitle$)
Dim i%, z%'Declare required working variables
Screen.MousePointer = 11 'hourglass mousepointer while working
On Error Resume Next 'Not good to have program crash :-)
' Set LinkTopic & LinkMode parameters
x.Label1.LinkTopic = "ProgMan|Progman"
x.Label1.LinkMode = 2
For i% = 1 To 10 ' Give the DDE process time to take place
 z% = DoEvents() 
Next 
x.Label1.LinkTimeout = 100
x.Label1.LinkExecute "[AddItem(" + CmdLine$ + Chr$(44) + IconTitle$ + Chr$(44) + ",,)]"
' Reset label properties and mousepointer
x.Label1.LinkTimeout = 50
x.Label1.LinkMode = 0
Screen.MousePointer = 0
End Sub
Finally, the last thing you need is for an event procedure (or any other form level routine) to call the 2 SUBs and provide the necessary information. In this example, I am creating a group window called VB Library and am placing it into the Windows directory. Then, I am creating an icon called "VB Library" within the group. This example creates an icon for the currently running program which happens to be Library.EXE. 
' Refer to Tips 23 and 24 for obtaining the Windows Directory
CreateProgManGroup Me, "VB Library", "c:\windows" 
CreateProgManItem Me, app.Path + "\library", "VB Library"
A little side note here. Thanks to Microsoft making Windows 95 backward-compatible, this routine runs fine within it. The group file will appear as an entry in the Start Menu's Programs section and the icon will be a sub-menu of that entry.


Other 4 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.