Category : BASIC Source Code
Archive   : VINST8.ZIP
Filename : ICONDEL.TXT

 
Output of file : ICONDEL.TXT contained in archive : VINST8.ZIP
' --------------------------------------------------------
' Procedure: CreateProgManItem
'
' Arguments:
' X The form where Text1 exists
'
' CmdLine$ A string that contains the command
' line for the item/icon.
' ie 'c:\myapp\setup.exe'
'
' IconTitle$ A string that contains the item's
' caption
'
' GroupName$ The name of the group to add the
' item to
' --------------------------------------------------------
Sub CreateProgManItem (x As Form, CmdLine$, IconTitle$, GroupName$)

Dim i%, Position%, Pos%, Pos2%, Continue%, FndDup%
Dim PrevPos%, Pos3%
Dim Temp$, Tmp$, Tmp2$, Tmp2a$, Tmp3$
Dim r%
Static iconcount%
Screen.MousePointer = 11


' -----------------------------------------------------
' Windows requires DDE in order to create a program
' group and item. Here, a Visual Basic text
' control is used to generate the DDE messages
' -----------------------------------------------------
On Error Resume Next


' -----------------------------------------------------
' Set LinkTopic to PROGRAM MANAGER
' -----------------------------------------------------
Setup1.Text1.LinkTopic = "ProgMan|Progman"
Setup1.Text1.LinkMode = 2 ' Set to COLD
For i% = 1 To 10 ' Loop to ensure that there is enough time to
DoEvents ' process DDE Execute. This is redundant but needed
Next ' for debug windows.
Setup1.Text1.LinkTimeout = 100


' -----------------------------------------------------
' Ask for the items in this group (returned in
' Text1.Text) - change to a group you actually have!
' Must use text box since label caption is limited to
' 1024 characters.
' -----------------------------------------------------
Setup1.Text1.LinkItem = GroupName$
Setup1.Text1.LinkRequest


' -----------------------------------------------------
' Reset properties
' -----------------------------------------------------
Setup1.Text1.LinkTimeout = 50
Setup1.Text1.LinkMode = 0


' -----------------------------------------------------
' Find if either the Icon Title or the Command line
' is the same as the one you are about to add.
' -----------------------------------------------------
i% = 1
Temp$ = Setup1.Text1.Text

Temp$ = Trim$(Temp$)
Position% = 1
PrevPos% = 1
Continue% = True

Do
' Get the to isolate the section
Pos% = InStr(PrevPos%, Temp$, Chr$(13))
Tmp$ = Mid$(Temp$, PrevPos%, Pos% - 1 - PrevPos%)
Pos% = Pos% + 1

If Pos% > 1 Then
If i% <> 1 Then
Pos2% = InStr(1, Tmp$, ",")
Tmp2a$ = Mid$(Tmp$, 2, Pos2% - 3)
Tmp2$ = UCase$(Tmp2a$)
Pos3% = InStr(Pos2% + 1, Tmp$, ",")
Tmp3$ = UCase$(Mid$(Tmp$, Pos2% + 2, Pos3% - 3 - Pos2%))

If UCase$(IconTitle$) = Tmp2$ Then
FndDup% = True
Exit Do
End If

If UCase$(CmdLine$) = Tmp3$ Then
FndDup% = True
Exit Do
End If

i% = i% + 1
Else
i% = i% + 1
End If
PrevPos% = Pos% + 1
Else
Continue% = False
End If
Loop While Continue% = True


' -----------------------------------------------------
' If found an identical icon title or command line,
' ask the user what he wants to do
' -----------------------------------------------------
If FndDup% = True Then
Load Duplicate_Icon
Tmp$ = "You are about to add an icon to the group "
Tmp$ = Tmp$ & UCase$(GroupName$) & ". A similar "
Tmp$ = Tmp$ & "already exists in this group. Do "
Tmp$ = Tmp$ & "you want to:"

Duplicate_Icon.LblForm.Caption = Tmp$
Duplicate_Icon.LblIconTitleCurrent.Caption = Tmp2$
Duplicate_Icon.LblIconCmdCurrent.Caption = Tmp3$
Duplicate_Icon.LblIconTitleNew.Caption = UCase$(IconTitle$)
Duplicate_Icon.LblIconCmdNew.Caption = UCase$(CmdLine$)
Screen.MousePointer = 0
CenterForm Duplicate_Icon
Duplicate_Icon.Show MODAL
FadeForm Setup1
Screen.MousePointer = 11

If gDupReturn% = 1 Then
' Continue as is
ElseIf gDupReturn% = 2 Then
' Replace the current icon
ElseIf gDupReturn% = 3 Then
' Abort and select new group
x.Text1.LinkMode = 0
Screen.MousePointer = 0
On Error GoTo 0
Exit Sub
End If
End If


' -----------------------------------------------------
' Set the focus to the selected group -- THIS IS
' CRITICAL!!
' 1 = Normal, with focus
' -----------------------------------------------------
x.Text1.LinkMode = 0
x.Text1.LinkTopic = "ProgMan|Progman"
x.Text1.LinkMode = 2
Setup1.Text1.LinkExecute "[ShowGroup(" & GroupName$ & ",1)]"
For i% = 1 To 5
DoEvents
Next i%


' -----------------------------------------------------
' Delete the item if that is what user selected
' -----------------------------------------------------
If FndDup% = True Then
If gDupReturn% = 2 Then
Setup1.Text1.LinkExecute "[DeleteItem(" & Tmp2a$ & ")]"
End If
For i% = 1 To 5
DoEvents
Next i%
End If


' -----------------------------------------------------
' Set LinkTopic to PROGRAM MANAGER
' -----------------------------------------------------
x.Text1.LinkMode = 0
x.Text1.LinkTopic = "ProgMan|Progman"
x.Text1.LinkMode = 2


' -----------------------------------------------------
' Loop to ensure that there is enough time to
' process DDE Execute. This is redundant but needed
' for debug windows.
' -----------------------------------------------------
For i% = 1 To 10
DoEvents
Next
x.Text1.LinkTimeout = 100


' -----------------------------------------------------
' Create Program Item, one of the icons to launch
' an application from Program Manager
' -----------------------------------------------------
Setup1.Text1.LinkExecute "[ShowGroup(" & GroupName$ & ",1)]"
For i% = 1 To 5
DoEvents
Next i%
x.Text1.LinkExecute "[AddItem(" & CmdLine$ & Chr$(44) & IconTitle$ & Chr$(44) & ",,)]"
iconcount% = iconcount% + 1
r% = writeprivateprofilestring("ICONS", "Iconnum", Format$(iconcount%), gunname$)
r% = writeprivateprofilestring("ICONS", "Num" + Format$(iconcount%), IconTitle$, gunname$)

' -----------------------------------------------------
' Reset properties
' -----------------------------------------------------
x.Text1.LinkTimeout = 50
x.Text1.LinkMode = 0

Screen.MousePointer = 0
On Error GoTo 0


End Sub


  3 Responses to “Category : BASIC Source Code
Archive   : VINST8.ZIP
Filename : ICONDEL.TXT

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/