home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / NexIRC_v2_2222363312012.psc / clsFMenu.cls < prev    next >
Text File  |  2007-03-03  |  31KB  |  756 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "clsFMenu"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Option Explicit
  15. Private Type gVariable
  16.     vName As String
  17.     vData As String
  18. End Type
  19. Private Type gVariables
  20.     vCount As Integer
  21.     vVariable(150) As gVariable
  22. End Type
  23. Private Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
  24. Private Declare Function CreatePopupMenu Lib "user32" () As Long
  25. Private Declare Function DestroyMenu Lib "user32" (ByVal hMenu As Long) As Long
  26. Private Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
  27. Private Declare Function GetPrivateProfileSectionNames Lib "kernel32.dll" Alias "GetPrivateProfileSectionNamesA" (ByVal lpszReturnBuffer As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
  28. Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
  29. Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
  30. Private Declare Function TrackPopupMenu Lib "user32" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal X As Long, ByVal Y As Long, ByVal nReserved As Long, ByVal hWnd As Long, ByVal lprc As Any) As Long
  31. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  32. Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal dwImageType As Long, ByVal dwDesiredWidth As Long, ByVal dwDesiredHeight As Long, ByVal dwFlags As Long) As Long
  33. Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long
  34. Private Const LR_LOADFROMFILE = &H10
  35. Private Const IMAGE_BITMAP = 0
  36. Private Const MF_BYCOMMAND = &H0&
  37. Private Const MF_BYPOSITION = &H400&
  38. Private Const MF_CHECKED = &H8&
  39. Private Const MF_DISABLED = &H2&
  40. Private Const MF_GRAYED = &H1&
  41. Private Const MF_MENUBARBREAK = &H20&
  42. Private Const MF_MENUBREAK = &H40&
  43. Private Const MF_POPUP = &H10&
  44. Private Const MF_SEPARATOR = &H800&
  45. Private Const MF_STRING = &H0&
  46. Private Const TPM_LEFTALIGN = &H0&
  47. Private Const TPM_RETURNCMD = &H100&
  48. Private Type FMENUITEM
  49.     lIcon As Long
  50.     lId As Long
  51.     lFlags As Long
  52.     sCaption As String
  53.     sCommand As String
  54.     sMenuName As String
  55. End Type
  56. Private Type FMENUITEMICON
  57.     lIcon As Long
  58.     sFilename As String
  59. End Type
  60. Private Type FMENUITEMCMDSTR
  61.     bGoteExecWinStyle As Boolean
  62.     bGoteMBType As Boolean
  63.     bGotlMBButtons As Boolean
  64.     bGotsCmd As Boolean
  65.     bGotsExec As Boolean
  66.     bGotsMBCaption As Boolean
  67.     bGotsMBText As Boolean
  68.     eExecWinStyle As VbAppWinStyle
  69.     eMBType As VbMsgBoxStyle
  70.     lMBButtons As Long
  71.     sCmd As String
  72.     sExec As String
  73.     sMBCaption As String
  74.     sMBText As String
  75. End Type
  76. Private m_tMenuItems() As FMENUITEM
  77. Private m_lIcons() As FMENUITEMICON
  78. Private m_lPopupMenus() As Long
  79. Private m_lNextAvailableItemID As Long
  80. Private m_lParentHWND As Long
  81. Private m_lMainHMENU As Long
  82. Private m_lNumIcons As Long
  83. Private lVariables As gVariables
  84. Public Event ItemClicked(sKey As String)
  85.  
  86. Public Property Get OwnerHWND() As Long
  87. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  88. OwnerHWND = m_lParentHWND
  89. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Public Property Get OwnerHWND() As Long"
  90. End Property
  91.  
  92. Public Property Let OwnerHWND(ByVal lVal As Long)
  93. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  94. m_lParentHWND = lVal
  95. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Public Property Get OwnerHWND() As Long"
  96. End Property
  97.  
  98. Private Sub Class_Initialize()
  99. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  100. ReDim Preserve m_tMenuItems(0 To 0)
  101. ReDim Preserve m_lIcons(0 To 0)
  102. ReDim Preserve m_lPopupMenus(0 To 0)
  103. m_lIcons(0).lIcon = -1
  104. m_lMainHMENU = CreatePopupMenu()
  105. m_lNextAvailableItemID = 1
  106. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Private Sub Class_Initialize()"
  107. End Sub
  108.  
  109. Private Sub Class_Terminate()
  110. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  111. Call DestroyAllMenus
  112. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Private Sub Class_Terminate()"
  113. End Sub
  114.  
  115. Private Function CacheIcon(ByVal sFile As String)
  116. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  117. Dim a As Long
  118. sFile = UCase$(sFile)
  119. For a = 0 To UBound(m_lIcons)
  120.     If (m_lIcons(a).sFilename = UCase$(sFile)) Then Exit Function
  121. Next a
  122. ReDim Preserve m_lIcons(0 To IIf(m_lIcons(0).lIcon = -1, 0, UBound(m_lIcons) + 1))
  123. With m_lIcons(UBound(m_lIcons))
  124.     .lIcon = LoadImage(-1, sFile, IMAGE_BITMAP, 13, 13, LR_LOADFROMFILE)
  125.     .sFilename = sFile
  126. End With
  127. m_lNumIcons = (m_lNumIcons + 1)
  128. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Private Function CacheIcon(ByVal sFile As String)"
  129. End Function
  130.  
  131. Public Function LoadMenus(ByVal sFile As String)
  132. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  133. Dim tTMI As FMENUITEM
  134. Dim a As Long, b As Long, c As Long, sTmpStr As String, lRet As Long
  135. Dim lNumSections As Long, lNumItems As Long, lNumIcons As Long
  136. lNumSections = CLng(GetPrivateProfileInt("INDEX", "NumSections", 0, sFile))
  137. lNumIcons = CLng(GetPrivateProfileInt("ICONS", "NumIcons", 0, sFile))
  138. For a = 1 To lNumIcons
  139.     sTmpStr = ReadINI(sFile, "ICONS", "Icon" & CStr(a))
  140.     If Len(sTmpStr) <> 0 Then sTmpStr = App.Path & "\data\images\menu\" & sTmpStr
  141.     If (sTmpStr <> "") Then Call CacheIcon(sTmpStr)
  142. Next a
  143. If (lNumSections > 0) Then
  144.     For a = 0 To (lNumSections - 1)
  145.         tTMI.sMenuName = UCase$(ReadINI(sFile, CStr(a), "MenuName"))
  146.         If (tTMI.sMenuName <> "") Then
  147.             lNumItems = GetPrivateProfileInt(CStr(a), "NumItems", 0, sFile)
  148.             If (lNumItems > 0) Then
  149.                 For b = 1 To lNumItems
  150.                     tTMI.sCaption = ReadINI(sFile, CStr(a), "Item" & CStr(b))
  151.                     tTMI.sCommand = ReadINI(sFile, CStr(a), "Item" & CStr(b) & "Command")
  152.                     tTMI.lFlags = MF_STRING
  153.                     sTmpStr = UCase$(ReadINI(sFile, CStr(a), "Item" & CStr(b) & "State"))
  154.                     If (InStr(1, sTmpStr, "CHECKED", vbTextCompare) > 0) Then tTMI.lFlags = (tTMI.lFlags Or MF_CHECKED)
  155.                     If (InStr(1, sTmpStr, "DISABLED", vbTextCompare) > 0) Then tTMI.lFlags = (tTMI.lFlags Or MF_DISABLED)
  156.                     If (InStr(1, sTmpStr, "GRAYED", vbTextCompare) > 0) Then tTMI.lFlags = (tTMI.lFlags Or MF_GRAYED)
  157.                     tTMI.lIcon = GetPrivateProfileInt(CStr(a), "Item" & CStr(b) & "Icon", 0, sFile)
  158.                     If (tTMI.lIcon > m_lNumIcons) Then
  159.                         tTMI.lIcon = 0
  160.                         If lSettings.sGeneralPrompts = True Then
  161.                             Call MsgBox("The requested icon # for [" & tTMI.sMenuName & "]Item" & CStr(b) & " is larger than the amount of icons specified. Defaulting to icon #0 (no icon). Please fix this error in your menu.", vbExclamation, "NexIRC")
  162.                         End If
  163.                     End If
  164.                     If (tTMI.sCaption = "-") Then
  165.                         tTMI.lFlags = MF_SEPARATOR
  166.                         tTMI.sCaption = ""
  167.                     End If
  168.                     If (tTMI.sCaption = "") Then tTMI.sCaption = " "
  169.                     If (tTMI.sCommand = "") Then
  170.                         tTMI.sCommand = "NX_NONE();"
  171.                     End If
  172.                     ReDim Preserve m_tMenuItems(0 To (UBound(m_tMenuItems) + 1))
  173.                     m_tMenuItems(UBound(m_tMenuItems)) = tTMI
  174.                     With tTMI
  175.                         .lFlags = 0&
  176.                         .lIcon = 0&
  177.                         .lId = 0&
  178.                         .sCaption = ""
  179.                         .sCommand = ""
  180.                     End With
  181.                 Next b
  182.             End If
  183.         Else
  184.             If (a = 0) Then
  185.                 If lSettings.sGeneralPrompts = True Then
  186.                     Call MsgBox("ROOT menu was not the first section encountered." & vbCrLf & "ROOT must -always- be the first section in the file." & vbCrLf & vbCrLf & "Menu creation terminated. Please fix this error in your menu.", vbCritical, "FMenu")
  187.                 End If
  188.                 ReDim m_tMenuItems(0 To 0) As FMENUITEM
  189.                 Exit Function
  190.             End If
  191.         End If
  192.     Next a
  193. End If
  194. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Public Function LoadMenus(ByVal sFile As String)"
  195. End Function
  196.  
  197. Private Function GetIndexesOfAllChildren(ByVal sMenuName As String, ByRef lIndexes() As Long) As Long
  198. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  199. Dim a As Long
  200. ReDim lIndexes(0 To 0) As Long
  201. lIndexes(0) = -1
  202. sMenuName = UCase$(sMenuName)
  203. For a = 0 To UBound(m_tMenuItems)
  204.     If (m_tMenuItems(a).sMenuName = sMenuName) Then
  205.         ReDim Preserve lIndexes(0 To IIf(lIndexes(0) = -1, 0, (UBound(lIndexes) + 1)))
  206.         lIndexes(UBound(lIndexes)) = a
  207.     End If
  208. Next a
  209. GetIndexesOfAllChildren = IIf(lIndexes(0) > -1, UBound(lIndexes) + 1, -1)
  210. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Private Function GetIndexesOfAllChildren(ByVal sMenuName As String, ByRef lIndexes() As Long) As Long"
  211. End Function
  212.  
  213. Private Function BuildMenu(ByVal DestHMENU As Long, ByVal sMenuName As String)
  214. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  215. Dim a As Long, lItems() As Long, sTmp As String
  216. Call GetIndexesOfAllChildren(sMenuName, lItems())
  217. If (lItems(0) > -1) Then
  218.     For a = 0 To UBound(lItems)
  219.         With m_tMenuItems(lItems(a))
  220.             .lId = m_lNextAvailableItemID
  221.             Call AppendMenu(DestHMENU, ByVal .lFlags, ByVal .lId, .sCaption)
  222.             If (.lIcon >= 1) Then
  223.                 Call SetMenuItemBitmaps(DestHMENU, ByVal .lId, MF_BYCOMMAND, ByVal m_lIcons(.lIcon - 1).lIcon, ByVal m_lIcons(.lIcon - 1).lIcon)
  224.             End If
  225.             If (UCase$(Mid$(.sCommand, 1, 14)) = "NX_INHERITMENU") Then
  226.                 sTmp = UCase$(.sCommand)
  227.                 If (Right$(sTmp, 2) = ");") Then
  228.                     sTmp = Mid$(sTmp, 1, Len(sTmp) - 2)
  229.                 End If
  230.                 Dim lUB As Long
  231.                 lUB = (UBound(m_lPopupMenus) + 1)
  232.                 ReDim Preserve m_lPopupMenus(0 To lUB)
  233.                 m_lPopupMenus(lUB) = CreatePopupMenu()
  234.                 sTmp = Mid$(sTmp, 16)
  235.                 If (m_lPopupMenus(lUB) > 0) Then
  236.                     Call ModifyMenu(m_lMainHMENU, .lId, .lFlags Or MF_POPUP, m_lPopupMenus(lUB), .sCaption)
  237.                     .lId = m_lPopupMenus(lUB)
  238.                     Call BuildMenu(m_lPopupMenus(lUB), sTmp)
  239.                 End If
  240.                 .sCommand = "NX_NONE();"
  241.             End If
  242.         End With
  243.         m_lNextAvailableItemID = (m_lNextAvailableItemID + 1)
  244.     Next a
  245. Else
  246.     Call AppendMenu(DestHMENU, MF_STRING Or MF_DISABLED, 0, "Error Building Menu")
  247.     Call AppendMenu(DestHMENU, MF_SEPARATOR, 0, "-")
  248.     Call AppendMenu(DestHMENU, MF_STRING Or MF_DISABLED, 0, "InheritMenu failed. The")
  249.     Call AppendMenu(DestHMENU, MF_STRING Or MF_DISABLED, 0, "requested section cannot")
  250.     Call AppendMenu(DestHMENU, MF_STRING Or MF_DISABLED, 0, "be located.")
  251. End If
  252. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Private Function BuildMenu(ByVal DestHMENU As Long, ByVal sMenuName As String)"
  253. End Function
  254.  
  255. Private Function FindItemByID(ByVal lId As Long) As Long
  256. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  257. Dim a As Long
  258. For a = 0 To UBound(m_tMenuItems)
  259.     With m_tMenuItems(a)
  260.         If .lId = lId Then
  261.             FindItemByID = a
  262.             Exit Function
  263.         End If
  264.     End With
  265. Next a
  266. FindItemByID = -1
  267. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Private Function FindItemByID(ByVal lID As Long) As Long"
  268. End Function
  269.  
  270. Private Function DestroyAllMenus()
  271. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  272. Dim a As Long
  273. Call DestroyMenu(m_lMainHMENU)
  274. For a = 0 To UBound(m_lPopupMenus)
  275.     If (m_lPopupMenus(a) > 0) Then Call DestroyMenu(m_lPopupMenus(a))
  276. Next a
  277. For a = 0 To UBound(m_tMenuItems)
  278.     If (m_tMenuItems(a).lIcon > 0) Then Call DeleteObject(m_tMenuItems(a).lIcon)
  279. Next a
  280. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Private Function DestroyAllMenus()"
  281. End Function
  282.  
  283. Public Sub RunScriptFile(lFileName As String)
  284. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  285. Dim msg As String, msg2 As String, msg3 As String
  286. If DoesFileExist(lFileName) = True Then
  287.     msg = ReadFile(lFileName)
  288.     If Len(msg) <> 0 Then
  289.         Do Until Len(msg) = 0
  290.             If InStr(msg, Chr(13)) Then
  291.                 msg2 = Trim(Left(msg, 1) & Parse(msg, Left(msg, 1), Chr(13)))
  292.                 msg = Trim(Right(msg, Len(msg) - Len(msg2) - 2))
  293.             Else
  294.                 msg2 = Trim(msg)
  295.                 msg = ""
  296.             End If
  297.             RunCommand msg2, mdiNexIRC
  298.         Loop
  299.     End If
  300. Else
  301.     ProcessReplaceString sFileNotFound, mdiNexIRC.ActiveForm.txtIncoming, lFileName
  302.     DoColorSep lSettings.sActiveServerForm.txtIncoming
  303. End If
  304. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Private Sub RunScriptFile(lFilename As String)"
  305. End Sub
  306.  
  307. Private Function FindVariableIndex(lName As String) As Integer
  308. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  309. Dim i As Integer
  310. If Len(lName) <> 0 Then
  311.     For i = 1 To 150
  312.         If LCase(lName) = LCase(lVariables.vVariable(i).vName) Then
  313.             FindVariableIndex = i
  314.             Exit Function
  315.         End If
  316.     Next i
  317.     FindVariableIndex = 151
  318. End If
  319. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Private Function FindVariableIndex(lName As String) As Integer"
  320. End Function
  321.  
  322. Public Function RunCommand(ByVal sCmd As String, lForm As Form) As Boolean
  323. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  324. Dim lParms As String, lSPLT() As String, i As Integer, lcmd As String, lSpltCount As Integer, msg As String, F As Integer, c As Integer, msg2 As String, lIfPositive As Boolean, var() As String
  325. If Len(sCmd) = 0 Then Exit Function
  326. lParms = Parse(sCmd, "(", ")")
  327. lcmd = Left(sCmd, Len(sCmd) - Len(lParms) - 3)
  328. If Left(lcmd, 2) = "//" Then Exit Function
  329. If InStr(lParms, "OpenDialog[") Then
  330.     msg = Parse(lParms, "OpenDialog[", "]")
  331.     If Len(msg) <> 0 Then
  332.         msg = Right(msg, Len(msg) - 10)
  333.         msg2 = "OpenDialog[" & msg & "]"
  334.         var = Split(msg, "|")
  335.         msg = ""
  336.         var(0) = Right(var(0), Len(var(0)) - 11)
  337.         var(0) = Replace(var(0), "{", "(")
  338.         var(0) = Replace(var(0), "}", ")")
  339.         var(0) = Replace(var(0), "+", "|")
  340.         Select Case LCase(var(0))
  341.         Case "$supported"
  342.             var(0) = "Audio (*.wav;*.mp3;*.wma;*.snd;*.au;*.ogg)|*.wav;*.mp3;*.wma;*.snd;*.au;*.ogg|All Files (*.*)|*.*|"
  343.         Case "$mp3"
  344.             var(0) = "MP3 Files (*.mp3)|*.mp3|All Files (*.*)|*.*|"
  345.         End Select
  346.         Select Case LCase(var(2))
  347.         Case "$curdir"
  348.             var(2) = CurDir & "\"
  349.         Case "$apppath"
  350.             var(2) = App.Path & "\"
  351.         End Select
  352.         msg = OpenDialog(lForm, var(0), var(1), var(2))
  353.         If Len(msg) <> 0 Then
  354.             If InStr(lParms, msg2) Then
  355.                 lParms = Replace(LCase(lParms), LCase(msg2), msg, , -1, vbTextCompare)
  356.             End If
  357.         End If
  358.     End If
  359. End If
  360. If InStr(LCase(lParms), "returnvsvariable[") Then
  361.     msg = Parse(lParms, "ariable[", "]")
  362.     msg = Right(msg, Len(msg) - 7)
  363.     msg2 = "ReturnVSVariable[" & msg & "]"
  364.     'mdiNexIRC.ctlVBScript.ExecuteStatement "mdiNexIRC.Tag = " & msg
  365.     If Len(mdiNexIRC.Tag) <> 0 Then
  366.         lParms = Replace(lParms, msg2, mdiNexIRC.Tag)
  367.         mdiNexIRC.Tag = ""
  368.     End If
  369. End If
  370. If InStr(LCase(lParms), "returnvariable[") Then
  371. RVAGAIN:
  372.     msg = Parse(lParms, "ariable[", "]")
  373.     msg = Right(msg, Len(msg) - 7)
  374.     If Len(msg) <> 0 Then
  375.         msg2 = "ReturnVariable[" & msg & "]"
  376.         i = FindVariableIndex(msg)
  377.         If i = 151 Then
  378.             ProcessReplaceString sVariableNotDeclared, lSettings.sActiveServerForm.txtIncoming, msg
  379.             Exit Function
  380.         End If
  381.         If i <> 0 And Len(lVariables.vVariable(i).vData) <> 0 Then
  382.             lParms = Replace(lParms, msg2, lVariables.vVariable(i).vData)
  383.         Else
  384.             lParms = Replace(lParms, msg2, " ")
  385.         End If
  386.         If InStr(LCase(lParms), "returnvariable[") Then GoTo RVAGAIN
  387.     End If
  388. End If
  389. If InStr(LCase(lParms), "copyvariable[") Then
  390.     msg = Parse(lParms, "copyvariable[", "]")
  391.     var = Split(msg, "|")
  392.     F = 0
  393.     c = 0
  394.     For i = 1 To 150
  395.         If InStr(LCase(lVariables.vVariable(i).vData), LCase(var(0))) Then
  396.             F = i
  397.             Exit For
  398.         End If
  399.         If InStr(LCase(lVariables.vVariable(i).vData), LCase(var(1))) Then
  400.             c = i
  401.             Exit For
  402.         End If
  403.     Next i
  404.     If F <> 0 And c <> 0 Then lVariables.vVariable(F).vData = lVariables.vVariable(c).vData
  405. End If
  406. lParms = Replace(lParms, "$ircsettings", GetINIFile(iIRC), 1, -1, vbTextCompare)
  407. If InStr(LCase(lParms), "readini[") Then
  408.     Dim ini() As String
  409.     ini = Split(Parse(lParms, "[", "]"), "|")
  410.     msg = ReadINI(ini(0), ini(1), ini(2), ini(3))
  411.     msg2 = "r" & Parse(LCase(lParms), "readini", "]") & "]"
  412.     lParms = Replace(LCase(lParms), LCase(msg2), msg, 1, -1, vbTextCompare)
  413. End If
  414. If InStr(lParms, "$activechannel") Then lParms = Replace(lParms, "$activechannel", mdiNexIRC.ActiveForm.Tag, 1, -1, vbTextCompare)
  415. If InStr(lParms, "$currentaudio") Then lParms = Replace(lParms, "$currentaudio", lPlayback.pCurrentFile, 1, -1, vbTextCompare)
  416. If InStr(lParms, "$server") Then lParms = Replace(lParms, "$server", lSettings.sServer, 1, -1, vbTextCompare)
  417. If InStr(lParms, "$port2") Then lParms = Replace(lParms, "$port2", Val(Mid(lSettings.sPort, 1)), 1, -1, vbTextCompare)
  418. If InStr(lParms, "$port") Then lParms = Replace(lParms, "$port", lSettings.sPort, 1, -1, vbTextCompare)
  419. If InStr(lParms, "$apppath") Then lParms = Replace(lParms, "$apppath", App.Path, 1, -1, vbTextCompare)
  420. If InStr(lParms, "$time") Then lParms = Replace(lParms, "$time", Time, 1, -1, vbTextCompare)
  421. If InStr(lParms, "$date") Then lParms = Replace(lParms, "$date", Date, 1, -1, vbTextCompare)
  422. If InStr(lParms, "$mynick") Then lParms = Replace(lParms, "$mynick", lSettings.sNickname, 1, -1, vbTextCompare)
  423. If InStr(lParms, "$myip") Then lParms = Replace(lParms, "$myip", lSettings.sActiveServerForm.tcp.LocalIP, 1, -1, vbTextCompare)
  424. If InStr(lParms, "$querynick") Then lParms = Replace(lParms, "$querynick", mdiNexIRC.ActiveForm.Caption)
  425. If InStr(lParms, "$password") Then lParms = Replace(lParms, "$password", lSettings.sPassword, 1, -1, vbTextCompare)
  426. If InStr(lParms, "$activeserver") Then lParms = Replace(lParms, "$activeserver", ReturnStatusWindowServer(FindStatusWindowIndexByTag(lSettings.sActiveServerForm.Tag)), 1, -1, vbTextCompare)
  427. If InStr(lParms, "$activeport") Then lParms = Replace(lParms, "$activeport", Val(Mid(ReturnStatusWindowPort(FindStatusWindowIndexByTag(lSettings.sActiveServerForm.Tag)), 1)), 1, -1, vbTextCompare)
  428. If InStr(lParms, "$lChannel") Then lParms = Replace(lParms, "$lChannel", mdiNexIRC.ActiveForm.Tag, 1, -1, vbTextCompare)
  429. If InStr(lParms, "NULL") Then lParms = Replace(lParms, "NULL", "", 1, -1, vbTextCompare)
  430. If InStr(lParms, "$nicklist") Then
  431.     lParms = Replace(lParms, "$nicklist", mdiNexIRC.ActiveForm.ReturnSelectedItem())
  432.     lParms = Replace(lParms, "@", "")
  433.     lParms = Replace(lParms, "+", "")
  434. End If
  435. lSPLT = Split(lParms, "::")
  436. lSpltCount = UBound(lSPLT)
  437. If InStr(LCase(lParms), "$input") Then
  438.     If InStr(LCase(lSPLT(0)), "$input") Then
  439.         msg = InputBox(lSPLT(1), lSPLT(2), lSPLT(3))
  440.         msg2 = "$input::" & lSPLT(1) & "::" & lSPLT(2) & "::" & lSPLT(3)
  441.         If Len(msg) <> 0 Then
  442.             lParms = Replace(lParms, msg2, msg)
  443.             lSPLT(1) = msg
  444.         End If
  445.     End If
  446.     If InStr(LCase(lSPLT(1)), "$input") Then
  447.         msg = InputBox(lSPLT(2), lSPLT(3), lSPLT(4))
  448.         msg2 = "$input::" & lSPLT(2) & "::" & lSPLT(3) & "::" & lSPLT(4)
  449.         If Len(msg) <> 0 Then
  450.             lParms = Replace(lParms, msg2, msg)
  451.             lSPLT(1) = msg
  452.         End If
  453.     End If
  454. End If
  455. lParms = Replace(lParms, "::", " ", 1, -1, vbTextCompare)
  456. Select Case LCase(Trim(lcmd))
  457. Case "writeini"
  458.     WriteINI lSPLT(0), lSPLT(1), lSPLT(2), lSPLT(3)
  459.     RunCommand = True
  460.     Exit Function
  461. Case "banaddress"
  462.     lSettings.sRetrieveAddressFromWhoisForBan = True
  463.     lSettings.sBanChannel = mdiNexIRC.ActiveForm.Tag
  464.     lSettings.sActiveServerForm.tcp.SendData "WHOIS " & lSPLT(0) & vbCrLf
  465.     RunCommand = True
  466.     Exit Function
  467. Case "showchannelproporties"
  468.     ProcessReplaceString sRequestChannelInformation, ReturnChannelIncomingTBox(FindChannelIndex(mdiNexIRC.ActiveForm.Tag))
  469.     lSettings.sActiveServerForm.tcp.SendData "MODE " & mdiNexIRC.ActiveForm.Tag & " +b" & vbCrLf
  470.     RunCommand = True
  471.     Exit Function
  472. Case "addignore"
  473.     AddToIgnore lSPLT(0)
  474.     RunCommand = True
  475.     Exit Function
  476. Case "connect"
  477.     If LCase(lSPLT(0)) <> "null" Then
  478.         If Len(lSPLT(0)) <> 0 And Len(lSPLT(1)) <> 0 Then
  479.             ConnectToIRC lSPLT(0), lSPLT(1), lForm
  480.         Else
  481.             ConnectToIRC lSettings.sServer, lSettings.sPort, lForm
  482.         End If
  483.     Else
  484.         ConnectToIRC lSettings.sServer, lSettings.sPort, lForm
  485.     End If
  486.     RunCommand = True
  487.     Exit Function
  488. Case "addbot"
  489.     frmAddBotCommand.Show
  490.     frmAddBotCommand.txtNickname.Text = lSPLT(0)
  491.     frmAddBotCommand.cboNicknameType.ListIndex = 1
  492.     RunCommand = True
  493.     Exit Function
  494. Case "docolor"
  495.     If Len(lSPLT(0)) <> 0 And Len(lSPLT(1)) <> 0 Then
  496.         If LCase(lSPLT(0)) = "$activeserver" Then
  497.             Call DoColor(lSettings.sActiveServerForm.txtIncoming, lSPLT(1))
  498.         Else
  499.             If lForm.Name = "mdiNexIRC" Then
  500.                 Call DoColor(mdiNexIRC.ActiveForm.txtIncoming, lSPLT(1))
  501.             Else
  502.                 Call DoColor(lForm.txtIncoming, lSPLT(1))
  503.             End If
  504.         End If
  505.     Else
  506.         'DoColor lForm.txtIncoming, "" & Color.Notify & " Could not find the window: " & lSPLT(0)
  507.     End If
  508.     RunCommand = True
  509.     Exit Function
  510. Case "addtonotify"
  511.     AddNotify lSPLT(0)
  512.     RunCommand = True
  513.     Exit Function
  514. Case "playmp3"
  515.     PlayFile lParms
  516.     'PlayMP3 lParms
  517.     RunCommand = True
  518.     Exit Function
  519. Case "playaudio"
  520.     PlayFile lParms
  521.     RunCommand = True
  522.     Exit Function
  523. Case "closeactivewindow"
  524.     Unload mdiNexIRC.ActiveForm
  525.     RunCommand = True
  526.     Exit Function
  527. Case "declarevariable"
  528.     For i = 1 To 150
  529.         If LCase(lVariables.vVariable(i).vName) = LCase(lParms) Then
  530.             F = i
  531.             Exit For
  532.         End If
  533.     Next i
  534.     If F = 0 Then
  535.         lVariables.vCount = lVariables.vCount + 1
  536.         lVariables.vVariable(lVariables.vCount).vName = lParms
  537.     End If
  538.     RunCommand = True
  539.     Exit Function
  540. Case "addfiletoplaylist"
  541.     AddToPlaylist lParms
  542.     RunCommand = True
  543.     Exit Function
  544. Case "editmenu"
  545.     Select Case LCase(lSPLT(0))
  546.     Case "channel"
  547.         frmMenuEditor.Show
  548.         frmMenuEditor.cboMenu.ListIndex = 1
  549.     Case "status"
  550.         frmMenuEditor.Show
  551.         frmMenuEditor.cboMenu.ListIndex = 0
  552.     Case "lQuery"
  553.         frmMenuEditor.Show
  554.         frmMenuEditor.cboMenu.ListIndex = 2
  555.     Case "nicklist"
  556.         frmMenuEditor.Show
  557.         frmMenuEditor.cboMenu.ListIndex = 3
  558.     End Select
  559.     RunCommand = True
  560.     Exit Function
  561. Case "queryuser"
  562.     NewQuery lSPLT(0)
  563.     RunCommand = True
  564.     Exit Function
  565.  
  566. Case "getfiletitle"
  567.     For i = 1 To 150
  568.         If LCase(lVariables.vVariable(i).vName) = LCase(lSPLT(0)) Then
  569.             lVariables.vVariable(i).vData = GetFileTitle(lVariables.vVariable(i).vData)
  570.             Exit For
  571.         End If
  572.     Next i
  573.     RunCommand = True
  574.     Exit Function
  575.     
  576. Case "addautoconnect"
  577.     AddToAutoConnect lSPLT(0), CLng(lSPLT(1))
  578.     RunCommand = True
  579.     Exit Function
  580. Case "if"
  581.     If LCase(lParms) = "true" Then lIfPositive = True
  582.     RunCommand = True
  583.     Exit Function
  584. Case "togglemixer"
  585.     If lSettings.sShowQuickmix = True Then
  586.         ToggleMixer False
  587.     Else
  588.         ToggleMixer True
  589.     End If
  590.     RunCommand = True
  591.     Exit Function
  592. Case "savelog"
  593.     msg = "log-" & Time$ & "-" & Date$ & ".log"
  594.     SaveFile App.Path & "\data\logs\" & msg, lSettings.sActiveServerForm.txtIncoming
  595.     ProcessReplaceString sSaveLog, mdiNexIRC.ActiveForm.txtIncoming, msg
  596.     RunCommand = True
  597.     Exit Function
  598. Case "endif"
  599.     lIfPositive = False
  600.     RunCommand = True
  601.     Exit Function
  602. Case "clearactiveserverwindowincoming"
  603.     lSettings.sActiveServerForm.txtIncoming.Text = ""
  604.     RunCommand = True
  605.     Exit Function
  606. Case "setvariabledata"
  607.     For i = 1 To 150
  608.         If LCase(lVariables.vVariable(i).vName) = LCase(lSPLT(0)) Then
  609.             lVariables.vVariable(i).vData = lSPLT(1)
  610.             Exit For
  611.         End If
  612.     Next i
  613.     RunCommand = True
  614.     Exit Function
  615. Case "clearvariable"
  616.     lParms = Left(lParms, Len(lParms) - 1)
  617.     lParms = Right(lParms, Len(lParms) - 1)
  618.     i = FindVariableIndex(lParms)
  619.     If i <> 0 Then
  620.         If i = lVariables.vCount Then lVariables.vCount = lVariables.vCount - 1
  621.         lVariables.vVariable(FindVariableIndex(lParms)).vData = ""
  622.         lVariables.vVariable(FindVariableIndex(lParms)).vName = ""
  623.     End If
  624.     RunCommand = True
  625.     Exit Function
  626. Case "msgbox"
  627.     MsgBox "Script: " & lParms
  628.     RunCommand = True
  629.     Exit Function
  630. Case "disconnect"
  631.     lForm.tcp.Close
  632.     RunCommand = True
  633.     Exit Function
  634. Case "showquickconnect"
  635.     frmQuickConnect.Show 0, mdiNexIRC
  636.     RunCommand = True
  637.     Exit Function
  638. Case "showconnectionmanager"
  639.     frmConnectionManager.Show
  640.     RunCommand = True
  641.     Exit Function
  642. Case "editautojoin"
  643.     frmAutoJoin.Show
  644.     RunCommand = True
  645.     Exit Function
  646. Case "joinchannel"
  647.     lForm.tcp.SendData "JOIN " & lParms & vbCrLf
  648.     RunCommand = True
  649.     Exit Function
  650. Case "addautojoin"
  651.     If LCase(lSPLT(0)) = "$activechannel" Then lSPLT(0) = mdiNexIRC.ActiveForm.Tag
  652.     If LCase(lSPLT(1)) = "$activenetwork" Then lSPLT(1) = lSettings.sNetwork
  653.     If Len(lSPLT(0)) <> 0 And Len(lSPLT(1)) <> 0 Then
  654.         AddAutoJoin lSPLT(0), lSPLT(1)
  655.     End If
  656.     RunCommand = True
  657.     Exit Function
  658. Case "addchannelfolder"
  659.     If LCase(lSPLT(0)) = "$activechannel" Then lSPLT(0) = mdiNexIRC.ActiveForm.Tag
  660.     If Len(lSPLT(0)) <> 0 Then AddtoChanFolder lSPLT(0)
  661.     RunCommand = True
  662.     Exit Function
  663. Case "resumeplayback"
  664.     MenuPlay
  665.     RunCommand = True
  666.     Exit Function
  667. Case "activateautojoin"
  668.     ActivateAutoJoin False
  669.     RunCommand = True
  670.     Exit Function
  671. Case "vbscript"
  672.     'mdiNexIRC.ctlVBScript.ExecuteStatement lParms
  673.     RunCommand = True
  674.     Exit Function
  675. Case "dccchat"
  676.     frmDCC_Chat.Show 0, mdiNexIRC
  677.     RunCommand = True
  678.     Exit Function
  679. Case "showadvancedsystemstats"
  680.     frmStats.Show
  681. Case "showsystemstats"
  682.     Select Case lSpltCount
  683.     Case 6
  684.         ShowSystemStats mdiNexIRC.ActiveForm, CBool(lSPLT(0)), CBool(lSPLT(1)), CBool(lSPLT(2)), CBool(lSPLT(3)), CBool(lSPLT(4)), CBool(lSPLT(5)), CBool(lSPLT(6))
  685.     Case 5
  686.         ShowSystemStats mdiNexIRC.ActiveForm, CBool(lSPLT(0)), CBool(lSPLT(1)), CBool(lSPLT(2)), CBool(lSPLT(3)), CBool(lSPLT(4)), CBool(lSPLT(5)), False
  687.     End Select
  688.     RunCommand = True
  689.     Exit Function
  690. Case "runvbscriptfile"
  691.     If DoesFileExist(lParms) = True Then
  692.         LoadScript lParms, True
  693.     Else
  694.         LoadScript lParms, False
  695.     End If
  696.     RunCommand = True
  697.     Exit Function
  698. Case "web"
  699.     Surf lParms, mdiNexIRC.hWnd
  700. Case "runscriptfile"
  701.     RunScriptFile App.Path & "\data\scripts\" & lParms
  702.     RunCommand = True
  703.     Exit Function
  704. Case "noticeops"
  705.     lSettings.sActiveServerForm.tcp.SendData "NOTICE " & lSPLT(0) & " :" & lSPLT(1) & vbCrLf
  706.     RunCommand = True
  707.     Exit Function
  708. Case "notice"
  709.     lSettings.sActiveServerForm.tcp.SendData "NOTICE " & lSPLT(0) & " :" & lSPLT(1) & vbCrLf
  710.     RunCommand = True
  711.     Exit Function
  712. Case "sendactiveserver"
  713.     lSettings.sActiveServerForm.tcp.SendData lParms & vbCrLf
  714.     RunCommand = True
  715.     Exit Function
  716. Case "activateautoconnect"
  717.     PerformAutoConnect
  718.     RunCommand = True
  719.     Exit Function
  720. Case "sendquitmessage"
  721.     If Len(lParms) <> 0 Then
  722.         If LCase(lParms) <> "null" Then
  723.             lSettings.sActiveServerForm.tcp.SendData "QUIT :" & lParms & vbCrLf
  724.         Else
  725.             SendQuitMessage lForm
  726.         End If
  727.     Else
  728.         SendQuitMessage lForm
  729.     End If
  730.     RunCommand = True
  731.     Exit Function
  732. End Select
  733. 'DoColor lForm.txtIncoming, "" & Color.Mode & "ò Unknown Command [" & "" & Color.CTCP & sCmd & "" & Color.Mode & "]"
  734. ProcessReplaceString sUnknownCommand, lForm.txtIncoming, sCmd
  735. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Public Function RunCommand(ByVal sCmd As String, lForm As Form) As Boolean"
  736. End Function
  737.  
  738. Public Function ShowMenu(ByVal X As Long, ByVal Y As Long, lForm As Form)
  739. If lSettings.sHandleErrors = True Then On Local Error Resume Next
  740. Dim lRet As Long, sCmdSplit() As String
  741. Call BuildMenu(m_lMainHMENU, "ROOT")
  742. lRet = TrackPopupMenu(m_lMainHMENU, TPM_LEFTALIGN Or TPM_RETURNCMD, ByVal X, ByVal Y, 0, m_lParentHWND, ByVal 0&)
  743. lRet = FindItemByID(lRet)
  744. If (lRet > 0) Then
  745.     With m_tMenuItems(lRet)
  746.         .sCommand = Replace(.sCommand, "$LF$", vbCrLf, 1, -1, vbTextCompare)
  747.         .sCommand = Replace(.sCommand, "$DATE$", Date$, 1, -1, vbTextCompare)
  748.         .sCommand = Replace(.sCommand, "$TIME$", Time$, 1, -1, vbTextCompare)
  749.         Call RunCommand(.sCommand, lForm)
  750.     End With
  751. Else
  752.     Exit Function
  753. End If
  754. If Err.Number <> 0 Then ProcessRuntimeError Err.Description, Err.Number, "Public Function ShowMenu(ByVal X As Long, ByVal Y As Long, lForm As Form)"
  755. End Function
  756.